mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-10-20 02:42:03 +08:00
grub-btrfsd: Fix #211 for OpenRC-Daemon
This commit is contained in:
@@ -69,6 +69,7 @@ uninstall:
|
|||||||
help:
|
help:
|
||||||
@echo
|
@echo
|
||||||
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
|
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
|
||||||
|
@echo "Example: $(MAKE) OPENRC=true SYSTEMD=false install"
|
||||||
@echo
|
@echo
|
||||||
@echo " actions: install"
|
@echo " actions: install"
|
||||||
@echo " uninstall"
|
@echo " uninstall"
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
## grub-btrfs
|
## grub-btrfs
|
||||||
|
|
||||||
This is a version 4.xx of grub-btrfs
|
[](https://github.com/Antynea/grub-btrfs/releases)
|
||||||
|

|
||||||
|
|
||||||
|
## grub-btrfs
|
||||||
|
|
||||||
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
||||||
- - -
|
- - -
|
||||||
### Description:
|
### Description:
|
||||||
@@ -22,7 +26,7 @@ This project includes its own solution.
|
|||||||
Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/initramfs/readme.md).
|
Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/initramfs/readme.md).
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
### What features does grub-btrfs v4.xx have?
|
### What features does grub-btrfs have?
|
||||||
* Automatically list snapshots existing on root partition (btrfs).
|
* Automatically list snapshots existing on root partition (btrfs).
|
||||||
* Automatically detect if `/boot` is in separate partition.
|
* Automatically detect if `/boot` is in separate partition.
|
||||||
* Automatically detect kernel, initramfs and intel/amd microcode in `/boot` directory on snapshots.
|
* Automatically detect kernel, initramfs and intel/amd microcode in `/boot` directory on snapshots.
|
||||||
@@ -47,9 +51,13 @@ eselect repository enable guru
|
|||||||
emerge --sync
|
emerge --sync
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Now merge grub-btrfs via
|
Now merge grub-btrfs via
|
||||||
`emerge app-backup/grub-btrfs`
|
`emerge app-backup/grub-btrfs`
|
||||||
|
|
||||||
|
If you are using SystemD on Gentoo, make sure the USE-Flag `systemD` is set. (Either globally in make.conf or in package.use for the package app-backup/grub-btrfs)
|
||||||
|
Without systemD USE-Flag the OpenRC-Daemon of grub-btrfs will be installed.
|
||||||
|
|
||||||
#### Kali Linux
|
#### Kali Linux
|
||||||
[grub-btrfs](http://pkg.kali.org/pkg/grub-btrfs) is available in the Kali Linux repository and can be installed with:
|
[grub-btrfs](http://pkg.kali.org/pkg/grub-btrfs) is available in the Kali Linux repository and can be installed with:
|
||||||
```
|
```
|
||||||
@@ -64,7 +72,7 @@ Booting into read-only snapshots is fully supported when choosing "btrfs" as fil
|
|||||||
* [btrfs-progs](https://archlinux.org/packages/core/x86_64/btrfs-progs/)
|
* [btrfs-progs](https://archlinux.org/packages/core/x86_64/btrfs-progs/)
|
||||||
* [grub](https://archlinux.org/packages/core/x86_64/grub/)
|
* [grub](https://archlinux.org/packages/core/x86_64/grub/)
|
||||||
* [bash >4](https://archlinux.org/packages/core/x86_64/bash/)
|
* [bash >4](https://archlinux.org/packages/core/x86_64/bash/)
|
||||||
* [gawk ](https://archlinux.org/packages/core/x86_64/gawk/)
|
* [gawk](https://archlinux.org/packages/core/x86_64/gawk/)
|
||||||
|
|
||||||
#### NOTE: All distros
|
#### NOTE: All distros
|
||||||
Generate your grub menu after installation for the changes to take effect.
|
Generate your grub menu after installation for the changes to take effect.
|
||||||
@@ -128,11 +136,12 @@ Currently not implemented
|
|||||||
##
|
##
|
||||||
#### OpenRC
|
#### OpenRC
|
||||||
1. If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
|
1. If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
|
||||||
|
* If you are using Timeshift, newer versions of it mount their snapshots to `/run/timeshift/$pidofthecurrentlyrunnigtimeshift/backup/timeshift-btrfs`. The OpenRC-Daemon can automatically take care of the detection of the correct PID and directory if you set the variable `timeshift_auto` to `true` in `etc/conf.d/grub-btrfsd`. In this case the variable `snapshots` has no influence.
|
||||||
|
* If you don't want to use `timeshift_auto`, set the variable `snapshots` in the file `/etc/conf.d/grub-btrfsd` to the path of your snapshot directory. By default this is set to snappers default directory, `./snapper`.
|
||||||
|
For Timeshift keep in mind, that newer versions of Timeshift will not work with the `/run/timeshift/backup/timeshift-btrfs/snapshots` path. However there is a [workaround](https://www.lorenzobettini.it/2022/07/timeshift-and-grub-btrfs-in-linux-arch/) that works for now.
|
||||||
* Use `rc-config add grub-btrfsd default`, to start the grub-btrfsd daemon the next time the system boots.
|
* Use `rc-config add grub-btrfsd default`, to start the grub-btrfsd daemon the next time the system boots.
|
||||||
* To start `grub-btrfsd` right now, run `rc-service grub-btrfsd start`
|
* To start `grub-btrfsd` right now, run `rc-service grub-btrfsd start`
|
||||||
* `grub-btrfsd` automatically watches the snapshot directory of timeshift (/run/timeshift/backup/timeshift-btrfs/snapshots)
|
* `grub-btrfsd` automatically watches the snapshot directory and updates the grub-menu when a change occurs
|
||||||
and updates the grub-menu when a change occurs.
|
|
||||||
* Currently untested for snapper
|
|
||||||
|
|
||||||
2. If you would like grub-btrfs menu to automatically update on system restart/ shutdown:
|
2. If you would like grub-btrfs menu to automatically update on system restart/ shutdown:
|
||||||
Just add the following script as `/etc/local.d/grub-btrfs-update.stop`
|
Just add the following script as `/etc/local.d/grub-btrfs-update.stop`
|
||||||
@@ -150,7 +159,7 @@ Just add the following script as `/etc/local.d/grub-btrfs-update.stop`
|
|||||||
bash -c 'if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else {GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o {GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi'
|
bash -c 'if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else {GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o {GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi'
|
||||||
```
|
```
|
||||||
|
|
||||||
Make your script executeable with `chmod a+x /etc/local.d/grub-btrfs-update.stop`.
|
Make your script executable with `chmod a+x /etc/local.d/grub-btrfs-update.stop`.
|
||||||
|
|
||||||
* The extension ".stop" at the end of the filename indicates to locald that this script should be run at shutdown.
|
* The extension ".stop" at the end of the filename indicates to locald that this script should be run at shutdown.
|
||||||
If you want to run the menu update on startup instead, rename the file to `grub-btrfs-update.start`
|
If you want to run the menu update on startup instead, rename the file to `grub-btrfs-update.start`
|
||||||
|
|||||||
+39
-3
@@ -1,7 +1,43 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo $$ > /run/grub-btrfsd.pid
|
# Copyright 2022 Pascal Jaeger
|
||||||
snapshots="${1:-/run/timeshift/backup/timeshift-btrfs/snapshots}"
|
# Distributed under the terms of the GNU General Public License v3
|
||||||
|
# Update GRUB when new BTRFS snapshots are created.
|
||||||
|
|
||||||
while true; do sleep 1 && inotifywait -e create -e delete "$snapshots" && sleep 5 && if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi ; done
|
timeshift_pid
|
||||||
|
watchtime=0
|
||||||
|
|
||||||
|
snapshots="${1}"
|
||||||
|
timeshift_auto="${2}"
|
||||||
|
|
||||||
|
if ! [ "${#snapshots}" -gt 0 ] && ! [ ${timeshift_auto} ]; then
|
||||||
|
echo "Please specify the snapshots directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ${timeshift_auto} ]; then
|
||||||
|
watchtime=15
|
||||||
|
else
|
||||||
|
watchtime=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if [ ${timeshift_auto} == "true" ] && ! [ "${#timeshift_pid}" -gt 0 ] ; then
|
||||||
|
inotifywait -e create -e delete /run/timeshift && {
|
||||||
|
sleep 1
|
||||||
|
timeshift_pid=$(ps ax | awk '{sub(/.*\//, "", $5)} $5 ~ /timeshift/ {print $1}')
|
||||||
|
snapshots="/run/timeshift/${timeshift_pid}/backup/timeshift-btrfs/snapshots"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
while [ -d "$snapshots" ]; do
|
||||||
|
sleep 1
|
||||||
|
inotifywait -e create -e delete -e unmount -t "$watchtime" "$snapshots" && {
|
||||||
|
sleep 5
|
||||||
|
if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then
|
||||||
|
/etc/grub.d/41_snapshots-btrfs
|
||||||
|
else
|
||||||
|
${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
done
|
||||||
|
timeshift_pid=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|||||||
+10
-3
@@ -1,3 +1,10 @@
|
|||||||
# Where to locate the root snapshots
|
# Copyright 2022 Pascal Jaeger
|
||||||
#snapshots="/.snapshots" # Snapper in the root directory
|
# Distributed under the terms of the GNU General Public License v3
|
||||||
snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift
|
|
||||||
|
## Where to locate the root snapshots
|
||||||
|
snapshots="/.snapshots" # Snapper in the root directory
|
||||||
|
#snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
|
||||||
|
|
||||||
|
## Autodetect timeshift snapshot directory. If this it set to true, variable snapshots is not taken into account. Use this for Timeshift >= v22.06
|
||||||
|
timeshift_auto=true # Timeshift >= v22.06
|
||||||
|
#timeshift_auto=false # snapper
|
||||||
|
|||||||
+3
-5
@@ -1,15 +1,13 @@
|
|||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
# Copyright 1999-2021 Gentoo Foundation
|
# Copyright 2021 Pascal Jaeger
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v3
|
||||||
|
|
||||||
name="grub-btrfs daemon"
|
name="grub-btrfs daemon"
|
||||||
command="/usr/bin/grub-btrfs-openrc"
|
command="/usr/bin/grub-btrfs-openrc"
|
||||||
command_args="${snapshots}"
|
command_args="${snapshots} ${timeshift_auto}"
|
||||||
pidfile="/run/{RC_SVCNAME}.pid"
|
pidfile="/run/{RC_SVCNAME}.pid"
|
||||||
command_background=true
|
command_background=true
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
use localmount
|
use localmount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user