grub-btrfsd: Update README.md, Fix #213

Signed-off-by: Jaeger <Pascal.Jaeger@bode-kassel.com>
This commit is contained in:
Pascal J
2022-08-20 11:01:06 +02:00
committed by Pascal Jäger
parent 6280f95139
commit 14c42b82eb

109
README.md
View File

@@ -3,14 +3,9 @@
## grub-btrfs
[![GitHub release](https://img.shields.io/github/release/Antynea/grub-btrfs.svg)](https://github.com/Antynea/grub-btrfs/releases)
![](https://img.shields.io/github/license/Antynea/grub-btrfs.svg)
## grub-btrfs
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
* BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
- - -
### Description:
### Description
Improves grub by adding "btrfs snapshots" to the grub menu.
You can boot your system on a "snapshot" from the grub menu.
@@ -35,7 +30,7 @@ Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/i
* Automatically generate `grub.cfg` if you use the provided systemd service.
- - -
### Installation:
### Installation
#### Arch Linux
The package is available in the community repository [grub-btrfs](https://archlinux.org/packages/community/any/grub-btrfs/)
```
@@ -50,14 +45,12 @@ emerge -av app-eselect/eselect-repository
eselect repository enable guru
emerge --sync
```
Now merge grub-btrfs via
`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.
Emerge grub-btrfs via
`emerge app-backup/grub-btrfs`
#### Kali Linux
[grub-btrfs](http://pkg.kali.org/pkg/grub-btrfs) is available in the Kali Linux repository and can be installed with:
```
@@ -81,29 +74,38 @@ On **Arch Linux** or **Gentoo** use `grub-mkconfig -o /boot/grub/grub.cfg`.
On **Fedora** use `grub2-mkconfig -o /boot/grub2/grub.cfg`
On **Debian-like** distribution `update-grub` is an alias to `grub-mkconfig ...`
- - -
### Customization:
### Customization
You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`.
See [config file](https://github.com/Antynea/grub-btrfs/blob/master/config) for more information.
#### Warning:
by default, `grub-mkconfig` command is used.
Might be `grub2-mkconfig` on some systems (Fedora ...).
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this.
- - -
### Automatically update grub upon snapshot:
### SystemD service
#### Automatically update grub upon snapshot
To automatically regenerate `grub-btrfs.cfg` when a modification appears in the `/.snapshots` mount point, run
```bash
```
systemctl enable grub-btrfs.path
systemctl start grub-btrfs.path # In case the mount point is available already
```
Monitoring starts automatically when the mount point becomes available.
#### Snapshots not in `/.snapshots`
##### Snapshots not in `/.snapshots`
To modify `grub-btrfs.path` run
```bash
```
systemctl edit --full grub-btrfs.path
systemctl reenable grub-btrfs.path
```
To find out the name of the `.mount` unit use `systemctl list-units -t mount`.
#### Automatically update grub upon restart/ boot:
[Look at this comment](https://github.com/Antynea/grub-btrfs/issues/138#issuecomment-766918328)
Currently not implemented
**Timeshift**
1. Run `systemctl edit --full grub-btrfs.path`
1. Replace the whole block by:
```
@@ -128,47 +130,52 @@ Note:
You can view your change to `systemctl cat grub-btrfs.path`.
To revert change use `systemctl revert grub-btrfs.path`.
----
### Automatically update grub upon restart/boot:
[Look at this comment](https://github.com/Antynea/grub-btrfs/issues/138#issuecomment-766918328)
Currently not implemented
Note: If you are using timeshift version v22.06 or newer, snapshots are now saved in the direcory `/run/timeshift/$PIDofthecurrentlyrunnigtimeshift/backup/timeshift-btrfs` by Timeshift. The PID is changing everytime you open Timeshift. This can not be changed, but when the mount `/run/timeshift/backup/` is created in `/etc/fstab` timeshift will use that. For further information on this workaround see [Lorenzo Bettinis blog](https://www.lorenzobettini.it/2022/07/timeshift-and-grub-btrfs-in-linux-arch/).
##
#### OpenRC
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.
* To start `grub-btrfsd` right now, run `rc-service grub-btrfsd start`
* `grub-btrfsd` automatically watches the snapshot directory and updates the grub-menu when a change occurs
### OpenRC daemon
#### Automatically update grub upon snapshot
If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted, configure `/etc/conf.d/grub-btrfsd` and after that start the daemon.
###### Timeshift versions >= v22.06 (default)
This is the default setting, you don't need to change anything in `/etc/conf.d/grub-btrfsd`, keep on reading at the "How to (auto)start the daemon" heading.
Newer versions of Timeshift mount their snapshots to `/run/timeshift/$PIDofthecurrentlyrunnigtimeshift/backup/timeshift-btrfs`. The PID is changing everytime you close Timeshift and open it again. 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.
###### Timeshift versions < v22.06
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. This is usually `/run/timeshift/backup/timeshift-btrfs/snapshots`. This will not work for newer Timeshift versions, however there is a [workaround](https://www.lorenzobettini.it/2022/07/timeshift-and-grub-btrfs-in-linux-arch/) that works for now. Basically you need to mount the root subvolume to `/run/timeshift/backup` by putting this line into `/etc/fstab`:
```
UUID=<UUID> /run/timeshift/backup btrfs defaults,noatime 0 0
```
You can get your UUID with the command `blkid`.
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`
```bash
#!/bin/bash
###### Snapper
For snapper set `timeshift-auto=false` and `snapshots` to Snapper snapshots directory. (usually `/.snapshots`)
##### How to (auto)start the daemon
Use `sudo 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 `sudo rc-service grub-btrfsd start`.
`grub-btrfsd` then automatically watches the snapshot directory and updates the grub-menu when a change occurs.
When you changed a setting in `/etc/conf.d/grub-btrfd`, you have to restart the daemon with `sudo rc-service grub-btrfd restart` to make the change become effective.
#### Automatically update grub upon restart/boot:
If you would like the grub-btrfs menu to automatically update on system restart/ shutdown, just add the following script as `/etc/local.d/grub-btrfs-update.stop`:
```bash
#!/usr/bin/env bash
description="Update the grub btrfs snapshots menu"
name="grub-btrfs-update"
depend()
{
use localmount
}
description="Update the grub btrfs snapshots menu"
name="grub-btrfs-update"
depend()
{
use localmount
}
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 executable with `chmod a+x /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'
```
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.
If you want to run the menu update on startup instead, rename the file to `grub-btrfs-update.start`
* Works for snapper and timeshift
##### Warning:
by default, `grub-mkconfig` command is used.
Might be `grub2-mkconfig` on some systems (Fedora ...).
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this.
- - -
### Special thanks for assistance and contributions
* [Maxim Baz](https://github.com/maximbaz)