mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-04 21:15:02 +08:00
Compare commits
112 Commits
v4.5
...
fix-snap-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efc4657aab | ||
|
|
6f154329c7 | ||
|
|
4942989d7f | ||
|
|
91c4aac82c | ||
|
|
1d760ad730 | ||
|
|
02c3fbb23a | ||
|
|
13b6df8e9a | ||
|
|
2186d831cd | ||
|
|
c9620d5d18 | ||
|
|
33810a9274 | ||
|
|
1969132073 | ||
|
|
ead3849613 | ||
|
|
75f7d85261 | ||
|
|
d406ce795c | ||
|
|
b2b5307fe4 | ||
|
|
57687ac0ab | ||
|
|
a6e9caf6f4 | ||
|
|
36cee77bd8 | ||
|
|
de68795d70 | ||
|
|
4c63b65e9e | ||
|
|
bc09bbda65 | ||
|
|
19f62ee6e6 | ||
|
|
4580c0fa2c | ||
|
|
44573e5282 | ||
|
|
5805029c79 | ||
|
|
9064d61145 | ||
|
|
8c8ee200fd | ||
|
|
961675ca31 | ||
|
|
14c42b82eb | ||
|
|
6280f95139 | ||
|
|
d54f3d7366 | ||
|
|
c78bd25784 | ||
|
|
0182e11951 | ||
|
|
3dc1d89965 | ||
|
|
fc4a5a8e56 | ||
|
|
a146cd5c9d | ||
|
|
8dbe80c0bd | ||
|
|
79ae25ea5d | ||
|
|
ee3c366fa4 | ||
|
|
4f1aa38604 | ||
|
|
1accd5e272 | ||
|
|
2500ce8d30 | ||
|
|
d9f54afcb7 | ||
|
|
33ad3273d3 | ||
|
|
3b0d0c4ff7 | ||
|
|
66a218356a | ||
|
|
7dc240faa7 | ||
|
|
75e6408510 | ||
|
|
fbc33391cb | ||
|
|
63c3493504 | ||
|
|
02b925e4b5 | ||
|
|
9d436adf95 | ||
|
|
301752f300 | ||
|
|
3b857348cb | ||
|
|
f3d8e99cb8 | ||
|
|
af80fe7993 | ||
|
|
c7f403d2a2 | ||
|
|
e6898c0de8 | ||
|
|
a790ff054e | ||
|
|
df643361cc | ||
|
|
b0408225c1 | ||
|
|
8142691be1 | ||
|
|
bab78d4ed8 | ||
|
|
544d2e84ac | ||
|
|
b346727219 | ||
|
|
f1ca0db36d | ||
|
|
c4d0df3a97 | ||
|
|
c1cadccd1f | ||
|
|
8cc214fd0e | ||
|
|
81bde02b03 | ||
|
|
14bf041ba6 | ||
|
|
863107588c | ||
|
|
2851ecd72b | ||
|
|
679d000446 | ||
|
|
981777d745 | ||
|
|
3433754c69 | ||
|
|
db753a9ac8 | ||
|
|
83bf1da01e | ||
|
|
2f22fd8630 | ||
|
|
88a0320d62 | ||
|
|
87b816345b | ||
|
|
d68fdf5fff | ||
|
|
87168d2d50 | ||
|
|
a437b80a35 | ||
|
|
9408231ecc | ||
|
|
9722f6732c | ||
|
|
0ed5adaf32 | ||
|
|
d4b97415b0 | ||
|
|
da36aa8847 | ||
|
|
d8df766554 | ||
|
|
9adce629f7 | ||
|
|
3c5e741641 | ||
|
|
fa65c3d6d9 | ||
|
|
4493bdc6e4 | ||
|
|
a7289b182a | ||
|
|
0fe512776a | ||
|
|
6af193c47a | ||
|
|
9a771d9842 | ||
|
|
64c08a0807 | ||
|
|
c9b605153b | ||
|
|
7e922abefb | ||
|
|
d20439554e | ||
|
|
ce8261395f | ||
|
|
133c8ebfdb | ||
|
|
2349282df5 | ||
|
|
041a9c6606 | ||
|
|
7e5bfa597f | ||
|
|
f0382536fb | ||
|
|
b50ad439d4 | ||
|
|
5f40f30985 | ||
|
|
d2c15acd72 | ||
|
|
77d69aaa81 |
File diff suppressed because it is too large
Load Diff
118
Makefile
118
Makefile
@@ -1,23 +1,121 @@
|
||||
PKGNAME ?= grub-btrfs
|
||||
PREFIX ?= /usr
|
||||
|
||||
INITCPIO ?= false
|
||||
SYSTEMD ?= true
|
||||
OPENRC ?= false
|
||||
|
||||
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
|
||||
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
|
||||
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
|
||||
MAN_DIR = $(SHARE_DIR)/man
|
||||
|
||||
.PHONY: install
|
||||
TEMP_DIR = ./temp
|
||||
|
||||
.PHONY: install uninstall clean help
|
||||
|
||||
install:
|
||||
@if test "$(shell id -u)" != 0; then \
|
||||
echo "You are not root, run this target as root please."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo " Installing "
|
||||
@echo
|
||||
@echo " :::::::: ::::::::: ::: ::: ::::::::: ::::::::: ::::::::::: ::::::::: :::::::::: :::::::: "
|
||||
@echo " :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: "
|
||||
@echo " +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ "
|
||||
@echo " :#: +#++:++#: +#+ +:+ +#++:++#+ +#++:++#++:++ +#++:++#+ +#+ +#++:++#: :#::+::# +#++:++#++ "
|
||||
@echo " +#+ +#+# +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ "
|
||||
@echo " #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# "
|
||||
@echo " ######## ### ### ######## ######### ######### ### ### ### ### ######## "
|
||||
@echo
|
||||
@echo " For further information visit https://github.com/Antynea/grub-btrfs or read the man page: 'man grub-btrfs'"
|
||||
@echo
|
||||
@mkdir "${TEMP_DIR}"
|
||||
@chmod 777 ${TEMP_DIR}
|
||||
@cp manpages/grub-btrfs.8.man ${TEMP_DIR}/grub-btrfs.8
|
||||
@bzip2 ${TEMP_DIR}/grub-btrfs.8
|
||||
@install -Dm644 -t "${MAN_DIR}/man8" "${TEMP_DIR}/grub-btrfs.8.bz2"
|
||||
@cp manpages/grub-btrfsd.8.man ${TEMP_DIR}/grub-btrfsd.8
|
||||
@bzip2 ${TEMP_DIR}/grub-btrfsd.8
|
||||
@install -Dm644 -t "${MAN_DIR}/man8" "${TEMP_DIR}/grub-btrfsd.8.bz2";
|
||||
@install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs
|
||||
@install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config
|
||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service
|
||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path
|
||||
@install -Dm744 -t "$(BIN_DIR)/" grub-btrfsd;
|
||||
@# Systemd init system
|
||||
@if test "$(SYSTEMD)" = true; then \
|
||||
echo "Installing systemd .service file"; \
|
||||
install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfsd.service; \
|
||||
fi
|
||||
@# OpenRC init system
|
||||
@if test "$(OPENRC)" = true; then \
|
||||
echo "Installing openRC init.d & conf.d file"; \
|
||||
install -Dm744 grub-btrfsd.initd "$(DESTDIR)/etc/init.d/grub-btrfsd"; \
|
||||
install -Dm644 grub-btrfsd.confd "$(DESTDIR)/etc/conf.d/grub-btrfsd"; \
|
||||
fi
|
||||
@# Arch Linux like distros only :
|
||||
@if test "$(INITCPIO)" = true; then \
|
||||
echo "Installing initcpio hook"; \
|
||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \
|
||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
|
||||
fi
|
||||
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
||||
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
||||
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
@rm -rf "${TEMP_DIR}"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs"
|
||||
rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||
rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs"
|
||||
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.service"
|
||||
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path"
|
||||
rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
|
||||
rm -f "$(DESTDIR)/boot/grub/grub-btrfs.cfg"
|
||||
@echo "Uninstalling grub-btrfs"
|
||||
@if test "$(shell id -u)" != 0; then \
|
||||
echo "You are not root, run this target as root please."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@grub_dirname="$$(grep -oP '^[[:space:]]*GRUB_BTRFS_GRUB_DIRNAME=\K.*' "$(DESTDIR)/etc/default/grub-btrfs/config" | sed "s|\s*#.*||;s|(\s*\(.\+\)\s*)|\1|;s|['\"]||g")"; \
|
||||
rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
|
||||
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||
@rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs"
|
||||
@rm -f "$(LIB_DIR)/systemd/system/grub-btrfsd.service"
|
||||
@rm -f "$(BIN_DIR)/grub-btrfsd;"
|
||||
@rm -f "$(DESTDIR)/etc/init.d/grub-btrfsd;"
|
||||
@rm -f "$(DESTDIR)/etc/conf.d/grub-btrfsd;"
|
||||
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
|
||||
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
|
||||
@rm -f "$(MAN_DIR)/man8/grub-btrfs.8.bz2"
|
||||
@rm -f "$(MAN_DIR)/man8/grub-btrfsd.8.bz2"
|
||||
@# Arch Linux UNlike distros only :
|
||||
@if test "$(INITCPIO)" != true && test -d "$(LIB_DIR)/initcpio"; then \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
|
||||
fi
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/README.md"
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
@rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/doc/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/licenses/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" || :
|
||||
|
||||
clean:
|
||||
@echo "Deleting ./temp"
|
||||
@rm -rf "${TEMP_DIR}"
|
||||
|
||||
help:
|
||||
@echo
|
||||
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
|
||||
@echo "Example: $(MAKE) OPENRC=true SYSTEMD=false install"
|
||||
@echo
|
||||
@echo " actions: install"
|
||||
@echo " uninstall"
|
||||
@echo " help"
|
||||
@echo
|
||||
@echo " parameter | type | description | defaults"
|
||||
@echo " ----------+------+--------------------------------+----------------------------"
|
||||
@echo " DESTDIR | path | install destination | <unset>"
|
||||
@echo " PREFIX | path | system tree prefix | '/usr'"
|
||||
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
||||
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
||||
@echo " PKGNAME | name | name of the ditributed package | 'grub-btrfs'"
|
||||
@echo " INITCPIO | bool | include mkinitcpio hook | false"
|
||||
@echo " SYSTEMD | bool | include unit files | true"
|
||||
@echo " OPENRC | bool | include OpenRc daemon | false"
|
||||
@echo
|
||||
|
||||
491
README.md
491
README.md
@@ -1,169 +1,390 @@
|
||||
[](https://github.com/Antynea/grub-btrfs/releases)
|
||||

|
||||
|
||||
## grub-btrfs
|
||||
## 💻 grub-btrfs
|
||||
|
||||
This is a version 4.xx of grub-btrfs
|
||||
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
||||
##
|
||||
### Description
|
||||
Improves Grub by adding "btrfs snapshots" to the Grub menu.
|
||||
|
||||
You can start your system on a "snapshot" from the Grub menu.
|
||||
- - -
|
||||
### 🔎 Description:
|
||||
Improves grub by adding "btrfs snapshots" to the grub menu.
|
||||
|
||||
You can boot your system on a "snapshot" from the grub menu.
|
||||
Supports manual snapshots, snapper, timeshift ...
|
||||
|
||||
##### Warning: booting on read-only snapshots can be tricky
|
||||
|
||||
If you choose to do it, `/var/log` must be on a separate subvolume.
|
||||
|
||||
Otherwise, make sure your snapshots are writeable.
|
||||
|
||||
If you choose to do it, `/var/log` or even `/var` must be on a separate subvolume.
|
||||
Otherwise, make sure your snapshots are writable.
|
||||
See [this ticket](https://github.com/Antynea/grub-btrfs/issues/92) for more info.
|
||||
|
||||
### What does grub-btrfs v4.xx do :
|
||||
* Automatically List snapshots existing on root partition (btrfs).
|
||||
* Automatically Detect if "/boot" is in separate partition.
|
||||
* Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots.
|
||||
* Automatically Create corresponding "menuentry" in `grub.cfg`
|
||||
* Automatically detect snapper and use snapper's snapshot description if available.
|
||||
* Automatically generate `grub.cfg` if you use the provided systemd service.
|
||||
##
|
||||
### Installation :
|
||||
#### Arch Linux
|
||||
This project includes its own solution.
|
||||
Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/initramfs/readme.md).
|
||||
|
||||
- - -
|
||||
### ✨ What features does grub-btrfs have?
|
||||
* Automatically list snapshots existing on root partition (btrfs).
|
||||
* Automatically detect if `/boot` is in separate partition.
|
||||
* Automatically detect kernel, initramfs and Intel/AMD microcode in `/boot` directory on snapshots.
|
||||
* Automatically create corresponding "menuentry" in `grub.cfg`
|
||||
* Automatically detect the type/tags and descriptions/comments of Snapper/Timeshift snapshots.
|
||||
* Automatically generate `grub.cfg` if you use the provided Systemd/ OpenRC service.
|
||||
|
||||
- - -
|
||||
### 🛠️ Installation:
|
||||
#### Arch Linux
|
||||
The package is available in the community repository [grub-btrfs](https://archlinux.org/packages/community/any/grub-btrfs/)
|
||||
```
|
||||
pacman -S grub-btrfs
|
||||
```
|
||||
|
||||
### Manual
|
||||
#### Gentoo
|
||||
grub-btrfs is only available in the Gentoo User Repository (GURU) and not in the official Gentoo repository.
|
||||
If you have not activated the GURU yet, do so by running:
|
||||
```
|
||||
emerge -av app-eselect/eselect-repository
|
||||
eselect repository enable guru
|
||||
emaint sync -r guru
|
||||
```
|
||||
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:
|
||||
```
|
||||
apt install grub-btrfs
|
||||
```
|
||||
Booting into read-only snapshots is fully supported when choosing "btrfs" as file system during a standard Kali Linux installation following [this walk-through](https://www.kali.org/docs/installation/btrfs/).
|
||||
|
||||
#### Manual
|
||||
* Run `make install` or look into Makefile for instructions on where to put each file.
|
||||
* Run `make help` to check what options are available.
|
||||
* Dependencies:
|
||||
* [btrfs-progs](https://archlinux.org/packages/core/x86_64/btrfs-progs/)
|
||||
* [grub](https://archlinux.org/packages/core/x86_64/grub/)
|
||||
* [bash >4](https://archlinux.org/packages/core/x86_64/bash/)
|
||||
* [gawk](https://archlinux.org/packages/core/x86_64/gawk/)
|
||||
* (only when using the daemon)[inotify-tools](https://archlinux.org/packages/community/x86_64/inotify-tools/)
|
||||
|
||||
NOTE: Generate your Grub menu after installation for the changes to take effect.
|
||||
- - -
|
||||
### 📚 Usage
|
||||
After installation the grub main menu needs to be generated to make a menuentry for the snapshots sub menu. Depending on the Linux distribution the commands for that are different:
|
||||
* 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 ...`
|
||||
|
||||
On Arch Linux use `grub-mkconfig -o /boot/grub/grub.cfg`.
|
||||
Once the entry for the sub menu was generated grub-btrfs puts the actual sub menu into the file grub-btrfs.cfg. So to generate snapshot entries in the sub menu it is usually enough to run only the script with `sudo /etc/grub.d/41_snapshots-btrfs`.
|
||||
Read further below on how to automate this process.
|
||||
|
||||
##
|
||||
### Customization:
|
||||
### ⚙️ Customization:
|
||||
|
||||
You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`.
|
||||
You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`.
|
||||
For further information see [config file](https://github.com/Antynea/grub-btrfs/blob/master/config) or `man grub-btrfs`
|
||||
|
||||
* GRUB_BTRFS_SUBMENUNAME="Arch Linux Snapshots"
|
||||
#### Warning:
|
||||
Some file locations and command names differ from distribution to distribution. Initially the configuration is set up to work with Arch and Gentoo (and many other distributions) out of the box, which are using the `grub-mkconfig` command.
|
||||
However, Fedora for example uses a different command, `grub2-mkconfig`.
|
||||
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this. (e.g. `GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig` for Fedora)
|
||||
|
||||
Name appearing in the Grub menu. Use distribution information from /etc/os-release by default.
|
||||
On most distributions and installs, the grub installation resides in `/boot/grub`. If grub is installed in a different place, change the variable `GRUB_BTRFS_MKCONFIG` in the config file accordingly. For Fedora this is `GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"`. Also the command to check the grub scripts is different on some system, for Fedora it is `GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check`
|
||||
|
||||
* GRUB_BTRFS_PREFIXENTRY="Snapshot:"
|
||||
#### Customization of the grub-btrfsd daemon
|
||||
|
||||
Add a name ahead your snapshots entries in the Grub menu.
|
||||
Grub-btrfs comes with a daemon script that automatically updates the grub menu when it sees a snapshot being created or deleted in a directory it is given via command line.
|
||||
|
||||
The daemon can be configured by passing different command line arguments to it.
|
||||
The arguments are:
|
||||
* `SNAPSHOTS_DIR`
|
||||
This argument specifies the path where grub-btrfsd looks for newly created snapshots and snapshot deletions. It is usually defined by the program used to make snapshots.
|
||||
E.g. for Snapper this would be `/.snapshots`
|
||||
* `-c / --no-color`
|
||||
Disable colors in output.
|
||||
* `-l / --log-file`
|
||||
This arguments specifies a file where grub-btrfsd should write log messages.
|
||||
* `-s / --syslog`
|
||||
* `-t / --timeshift-auto`
|
||||
This is a flag to activate the auto detection of the path where Timeshift stores snapshots. Newer versions (>=22.06) of Timeshift mount their snapshots to `/run/timeshift/$PID/backup/timeshift-btrfs`. Where `$PID` is the process ID of the currently running Timeshift session. The PID is changing every time Timeshift is opened. grub-btrfsd can automatically take care of the detection of the correct PID and directory if this flag is set. In this case the argument `SNAPSHOTS_DIR` has no effect.
|
||||
* `-v / --verbose`
|
||||
Let the log of the daemon be more verbose
|
||||
* `-h / --help`
|
||||
Displays a short help message.
|
||||
- - -
|
||||
##### Systemd instructions
|
||||
To edit the arguments that are passed to the daemon, use
|
||||
```bash
|
||||
sudo systemctl edit --full grub-btrfsd
|
||||
```
|
||||
after that the Daemon must be restarted with
|
||||
```bash
|
||||
sudo systemctl restart grub-btrfsd
|
||||
```
|
||||
|
||||
It is also possible to start the daemon without using systemd for troubleshooting purposes for example. If you want to do this, a running daemon should be stopped with
|
||||
```bash
|
||||
sudo systemctl stop grub-btrfsd
|
||||
```
|
||||
Then the daemon can be manually run and played around with using the command `/usr/bin/grub-btrfsd`.
|
||||
For additional information on the daemon script and its arguments, run `grub-btrfsd -h` and see `man grub-btrfsd`
|
||||
- - -
|
||||
##### OpenRC instructions
|
||||
To edit the arguments that are passed to the daemon edit the file `/etc/conf.d/grub-btrfsd`.
|
||||
After that restart the daemon with
|
||||
```
|
||||
sudo rc-service grub-btrfsd restart
|
||||
```
|
||||
|
||||
It is also possible to start the daemon without using OpenRC for troubleshooting purposes for example. If you want to do this, a running daemon should be stopped with
|
||||
```bash
|
||||
sudo rc-service grub-btrfsd stop
|
||||
```
|
||||
Then the daemon can be manually run and played around with using the command `grub-btrfsd`.
|
||||
For additional information on daemon script and its arguments, run `grub-btrfsd -h` and see `man grub-btrfsd`
|
||||
|
||||
- - -
|
||||
### 🪀 Automatically update grub upon snapshot
|
||||
Grub-btrfsd is a daemon daemon that watches the snapshot directory for you and updates the grub menu automatically every time a snapshot is created or deleted.
|
||||
By default this daemon watches the directory `/.snapshots` for changes (creation or deletion of snapshots) and triggers the grub menu creation if a snapshot is found.
|
||||
Therefore, if Snapper is used with its default directory, the daemon can just be started and nothing needs to be configured. For other configurations like Timeshift, or Snapper with a different directory, see further below.
|
||||
- - -
|
||||
#### SystemD instructions
|
||||
To start the daemon run
|
||||
```bash
|
||||
sudo systemctl start grub-btrfsd
|
||||
```
|
||||
|
||||
To activate it during system startup, run
|
||||
```bash
|
||||
sudo systemctl enable grub-btrfsd
|
||||
```
|
||||
|
||||
##### 💼 Snapshots not in `/.snapshots`
|
||||
NOTE: This works also for Timeshift versions < 22.06, the path to watch would be `/run/timeshift/backup/timeshift-btrfs/snapshots`.
|
||||
|
||||
By default the daemon is watching the directory `/.snapshots`. If the daemon should watch a different directory, it can be edited with
|
||||
```bash
|
||||
sudo systemctl edit --full grub-btrfsd
|
||||
```
|
||||
What should be edited is the `/.snapshots`-part in the line that says `ExecStart=/usr/bin/grub-btrfsd --syslog /.snapshots`.
|
||||
So this is what the file should look afterwards:
|
||||
``` bash
|
||||
[Unit]
|
||||
Description=Regenerate grub-btrfs.cfg
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
LogLevelMax=notice
|
||||
# Set the possible paths for `grub-mkconfig`
|
||||
Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
# Load environment variables from the configuration
|
||||
EnvironmentFile=/etc/default/grub-btrfs/config
|
||||
# Start the daemon, usage of it is:
|
||||
# grub-btrfsd [-h, --help] [-t, --timeshift-auto] [-l, --log-file LOG_FILE] SNAPSHOTS_DIR
|
||||
# SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto
|
||||
# Optional arguments:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
ExecStart=/usr/bin/grub-btrfsd --syslog /path/to/your/snapshot/directory
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
When done, the service should be restarted with
|
||||
``` bash
|
||||
sudo systemctl restart grub-btrfsd
|
||||
```
|
||||
|
||||
##### 🌟 Timeshift >= version 22.06
|
||||
Newer Timeshift versions create a new directory named after their process ID in `/run/timeshift` every time they are started. The PID is going to be different every time.
|
||||
Therefore the daemon can not simply watch a directory, it watches `/run/timeshift` first, if a directory is created it gets Timeshifts current PID, then watches a directory in that newly created directory from Timeshift.
|
||||
Anyhow, to activate this mode of the daemon, `--timeshift-auto` must be passed to the daemon as a command line argument.
|
||||
|
||||
To pass `--timeshift-auto` to grub-btrfsd, the .service-file of grub-btrfsd can be edited with
|
||||
```bash
|
||||
sudo systemctl edit --full grub-btrfsd
|
||||
```
|
||||
|
||||
The line that says
|
||||
```bash
|
||||
ExecStart=/usr/bin/grub-btrfsd /.snapshots --syslog
|
||||
|
||||
```
|
||||
|
||||
should be edited into
|
||||
``` bash
|
||||
ExecStart=/usr/bin/grub-btrfsd --syslog --timeshift-auto
|
||||
```
|
||||
|
||||
So the file looks like this, afterwards:
|
||||
``` bash
|
||||
[Unit]
|
||||
Description=Regenerate grub-btrfs.cfg
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
LogLevelMax=notice
|
||||
# Set the possible paths for `grub-mkconfig`
|
||||
Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
# Load environment variables from the configuration
|
||||
EnvironmentFile=/etc/default/grub-btrfs/config
|
||||
# Start the daemon, usage of it is:
|
||||
# grub-btrfsd [-h, --help] [-t, --timeshift-auto] [-l, --log-file LOG_FILE] SNAPSHOTS_DIR
|
||||
# SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto
|
||||
# Optional arguments:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
ExecStart=/usr/bin/grub-btrfsd --syslog --timeshift-auto
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
When done, the service must be restarted with
|
||||
``` bash
|
||||
sudo systemctl restart grub-btrfsd
|
||||
```
|
||||
|
||||
Note:
|
||||
You can view your change with `systemctl cat grub-btrfsd`.
|
||||
To revert all the changes use `systemctl revert grub-btrfsd`.
|
||||
|
||||
##### ❇️ Automatically update grub upon restart/boot:
|
||||
[Look at this comment](https://github.com/Antynea/grub-btrfs/issues/138#issuecomment-766918328)
|
||||
Currently not implemented
|
||||
- - -
|
||||
#### OpenRC instructions
|
||||
To start the daemon run
|
||||
```bash
|
||||
sudo rc-service grub-btrfsd start
|
||||
```
|
||||
|
||||
To activate it during system startup, run
|
||||
```bash
|
||||
sudo rc-config add grub-btrfsd default
|
||||
```
|
||||
|
||||
##### 💼 Snapshots not in `/.snapshots`
|
||||
NOTE: This works also for Timeshift versions < 22.06, the path to watch would be `/run/timeshift/backup/timeshift-btrfs/snapshots`.
|
||||
|
||||
By default the daemon is watching the directory `/.snapshots`. If the daemon should watch a different directory, it can be edited by passing different arguments to it.
|
||||
Arguments are passed to grub-btrfsd via the file `/etc/conf.d/grub-btrfsd`.
|
||||
The variable `snapshots` defines, where the daemon will watch for snapshots.
|
||||
|
||||
After editing, the file should look like this:
|
||||
``` bash
|
||||
# Copyright 2022 Pascal Jaeger
|
||||
# Distributed under the terms of the GNU General Public License v3
|
||||
|
||||
## Where to locate the root snapshots
|
||||
#snapshots="/.snapshots" # Snapper in the root directory
|
||||
#snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
|
||||
snapshots="/path/to/your/snapshot/directory"
|
||||
|
||||
## Optional arguments to run with the daemon
|
||||
# Possible options are:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
# Uncomment the line to activate the option
|
||||
optional_args+="--syslog " # write to syslog by default
|
||||
#optional_args+="--timeshift-auto "
|
||||
#optional_args+="--log-file /var/log/grub-btrfsd.log "
|
||||
#optional_args+="--verbose "
|
||||
```
|
||||
|
||||
After that, the daemon should be restarted with
|
||||
``` bash
|
||||
sudo rc-service grub-btrfsd restart
|
||||
```
|
||||
|
||||
##### 🌟 Timeshift >= version 22.06
|
||||
Arguments are passed to grub-btrfsd via the file `/etc/conf.d/grub-btrfsd`.
|
||||
The variable `optional_args` defines, which optional arguments get passed to the daemon.
|
||||
Uncomment `#optional_args+="--timeshift-auto "` to pass the command line option `--timeshift-auto` to it.
|
||||
|
||||
After the change, the file should look like this:
|
||||
(Note that there is no need to comment out the `snapshots` variable. It is ignored when `--timeshift-auto` is active.)
|
||||
``` bash
|
||||
# Copyright 2022 Pascal Jaeger
|
||||
# Distributed under the terms of the GNU General Public License v3
|
||||
|
||||
## Where to locate the root snapshots
|
||||
snapshots="/.snapshots" # Snapper in the root directory
|
||||
#snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
|
||||
|
||||
## Optional arguments to run with the daemon
|
||||
# Possible options are:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
# Uncomment the line to activate the option
|
||||
optional_args+="--syslog " # write to syslog by default
|
||||
optional_args+="--timeshift-auto "
|
||||
#optional_args+="--log-file /var/log/grub-btrfsd.log "
|
||||
#optional_args+="--verbose "
|
||||
```
|
||||
|
||||
After that, the daemon should be restarted with
|
||||
``` bash
|
||||
sudo rc-service grub-btrfsd restart
|
||||
```
|
||||
|
||||
##### ❇️ 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
|
||||
}
|
||||
|
||||
* GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="true"
|
||||
|
||||
Show full path snapshot or only name in the Grub menu, weird reaction with snapper.
|
||||
|
||||
* GRUB_BTRFS_TITLE_FORMAT="p/d/n"
|
||||
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'
|
||||
```
|
||||
|
||||
Custom title, shows/hides p"prefix" d"date" n"name" in the Grub menu, separator "/", custom order available.
|
||||
Make your script executable with `sudo chmod a+x /etc/local.d/grub-btrfs-update.stop`.
|
||||
|
||||
* GRUB_BTRFS_LIMIT="50"
|
||||
* The extension `.stop` at the end of the filename indicates to the locald-daemon that this script should be run at shutdown.
|
||||
If you want to run the menu update on system startup instead, rename the file to `grub-btrfs-update.start`
|
||||
* Works for Snapper and Timeshift
|
||||
- - -
|
||||
### Troubleshooting
|
||||
If there are problems don't hesitate [to file an issue](https://github.com/Antynea/grub-btrfs/issues/new/choose).
|
||||
|
||||
Limit the number of snapshots populated in the GRUB menu.
|
||||
#### Version
|
||||
To help the best we would like to know the version of grub-btrfs used. Please run
|
||||
``` bash
|
||||
sudo /etc/grub.d/41_snapshots-btrfs --version
|
||||
```
|
||||
or
|
||||
``` bash
|
||||
sudo /usr/bin/grub-btrfsd --help
|
||||
```
|
||||
to get the currently running version of grub-btrfs.
|
||||
|
||||
* GRUB_BTRFS_SUBVOLUME_SORT="descending"
|
||||
#### Verbose mode of the daemon
|
||||
If you have problems with the daemon, you can run it with the `--verbose`-flag. To do so you can run
|
||||
``` bash
|
||||
sudo /usr/bin/grub-btrfsd --verbose --timeshift-auto` (for timeshift)
|
||||
# or
|
||||
sudo /usr/bin/grub-btrfsd /.snapshots --verbose` (for snapper)
|
||||
```
|
||||
Or pass `--verbose` to the daemon using the Systemd .service-file or the OpenRC conf.d file respectively. (see Daemon installation instructions how to do that)
|
||||
|
||||
Sort the found subvolumes by newest first ("descending") or oldest first ("ascending").
|
||||
|
||||
If "ascending" is chosen then
|
||||
|
||||
the $GRUB_BTRFS_LIMIT oldest subvolumes will populate the menu.
|
||||
|
||||
* GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="true"
|
||||
|
||||
Show snapshots found during run "grub-mkconfig".
|
||||
|
||||
* GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND="true"
|
||||
|
||||
Show Total number of snapshots found during run "grub-mkconfig".
|
||||
|
||||
* GRUB_BTRFS_NKERNEL=("kernel-custom")
|
||||
|
||||
Use it only if you have a custom kernel name
|
||||
|
||||
* GRUB_BTRFS_NINIT=("initramfs-custom.img" "initrd.img-custom")
|
||||
|
||||
Use it only if you have a custom initramfs name.
|
||||
|
||||
* GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img")
|
||||
|
||||
Use it only if you have custom intel-ucode.
|
||||
|
||||
* GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker")
|
||||
|
||||
Ignore specific path during run "grub-mkconfig".
|
||||
|
||||
For example:
|
||||
|
||||
If path is a directory `# Found Snapshot: 2016-03-31 10:24:41` **var/lib/docker/btrfs/subvolumes/...**
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker")`
|
||||
|
||||
If path is a subvolume : `# Found Snapshot: 2016-03-31 10:24:41` **@var/lib/docker/btrfs/subvolumes/...**
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker")`
|
||||
|
||||
You can combine them
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker" "var/lib/docker")`
|
||||
|
||||
|
||||
* GRUB_BTRFS_SNAPPER_CONFIG="root"
|
||||
|
||||
Snapper's config name to use.
|
||||
|
||||
* GRUB_BTRFS_DISABLE="false"
|
||||
|
||||
Disable grub-btrfs.
|
||||
|
||||
* GRUB_BTRFS_DIRNAME="grub"
|
||||
|
||||
Name of the grub folder in `/boot/`, might be grub2 on some distributions.
|
||||
|
||||
* GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="false"
|
||||
|
||||
Change to "true" if you have a boot partition in a different subvolume.
|
||||
|
||||
* GRUB_BTRFS_MKCONFIG=grub-mkconfig
|
||||
|
||||
Name or path of the 'grub-mkconfig' executable; might be 'grub2-mkconfig' on some distributions.
|
||||
|
||||
- Password protection management for submenu (refer to the [Grub documentation](https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation))
|
||||
|
||||
- GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS=""
|
||||
|
||||
Add authorized usernames separate by comma (foo,bar)
|
||||
|
||||
When Grub's password protection is enabled, the superuser is authorized by default, it isn't necessary to add it
|
||||
|
||||
- GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="false"
|
||||
|
||||
Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
|
||||
doesn't work if `GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS` isn't empty
|
||||
|
||||
##
|
||||
### Automatically update grub
|
||||
If you would like Grub to automatically update when a snapshot is made or deleted:
|
||||
* Mount your subvolume which contains snapshots to `/.snapshots`
|
||||
* Use `systemctl start/enable grub-btrfs.path`
|
||||
* `grub-btrfs.path` automatically (re)generates `grub.cfg` when a modification appears in `/.snapshots`
|
||||
##
|
||||
- - -
|
||||
### Special thanks for assistance and contributions
|
||||
* [maximbaz](https://github.com/maximbaz)
|
||||
* [crossroads1112](https://github.com/crossroads1112)
|
||||
* [penetal](https://github.com/penetal)
|
||||
* [wesbarnett](https://github.com/wesbarnett)
|
||||
* [Psykar](https://github.com/Psykar)
|
||||
* [anyc](https://github.com/anyc)
|
||||
* [daftaupe](https://github.com/daftaupe)
|
||||
* [N-Parsons](https://github.com/N-Parsons)
|
||||
##
|
||||
* [Maxim Baz](https://github.com/maximbaz)
|
||||
* [Schievel1](https://github.com/Antynea/grub-btrfs/discussions/173#discussioncomment-1438790)
|
||||
* [All contributors](https://github.com/Antynea/grub-btrfs/graphs/contributors)
|
||||
- - -
|
||||
|
||||
155
config
155
config
@@ -1,87 +1,134 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Name appearing in the Grub menu
|
||||
# Default: Use distribution information from /etc/os-release
|
||||
GRUB_BTRFS_VERSION=4.12-fix-snap-dir-check-2022-11-26T14:06:44+00:00
|
||||
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE="true"
|
||||
|
||||
# Name appearing in the Grub menu.
|
||||
# Default: "Use distribution information from /etc/os-release."
|
||||
#GRUB_BTRFS_SUBMENUNAME="Arch Linux snapshots"
|
||||
|
||||
# Add a name ahead your snapshots entries in the Grub menu
|
||||
# Default: "Snapshot:"
|
||||
#GRUB_BTRFS_PREFIXENTRY="Snapshot:"
|
||||
# Custom title.
|
||||
# Shows/Hides "date" "snapshot" "type" "description" in the Grub menu, custom order available.
|
||||
# Default: ("date" "snapshot" "type" "description")
|
||||
#GRUB_BTRFS_TITLE_FORMAT=("date" "snapshot" "type" "description")
|
||||
|
||||
# Show full path snapshot or only name in the Grub menu
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="true"
|
||||
|
||||
# Custom title
|
||||
# shows/hides p"prefix" d"date" n"name" in the Grub menu, separator "/", custom order available
|
||||
# Default: "p/d/n"
|
||||
#GRUB_BTRFS_TITLE_FORMAT="p/d/n"
|
||||
|
||||
# Limit the number of snapshots populated in the GRUB menu
|
||||
# Limit the number of snapshots populated in the GRUB menu.
|
||||
# Default: "50"
|
||||
#GRUB_BTRFS_LIMIT="50"
|
||||
|
||||
# Sort the found subvolumes by newest first ("descending") or oldest first ("ascending") and show $GRUB_BTRFS_LIMIT first entries.
|
||||
# Default: "descending"
|
||||
#GRUB_BTRFS_SUBVOLUME_SORT="descending"
|
||||
# Sort the found subvolumes by "ogeneration" or "generation" or "path" or "rootid".
|
||||
# # See Sorting section to https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-subvolume#SUBCOMMAND
|
||||
# "-rootid" means list snapshot by new ones first.
|
||||
# Default: "-rootid"
|
||||
#GRUB_BTRFS_SUBVOLUME_SORT="+ogen,-gen,path,rootid"
|
||||
|
||||
# Show snapshots found during run "grub-mkconfig"
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="true"
|
||||
#GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"
|
||||
|
||||
# Show Total of snapshots found during run "grub-mkconfig"
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND="true"
|
||||
|
||||
# Use only if you have custom kernel name
|
||||
# Default:
|
||||
#GRUB_BTRFS_NKERNEL=("vmlinuz-linux")
|
||||
# By default, "grub-btrfs" automatically detects most existing kernels.
|
||||
# If you have one or more custom kernels, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_NKERNEL=("kernel-custom" "vmlinux-custom")
|
||||
|
||||
# Use only if you have custom initramfs name
|
||||
# Default:
|
||||
#GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img")
|
||||
# By default, "grub-btrfs" automatically detects most existing initramfs.
|
||||
# If you have one or more custom initramfs, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_NINIT=("initramfs-custom.img" "initrd-custom.img" "otherinit-custom.gz")
|
||||
|
||||
# Use only if you have custom intel-ucode
|
||||
# Default:
|
||||
#GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img")
|
||||
# By default, "grub-btrfs" automatically detects most existing microcodes.
|
||||
# If you have one or more custom microcodes, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_CUSTOM_MICROCODE=("custom-ucode.img" "custom-uc.img "custom_ucode.cpio")
|
||||
|
||||
# Comma seperated mount options to be used when booting a snapshot.
|
||||
# They can be defined here as well as in the "/" line inside the respective snapshots'
|
||||
# "/etc/fstab" files. Mount options found in both places are combined, and this variable
|
||||
# takes priority over `fstab` entries.
|
||||
# NB: Do NOT include "subvol=..." or "subvolid=..." here.
|
||||
# Default: ""
|
||||
#GRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"
|
||||
|
||||
# Ignore specific path during run "grub-mkconfig".
|
||||
# If path is a directory, # Found Snapshot: 2016-03-31 10:24:41 var/lib/docker/btrfs/subvolumes/...
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker");
|
||||
# If path is a subvolume, # Found Snapshot: 2016-03-31 10:24:41 @var/lib/docker/btrfs/subvolumes/...
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker");
|
||||
# You can combine them
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker" "var/lib/docker")
|
||||
# Default:
|
||||
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "@var/lib/docker")
|
||||
# Only exact paths are ignored.
|
||||
# e.g : if `specific path` = @, only `@` snapshot will be ignored.
|
||||
# Default: ("@")
|
||||
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@")
|
||||
|
||||
# Snapper's config name to use
|
||||
# Default: "root"
|
||||
#GRUB_BTRFS_SNAPPER_CONFIG="root"
|
||||
# Ignore prefix path during run "grub-mkconfig".
|
||||
# Any path starting with the specified string will be ignored.
|
||||
# e.g : if `prefix path` = @, all snapshots beginning with "@/..." will be ignored.
|
||||
# Default: ("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
|
||||
GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
|
||||
|
||||
# Disable Grub-btrfs
|
||||
# Ignore specific type/tag of snapshot during run "grub-mkconfig".
|
||||
# For snapper:
|
||||
# Type = single, pre, post.
|
||||
# For Timeshift:
|
||||
# Tag = boot, ondemand, hourly, daily, weekly, monthly.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("")
|
||||
|
||||
# Ignore specific description of snapshot during run "grub-mkconfig".
|
||||
# e.g: timeline
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION=("")
|
||||
|
||||
# By default "grub-btrfs" automatically detects your boot partition,
|
||||
# either located at the system root or on a separate partition or in a subvolume,
|
||||
# Change to "true" if your boot partition isn't detected as separate.
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE="false"
|
||||
#GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="true"
|
||||
|
||||
# Change to "true" if you have a boot partition in a different subvolume
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="false"
|
||||
# Location of the folder containing the "grub.cfg" file.
|
||||
# Use by grub-btrfs to save the file "grub-btrfs.cfg".
|
||||
# Might be grub2 on some systems.
|
||||
# For example, on Fedora with EFI : "/boot/efi/EFI/fedora"
|
||||
# Default: "/boot/grub"
|
||||
#GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"
|
||||
|
||||
# Might be grub2 on some systems ex. /boot/grub2/...
|
||||
# Default: "grub"
|
||||
#GRUB_BTRFS_DIRNAME="grub"
|
||||
# Location of kernels/initramfs/microcode.
|
||||
# Use by "grub-btrfs" to detect the boot partition and the location of kernels/initrafms/microcodes.
|
||||
# Default: "/boot"
|
||||
#GRUB_BTRFS_BOOT_DIRNAME="/boot"
|
||||
|
||||
# Might be 'grub2-mkconfig' on some systems
|
||||
# Default: /usr/bin/grub-mkconfig
|
||||
# Name/path of grub-mkconfig command, use by "grub-btrfs.service"
|
||||
# Might be 'grub2-mkconfig' on some systems (Fedora ...)
|
||||
# Default paths are /sbin:/bin:/usr/sbin:/usr/bin,
|
||||
# if your path is missing, report it on the upstream project.
|
||||
# For example, on Fedora : "/sbin/grub2-mkconfig"
|
||||
# You can use only name or full path.
|
||||
# Default: grub-mkconfig
|
||||
#GRUB_BTRFS_MKCONFIG=/usr/bin/grub2-mkconfig
|
||||
|
||||
## Password protection management for submenu,snapshots
|
||||
# Name of grub-script-check command, use by "grub-btrfs"
|
||||
# Might be 'grub2-script-check' on some systems (Fedora ...)
|
||||
# For example, on Fedora : "grub2-script-check"
|
||||
# Default: grub-script-check
|
||||
#GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check
|
||||
|
||||
# Path of grub-mkconfig_lib file, use by "grub-btrfs"
|
||||
# Might be '/usr/share/grub2/grub-mkconfig_lib' on some systems (Opensuse ...)
|
||||
# Default: /usr/share/grub/grub-mkconfig_lib
|
||||
#GRUB_BTRFS_MKCONFIG_LIB=/usr/share/grub2/grub-mkconfig_lib
|
||||
|
||||
# Password protection management for submenu,snapshots
|
||||
# Refer to the Grub documentation https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation
|
||||
# and this comment https://github.com/Antynea/grub-btrfs/issues/95#issuecomment-682295660
|
||||
#
|
||||
# Add authorized usernames separate by comma (foo,bar)
|
||||
# When Grub's password protection is enabled, the superuser is authorized by default, it isn't necessary to add it
|
||||
# Default:
|
||||
# GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS=""
|
||||
# Default: ""
|
||||
#GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS="foo,bar"
|
||||
#
|
||||
# Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
# doesn't work if GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS isn't empty
|
||||
# Default: false
|
||||
# GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="false"
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="true"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
[Unit]
|
||||
Description=Monitors for new snapshots
|
||||
|
||||
[Path]
|
||||
PathModified=/.snapshots
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=Regenerate grub-btrfs.cfg
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# Set the possible paths for `grub-mkconfig`
|
||||
Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
# Load environment variables from the configuration
|
||||
EnvironmentFile=/etc/default/grub-btrfs/config
|
||||
# Regenerate just '/boot/grub/grub-btrfs.cfg' if it exists and is not empty, else regenerate the whole grub menu
|
||||
ExecStart=/bin/bash -c 'if [ -s "/boot/${GRUB_BTRFS_DIRNAME:-grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-/usr/bin/grub-mkconfig} -o /boot/${GRUB_BTRFS_DIRNAME:-grub}/grub.cfg; fi'
|
||||
281
grub-btrfsd
Executable file
281
grub-btrfsd
Executable file
@@ -0,0 +1,281 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2022 Pascal Jaeger
|
||||
# Distributed under the terms of the GNU General Public License v3
|
||||
# Update GRUB when new BTRFS snapshots are created.
|
||||
|
||||
# init
|
||||
timeshift_pid=-1
|
||||
watchtime=0
|
||||
logfile=0
|
||||
snapshots=-1
|
||||
timeshift_auto=false
|
||||
timeshift_old=false
|
||||
verbose=false
|
||||
syslog=false
|
||||
|
||||
setcolors() {
|
||||
if [ "${1}" = true ]; then
|
||||
GREEN=$'\033[0;32m'
|
||||
RED=$'\033[0;31m'
|
||||
CYAN=$'\033[;36m'
|
||||
RESET=$'\033[0m'
|
||||
fi
|
||||
if [ "${1}" = false ]; then
|
||||
GREEN=$'\033[0;0m'
|
||||
RED=$'\033[0;0m'
|
||||
CYAN=$'\033[;0m'
|
||||
RESET=$'\033[0m'
|
||||
fi
|
||||
}
|
||||
setcolors true # normally we want colors
|
||||
|
||||
sysconfdir="/etc"
|
||||
grub_btrfs_config="${sysconfdir}/default/grub-btrfs/config"
|
||||
# source config file
|
||||
[ -f "$grub_btrfs_config" ] && . "$grub_btrfs_config"
|
||||
[ -f "${sysconfdir}/default/grub" ] && . "${sysconfdir}/default/grub"
|
||||
|
||||
print_help() {
|
||||
echo "${CYAN}[?] Usage:"
|
||||
echo "${0##*/} [-h, --help] [-c, --no-color] [-l, --log-file LOG_FILE] [-s, --syslog] [-t, --timeshift-auto] [-v, --verbose] SNAPSHOTS_DIR"
|
||||
echo
|
||||
echo "SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto"
|
||||
echo
|
||||
echo "Optional arguments:"
|
||||
echo "-c, --no-color Disable colors in output"
|
||||
echo "-l, --log-file Specify a logfile to write to"
|
||||
echo "-s, --syslog Write to syslog"
|
||||
echo "-o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (requires --timeshift-auto)"
|
||||
echo "-t, --timeshift-auto Automatically detect Timeshifts snapshot directory"
|
||||
echo "-v, --verbose Let the log of the daemon be more verbose"
|
||||
echo "-h, --help Display this message"
|
||||
echo
|
||||
echo "Version ${GRUB_BTRFS_VERSION}${RESET}"
|
||||
}
|
||||
|
||||
log() {
|
||||
echo "${2}"$1"${RESET}"
|
||||
if [ ${syslog} = true ]; then
|
||||
logger -p user.notice -t ${0##*/}"["$$"]" "$1"
|
||||
fi
|
||||
if [ ${#logfile} -gt 1 ]; then
|
||||
echo "$(date) ${1}" >> ${logfile}
|
||||
fi
|
||||
}
|
||||
|
||||
vlog() {
|
||||
if [ ${verbose} = true ]; then
|
||||
echo "${2}"$1"${RESET}"
|
||||
if [ ${syslog} = true ]; then
|
||||
logger -p user.notice -t ${0##*/} "$1"
|
||||
fi
|
||||
if [ ${#logfile} -gt 1 ]; then
|
||||
echo "$(date) ${1}" >> ${logfile}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
err() {
|
||||
echo "${2}"${1}"${RESET}" >&2
|
||||
if [ ${syslog} = true ]; then
|
||||
logger -p user.error -t ${0##*/} "$1"
|
||||
fi
|
||||
if [ ${#logfile} -gt 1 ]; then
|
||||
echo "$(date) error: ${1}" >> ${logfile}
|
||||
fi
|
||||
}
|
||||
|
||||
# parse arguments
|
||||
while getopts :l:ctvsh-: opt; do
|
||||
case "$opt" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
no-color)
|
||||
setcolors false
|
||||
;;
|
||||
log-file)
|
||||
logfile="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
|
||||
;;
|
||||
timeshift-auto)
|
||||
timeshift_auto=true
|
||||
;;
|
||||
timeshift-old)
|
||||
timeshift_old=true
|
||||
;;
|
||||
verbose)
|
||||
verbose=true
|
||||
;;
|
||||
syslog)
|
||||
syslog=true
|
||||
;;
|
||||
help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
|
||||
err "[!] Unknown option --${OPTARG}" "${RED}" >&2
|
||||
echo
|
||||
fi
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
esac;;
|
||||
c)
|
||||
setcolors false
|
||||
;;
|
||||
l)
|
||||
logfile="${OPTARG}"
|
||||
;;
|
||||
t)
|
||||
timeshift_auto=true
|
||||
;;
|
||||
o)
|
||||
timeshift_old=true
|
||||
;;
|
||||
v)
|
||||
verbose=true
|
||||
;;
|
||||
s)
|
||||
syslog=true
|
||||
;;
|
||||
h)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
if [ "$OPTERR" = 1 ] || [ "${optspec:0:1}" = ":" ]; then
|
||||
err "[!] Non-option argument: '-${OPTARG}'" "${RED}" >&2
|
||||
echo
|
||||
fi
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
snapshots="${1}"
|
||||
|
||||
# check if inotify exists, see issue #227
|
||||
if ! command -v inotifywait &> /dev/null; then
|
||||
err "[!] inotifywait was not found, exiting. Is inotify-tools installed?" "${RED}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#logfile} -gt 1 ]; then
|
||||
touch "${logfile}"
|
||||
echo "GRUB-BTRFSD log $(date)" >> "${logfile}"
|
||||
fi
|
||||
|
||||
log "grub-btrfsd starting up..." "${GREEN}"
|
||||
|
||||
if [ ${verbose} = true ]; then
|
||||
inotify_qiet_flag=""
|
||||
else
|
||||
inotify_qiet_flag=" -q -q "
|
||||
fi
|
||||
|
||||
if [ ${timeshift_auto} = false ] && [ ${timeshift_old} = true ]; then
|
||||
err "[!] Flag --timeshift-old requires flag --timeshift-auto" "${RED}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vlog "Arguments:"
|
||||
vlog "Snapshot directory: $snapshots"
|
||||
vlog "Timestift autodetection: $timeshift_auto"
|
||||
vlog "Timeshift old: $timeshift_old"
|
||||
vlog "Logfile: $logfile"
|
||||
|
||||
if ! [ -d "$snapshots" ] && ! [ ${timeshift_auto} = true ]; then
|
||||
err "[!] No directory found at ${snapshots}" "${RED}" >&2
|
||||
err "[!] Please specify a valid snapshot directory" "${RED}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${timeshift_auto} = true ]; then
|
||||
watchtime=15
|
||||
[ -d /run/timeshift ] || mkdir /run/timeshift
|
||||
else
|
||||
watchtime=0
|
||||
fi
|
||||
|
||||
create_grub_menu() {
|
||||
# create the grub submenu of the whole grub menu, depending on wether the submenu already exists
|
||||
# and gives feedback if it worked
|
||||
if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then
|
||||
if /etc/grub.d/41_snapshots-btrfs; then
|
||||
log "Grub submenu recreated" "${GREEN}"
|
||||
else
|
||||
err "[!] Error during grub submenu creation (grub-btrfs error)" "${RED}"
|
||||
fi
|
||||
else
|
||||
if ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; then
|
||||
log "Grub menu recreated" "${GREEN}"
|
||||
else
|
||||
err "[!] Error during grub menu creation (grub/ grub-btrfs error)" "${RED}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
set_snapshot_dir() {
|
||||
# old timeshift has it's snapshot dir in a different location
|
||||
if [ "${timeshift_old}" = true ]; then
|
||||
snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots"
|
||||
else
|
||||
snapshots="/run/timeshift/${timeshift_pid}/backup/timeshift-btrfs/snapshots"
|
||||
fi
|
||||
}
|
||||
|
||||
# start the actual daemon
|
||||
vlog "Snapshot dir watchtimeout: $watchtime"
|
||||
vlog "Entering infinite while" "${GREEN}"
|
||||
while true; do
|
||||
runs=false
|
||||
if [ ${timeshift_auto} = true ] && ! [ "${timeshift_pid}" -gt 0 ] ; then
|
||||
# watch the timeshift folder for a folder that is created when timeshift starts up
|
||||
sleep 1 # for safety so the outer while is not going crazy
|
||||
if [ "${timeshift_pid}" -eq -2 ]; then
|
||||
log "detected timeshift shutdown"
|
||||
fi
|
||||
timeshift_pid=$(ps ax | awk '{sub(/.*\//, "", $5)} $5 ~ /timeshift/ {print $1}')
|
||||
if [ "${#timeshift_pid}" -gt 0 ]; then
|
||||
set_snapshot_dir
|
||||
log "detected running Timeshift at daemon startup, PID is: $timeshift_pid"
|
||||
vlog "new snapshots directory is $snapshots"
|
||||
else
|
||||
log "Watching /run/timeshift for timeshift to start"
|
||||
inotifywait ${inotify_qiet_flag} -e create -e delete /run/timeshift && {
|
||||
sleep 1
|
||||
timeshift_pid=$(ps ax | awk '{sub(/.*\//, "", $5)} $5 ~ /timeshift/ {print $1}')
|
||||
set_snapshot_dir
|
||||
log "detected Timeshift startup, PID is: $timeshift_pid" "${CYAN}"
|
||||
vlog "new snapshots directory is $snapshots" "${CYAN}"
|
||||
(create_grub_menu) # create the grub menu once immidiatly in a forking process. Snapshots from commandline using timeshift --create need this
|
||||
}
|
||||
fi
|
||||
runs=false
|
||||
else
|
||||
while [ -d "$snapshots" ]; do
|
||||
# watch the actual snapshots folder for a new snapshot or a deletion of a snapshot
|
||||
if [ ${runs} = false ] && [ ${verbose} = false ]; then
|
||||
log "Watching $snapshots for new snapshots..." "${CYAN}"
|
||||
else
|
||||
vlog "Watching $snapshots for new snapshots..." "${CYAN}"
|
||||
fi
|
||||
runs=true
|
||||
inotifywait ${inotify_qiet_flag} -e create -e delete -e unmount -t "$watchtime" "$snapshots" && {
|
||||
log "Detected snapshot creation/ deletion, recreating Grub menu" "${CYAN}"
|
||||
sleep 5
|
||||
create_grub_menu
|
||||
}
|
||||
sleep 1
|
||||
done
|
||||
timeshift_pid=-2
|
||||
fi
|
||||
if ! [ ${timeshift_auto} = true ] && ! [ -d "${snapshots}" ] ; then # in case someone deletes the snapshots folder (in snapper mode) to prevent the while loop from going wild
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0 # tradition is tradition
|
||||
18
grub-btrfsd.confd
Normal file
18
grub-btrfsd.confd
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright 2022 Pascal Jaeger
|
||||
# Distributed under the terms of the GNU General Public License v3
|
||||
|
||||
## Where to locate the root snapshots
|
||||
snapshots="/.snapshots" # Snapper in the root directory
|
||||
#snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
|
||||
|
||||
## Optional arguments to run with the daemon
|
||||
# Possible options are:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
# Uncomment the line to activate the option
|
||||
optional_args+="--syslog " # write to syslog by default
|
||||
#optional_args+="--timeshift-auto "
|
||||
#optional_args+="--log-file /var/log/grub-btrfsd.log "
|
||||
#optional_args+="--verbose "
|
||||
13
grub-btrfsd.initd
Executable file
13
grub-btrfsd.initd
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/sbin/openrc-run
|
||||
# Copyright 2021 Pascal Jaeger
|
||||
# Distributed under the terms of the GNU General Public License v3
|
||||
|
||||
name="grub-btrfs daemon"
|
||||
command="/usr/bin/grub-btrfsd"
|
||||
command_args="$optional_args ${snapshots}"
|
||||
pidfile="/run/{RC_SVCNAME}.pid"
|
||||
command_background=true
|
||||
|
||||
depend() {
|
||||
use localmount
|
||||
}
|
||||
22
grub-btrfsd.service
Normal file
22
grub-btrfsd.service
Normal file
@@ -0,0 +1,22 @@
|
||||
[Unit]
|
||||
Description=Regenerate grub-btrfs.cfg
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
LogLevelMax=notice
|
||||
# Set the possible paths for `grub-mkconfig`
|
||||
Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
# Load environment variables from the configuration
|
||||
EnvironmentFile=/etc/default/grub-btrfs/config
|
||||
# Start the daemon, usage of it is:
|
||||
# grub-btrfsd [-h, --help] [-t, --timeshift-auto] [-l, --log-file LOG_FILE] SNAPSHOTS_DIR
|
||||
# SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto
|
||||
# Optional arguments:
|
||||
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory
|
||||
# -l, --log-file Specify a logfile to write to
|
||||
# -v, --verbose Let the log of the daemon be more verbose
|
||||
# -s, --syslog Write to syslog
|
||||
ExecStart=/usr/bin/grub-btrfsd --syslog /.snapshots
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
15
initramfs/Arch Linux/overlay_snap_ro-hook
Normal file
15
initramfs/Arch Linux/overlay_snap_ro-hook
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ash
|
||||
|
||||
run_latehook() {
|
||||
local root_mnt="/new_root"
|
||||
local current_dev=$(resolve_device "$root"); # resolve devices for blkid
|
||||
if [[ $(blkid "${current_dev}" -s TYPE -o value) = "btrfs" ]] && [[ $(btrfs property get ${root_mnt} ro) != "ro=false" ]]; then # run only on a read only snapshot
|
||||
local lower_dir=$(mktemp -d -p /)
|
||||
local ram_dir=$(mktemp -d -p /)
|
||||
mount --move ${root_mnt} ${lower_dir} # move new_root to lower_dir
|
||||
mount -t tmpfs cowspace ${ram_dir} #meuh!!! space, you can't test !
|
||||
mkdir -p ${ram_dir}/upper
|
||||
mkdir -p ${ram_dir}/work
|
||||
mount -t overlay -o lowerdir=${lower_dir},upperdir=${ram_dir}/upper,workdir=${ram_dir}/work rootfs ${root_mnt}
|
||||
fi
|
||||
}
|
||||
18
initramfs/Arch Linux/overlay_snap_ro-install
Normal file
18
initramfs/Arch Linux/overlay_snap_ro-install
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
add_module btrfs
|
||||
add_module overlay
|
||||
add_binary btrfs
|
||||
add_binary btrfsck
|
||||
add_binary blkid
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook uses overlayfs to boot on a read only snapshot.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
45
initramfs/readme.md
Normal file
45
initramfs/readme.md
Normal file
@@ -0,0 +1,45 @@
|
||||
### Description :
|
||||
|
||||
Booting on a snapshot in read-only mode can be tricky.
|
||||
An elegant way is to boot this snapshot using overlayfs (included in the kernel ≥ 3.18).
|
||||
|
||||
Using overlayfs, the booted snapshot will behave like a live-cd in non-persistent mode.
|
||||
The snapshot will not be modified, the system will be able to boot correctly, because a writeable folder will be included in the ram.
|
||||
(no more problems due to `/var` not open for writing)
|
||||
|
||||
Any changes in this system thus started will be lost when the system is rebooted/shutdown.
|
||||
|
||||
To do this, it is necessary to modify the initramfs.
|
||||
This means that any snapshot that does not include this modified initramfs will not be able to benefit from it.
|
||||
(except for separate boot partitions)
|
||||
#
|
||||
### Installation :
|
||||
#### Arch Linux
|
||||
1.
|
||||
`Pacman -S grub-btrfs`
|
||||
Or if you use git
|
||||
copy the `overlay_snap_ro-install` file to `/etc/initcpio/install/grub-btrfs-overlayfs`
|
||||
copy the `overlay_snap_ro-hook` file to `/etc/initcpio/hooks/grub-btrfs-overlayfs`
|
||||
You must rename the files. (I did it above)
|
||||
|
||||
For example :
|
||||
`overlay_snap_ro-install` to `grub-btrfs-overlayfs`
|
||||
`overlay_snap_ro-hook` to `grub-btrfs-overlayfs`
|
||||
Keep in mind that the files must have exactly the same name to ensure a match.
|
||||
|
||||
2.
|
||||
Edit the file `/etc/mkinitcpio.conf`
|
||||
Added hook `grub-btrfs-overlayfs` at the end of the line `HOOKS`.
|
||||
|
||||
For example :
|
||||
`HOOKS=(base udev autodetect modconf block filesystems keyboard fsck grub-btrfs-overlayfs)`
|
||||
You notice that the name of the `hook` must match the name of the 2 installed files. (don't forget it)
|
||||
|
||||
3.
|
||||
Re-generate your initramfs
|
||||
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
|
||||
|
||||
#### Other distribution
|
||||
Refer to your distribution's documentation
|
||||
or contribute to this project to add a paragraph.
|
||||
#
|
||||
240
manpages/grub-btrfs.8.man
Normal file
240
manpages/grub-btrfs.8.man
Normal file
@@ -0,0 +1,240 @@
|
||||
.TH "grub-btrfs" "8"
|
||||
|
||||
.SH "NAME"
|
||||
.PP
|
||||
grub-btrfs - Automatically add btrfs-Snapshots as a Grub submenu
|
||||
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fC/etc/grub.d/41_snapshots\-btrfs [\-V, \-\-version]\fP
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
Improves grub by adding “btrfs snapshots” to the grub menu.
|
||||
|
||||
.PP
|
||||
You can boot your system on a “snapshot” from the grub menu.
|
||||
Supports manual snapshots, snapper and timeshift.
|
||||
Features of grub-btrfs:
|
||||
.IP \(em 4
|
||||
Automatically list snapshots existing on root partition (btrfs).
|
||||
.IP \(em 4
|
||||
Automatically detect if /boot is in separate partition.
|
||||
.IP \(em 4
|
||||
Automatically detect kernel, initramfs and intel/amd microcode in /boot directory on snapshots.
|
||||
.IP \(em 4
|
||||
Automatically create corresponding “menuentry” in grub.cfg
|
||||
.IP \(em 4
|
||||
Automatically detect the type/tags and descriptions/comments of snapper/timeshift snapshots.
|
||||
.IP \(em 4
|
||||
Automatically generate grub.cfg if you use the provided systemd service.
|
||||
|
||||
.SH "CONFIGURATION"
|
||||
.PP
|
||||
grub-btrfs is configured via the file \fC/etc/default/grub\-btrfs/config\fP.
|
||||
Possible options are:
|
||||
|
||||
.SS "GENERAL"
|
||||
.SS "\fCGRUB_BTRFS_DISABLE\fP"
|
||||
.PP
|
||||
Disable grub-btrfs if true.
|
||||
.IP \(em 4
|
||||
Default: “false”
|
||||
.IP \(em 4
|
||||
Example: \fCGRUB_BTRFS_DISABLE="true"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_TITLE_FORMAT\fP"
|
||||
.PP
|
||||
The snapshot entries submenu in Grub are added according to this line. It is possible to change to order of the fields.
|
||||
.IP \(em 4
|
||||
Default: (“date” “snapshot” “type” “description”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_TITLE_FORMAT=("date" "snapshot" "type" "description")\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_LIMIT\fP"
|
||||
.PP
|
||||
Maximum number of snapshots in the GRUB snapshots sub menu.
|
||||
.IP \(em 4
|
||||
Default: “50”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_LIMIT="50"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_SUBVOLUME_SORT\fP"
|
||||
.PP
|
||||
Sort the found subvolumes by “ogeneration” or “generation” or “path” or “rootid”.
|
||||
.IP \(em 4
|
||||
See Sorting section in
|
||||
.BR btrfs-subvolume (8)
|
||||
.PP
|
||||
“-rootid” means list snapshot by new ones first.
|
||||
.IP \(em 4
|
||||
Default: “-rootid”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_SUBVOLUME_SORT="+ogen,\-gen,path,rootid"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_SHOW_SNAPSHOTS_FOUND\fP"
|
||||
.PP
|
||||
Show snapshots found during run “grub-mkconfig”
|
||||
.IP \(em 4
|
||||
Default: “true”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_ROOTFLAGS\fP"
|
||||
.PP
|
||||
Comma seperated mount options to be used when booting a snapshot.
|
||||
They can be defined here as well as in the “/” line inside the respective snapshots’
|
||||
“/etc/fstab” files. Mount options found in both places are combined, and this variable
|
||||
takes priority over `fstab` entries.
|
||||
NB: Do NOT include “subvol=...” or “subvolid=...” here.
|
||||
.IP \(em 4
|
||||
Default: “”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION\fP"
|
||||
.PP
|
||||
By default “grub-btrfs” automatically detects your boot partition,
|
||||
either located at the system root or on a separate partition or in a subvolume,
|
||||
Change to “true” if your boot partition is not detected as separate.
|
||||
.IP \(em 4
|
||||
Default: “false”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="true"\fP
|
||||
|
||||
.SS "CUSTOM KERNELS"
|
||||
.SS "\fCGRUB_BTRFS_NKERNEL\fP / \fCGRUB_BTRFS_NINIT\fP / \fCGRUB_BTRFS_CUSTOM_MICROCODE\fP"
|
||||
.PP
|
||||
By default, “grub-btrfs” automatically detects most existing kernels, initramfs and microcode.
|
||||
Customs kernel, initramfs and microcodes that are not detected can be added in these variables.
|
||||
.IP \(em 4
|
||||
Default: (“”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_NKERNEL=("kernel\-5.19.4\-custom" "vmlinux\-5.19.4\-custom")\fP
|
||||
\fCGRUB_BTRFS_NINIT=("initramfs\-5.19.4\-custom.img" "initrd\-5.19.4\-custom.img" "otherinit\-5.19.4\-custom.gz")\fP
|
||||
\fCGRUB_BTRFS_CUSTOM_MICROCODE=("custom\-ucode.img" "custom\-uc.img "custom_ucode.cpio")\fP
|
||||
|
||||
.SS "SNAPSHOT FILTERING"
|
||||
.SS "\fCGRUB_BTRFS_IGNORE_SPECIFIC_PATH\fP"
|
||||
.PP
|
||||
Ignore specific path during run “grub-mkconfig”.
|
||||
Only exact paths are ignored.
|
||||
e.g : if `specific path` = @, only `@` snapshot will be ignored.
|
||||
.IP \(em 4
|
||||
Default: (“@”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@home")\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_IGNORE_PREFIX_PATH\fP"
|
||||
.PP
|
||||
Ignore prefix path during run “grub-mkconfig”.
|
||||
Any path starting with the specified string will be ignored.
|
||||
e.g : if `prefix path` = @, all snapshots beginning with “@/...” will be ignored.
|
||||
.IP \(em 4
|
||||
Default: (“var/lib/docker” “@var/lib/docker” “@/var/lib/docker”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_IGNORE_SNAPSHOT_TYPE\fP"
|
||||
.PP
|
||||
Ignore specific type/tag of snapshot during run “grub-mkconfig”.
|
||||
For snapper:
|
||||
Type = single, pre, post.
|
||||
For Timeshift:
|
||||
Tag = boot, ondemand, hourly, daily, weekly, monthly.
|
||||
.IP \(em 4
|
||||
Default: (“”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("ondemand")\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION\fP"
|
||||
.PP
|
||||
Ignore specific description of snapshot during run “grub-mkconfig”.
|
||||
.IP \(em 4
|
||||
Default: (“”)
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION=("timeline")\fP
|
||||
|
||||
.SS "DISTRIBUTION DEPENDENT SETTINGS"
|
||||
.SS "\fCGRUB_BTRFS_BOOT_DIRNAME\fP"
|
||||
.PP
|
||||
Location of kernels/initramfs/microcode.
|
||||
Used by “grub-btrfs” to detect the boot partition and the location of kernels, initramfs and microcodes.
|
||||
.IP \(em 4
|
||||
Default: “/boot”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_BOOT_DIRNAME="/"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_GRUB_DIRNAME\fP"
|
||||
.PP
|
||||
Location of the folder containing the “grub.cfg” file.
|
||||
Used by grub-btrfs to save the file “grub-btrfs.cfg”.
|
||||
Might be grub2 on some systems.
|
||||
For example, on Fedora with EFI : “/boot/efi/EFI/fedora”
|
||||
.IP \(em 4
|
||||
Default: “/boot/grub”
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_MKCONFIG\fP"
|
||||
.PP
|
||||
Name/path of the command to generate the grub menu, used by “grub-btrfs.service”
|
||||
Might be ’grub2-mkconfig’ on some systems (e.g. Fedora)
|
||||
Default paths are /sbin:/bin:/usr/sbin:/usr/bin, if your path is missing, report it on the upstream project.
|
||||
You can use the name of the command only or full the path.
|
||||
.IP \(em 4
|
||||
Default: grub-mkconfig
|
||||
.PP
|
||||
-Example: \fCGRUB_BTRFS_MKCONFIG=/sbin/grub2\-mkconfig\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_SCRIPT_CHECK\fP"
|
||||
.PP
|
||||
Name of grub-script-check command, used by “grub-btrfs”
|
||||
Might be ’grub2-script-check’ on some systems (e.g. Fedora)
|
||||
.IP \(em 4
|
||||
Default: grub-script-check
|
||||
.IP \(em 4
|
||||
Example: \fCGRUB_BTRFS_SCRIPT_CHECK=grub2\-script\-check\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_MKCONFIG_LIB\fP"
|
||||
.PP
|
||||
Path of grub-mkconfig\d\s-2lib\s+2\u file, used by “grub-btrfs”
|
||||
Might be ’/usr/share/grub2/grub-mkconfig\d\s-2lib\s+2\u’ on some systems (e.g. Opensuse)
|
||||
.IP \(em 4
|
||||
Default: /usr/share/grub/grub-mkconfig\d\s-2lib\s+2\u
|
||||
.IP \(em 4
|
||||
Example: \fCGRUB_BTRFS_MKCONFIG_LIB=/usr/share/grub2/grub\-mkconfig_lib\fP
|
||||
|
||||
.SS "SECURITY"
|
||||
.SS "\fCGRUB_BTRFS_PROTECTION_AUTHORIZED_USERS\fP"
|
||||
.PP
|
||||
Password protection management for submenu, snapshots
|
||||
Refer to the Grub documentation \fIhttps://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation\fP
|
||||
and this comment \fIhttps://github.com/Antynea/grub-btrfs/issues/95#issuecomment-682295660\fP
|
||||
Add authorized usernames separate by comma (userfoo,userbar).
|
||||
When Grub’s password protection is enabled, the superuser is authorized by default, it is not necessary to add it
|
||||
.IP \(em 4
|
||||
Default: “- Example: \fCGRUB_BTRFS_PROTECTION_AUTHORIZED_USERS="userfoo,userbar"\fP
|
||||
|
||||
.SS "\fCGRUB_BTRFS_DISABLE_PROTECTION_SUBMENU\fP"
|
||||
.PP
|
||||
Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
does not work if GRUB\d\s-2BTRFS\s+2\u\d\s-2PROTECTION\s+2\u\d\s-2AUTHORIZED\s+2\u\d\s-2USERS\s+2\u is not empty
|
||||
.IP \(em 4
|
||||
Default: “false”
|
||||
.IP \(em 4
|
||||
Example: \fCGRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="true"\fP
|
||||
|
||||
.SH "FILES"
|
||||
.PP
|
||||
/etc/default/grub-btrfs/config
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.IR btrfs (8)
|
||||
.IR btrfs-subvolume (8)
|
||||
.IR grub-btrfsd (8)
|
||||
.IR grub-mkconfig (8)
|
||||
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright (c) 2022 Pascal Jäger
|
||||
180
manpages/grub-btrfs.8.org
Normal file
180
manpages/grub-btrfs.8.org
Normal file
@@ -0,0 +1,180 @@
|
||||
#+title: grub-btrfs
|
||||
#+author: Pascal Jaeger
|
||||
#+man_class_option: :sectionid 8
|
||||
|
||||
* NAME
|
||||
grub-btrfs - Automatically add btrfs-Snapshots as a Grub submenu
|
||||
|
||||
* SYNOPSIS
|
||||
~/etc/grub.d/41_snapshots-btrfs [-V, --version]~
|
||||
|
||||
* DESCRIPTION
|
||||
Improves grub by adding "btrfs snapshots" to the grub menu.
|
||||
|
||||
You can boot your system on a "snapshot" from the grub menu.
|
||||
Supports manual snapshots, snapper and timeshift.
|
||||
Features of grub-btrfs:
|
||||
- Automatically list snapshots existing on root partition (btrfs).
|
||||
- Automatically detect if /boot is in separate partition.
|
||||
- Automatically detect kernel, initramfs and intel/amd microcode in /boot directory on snapshots.
|
||||
- Automatically create corresponding "menuentry" in grub.cfg
|
||||
- Automatically detect the type/tags and descriptions/comments of snapper/timeshift snapshots.
|
||||
- Automatically generate grub.cfg if you use the provided systemd service.
|
||||
|
||||
* CONFIGURATION
|
||||
grub-btrfs is configured via the file ~/etc/default/grub-btrfs/config~.
|
||||
Possible options are:
|
||||
|
||||
** GENERAL
|
||||
|
||||
*** ~GRUB_BTRFS_DISABLE~
|
||||
Disable grub-btrfs if true.
|
||||
- Default: "false"
|
||||
- Example: ~GRUB_BTRFS_DISABLE="true"~
|
||||
|
||||
*** ~GRUB_BTRFS_TITLE_FORMAT~
|
||||
The snapshot entries submenu in Grub are added according to this line. It is possible to change to order of the fields.
|
||||
- Default: ("date" "snapshot" "type" "description")
|
||||
-Example: ~GRUB_BTRFS_TITLE_FORMAT=("date" "snapshot" "type" "description")~
|
||||
|
||||
*** ~GRUB_BTRFS_LIMIT~
|
||||
Maximum number of snapshots in the GRUB snapshots sub menu.
|
||||
- Default: "50"
|
||||
-Example: ~GRUB_BTRFS_LIMIT="50"~
|
||||
|
||||
*** ~GRUB_BTRFS_SUBVOLUME_SORT~
|
||||
Sort the found subvolumes by "ogeneration" or "generation" or "path" or "rootid".
|
||||
- See Sorting section in
|
||||
#+BEGIN_MAN
|
||||
.BR btrfs-subvolume (8)
|
||||
#+END_MAN
|
||||
"-rootid" means list snapshot by new ones first.
|
||||
- Default: "-rootid"
|
||||
-Example: ~GRUB_BTRFS_SUBVOLUME_SORT="+ogen,-gen,path,rootid"~
|
||||
|
||||
*** ~GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND~
|
||||
Show snapshots found during run "grub-mkconfig"
|
||||
- Default: "true"
|
||||
-Example: ~GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"~
|
||||
|
||||
*** ~GRUB_BTRFS_ROOTFLAGS~
|
||||
Comma seperated mount options to be used when booting a snapshot.
|
||||
They can be defined here as well as in the "/" line inside the respective snapshots'
|
||||
"/etc/fstab" files. Mount options found in both places are combined, and this variable
|
||||
takes priority over `fstab` entries.
|
||||
NB: Do NOT include "subvol=..." or "subvolid=..." here.
|
||||
- Default: ""
|
||||
-Example: ~GRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"~
|
||||
|
||||
*** ~GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION~
|
||||
By default "grub-btrfs" automatically detects your boot partition,
|
||||
either located at the system root or on a separate partition or in a subvolume,
|
||||
Change to "true" if your boot partition is not detected as separate.
|
||||
- Default: "false"
|
||||
-Example: ~GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="true"~
|
||||
|
||||
** CUSTOM KERNELS
|
||||
|
||||
*** ~GRUB_BTRFS_NKERNEL~ / ~GRUB_BTRFS_NINIT~ / ~GRUB_BTRFS_CUSTOM_MICROCODE~
|
||||
By default, "grub-btrfs" automatically detects most existing kernels, initramfs and microcode.
|
||||
Customs kernel, initramfs and microcodes that are not detected can be added in these variables.
|
||||
- Default: ("")
|
||||
-Example: ~GRUB_BTRFS_NKERNEL=("kernel-5.19.4-custom" "vmlinux-5.19.4-custom")~
|
||||
~GRUB_BTRFS_NINIT=("initramfs-5.19.4-custom.img" "initrd-5.19.4-custom.img" "otherinit-5.19.4-custom.gz")~
|
||||
~GRUB_BTRFS_CUSTOM_MICROCODE=("custom-ucode.img" "custom-uc.img "custom_ucode.cpio")~
|
||||
|
||||
** SNAPSHOT FILTERING
|
||||
|
||||
*** ~GRUB_BTRFS_IGNORE_SPECIFIC_PATH~
|
||||
Ignore specific path during run "grub-mkconfig".
|
||||
Only exact paths are ignored.
|
||||
e.g : if `specific path` = @, only `@` snapshot will be ignored.
|
||||
- Default: ("@")
|
||||
-Example: ~GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@home")~
|
||||
|
||||
*** ~GRUB_BTRFS_IGNORE_PREFIX_PATH~
|
||||
Ignore prefix path during run "grub-mkconfig".
|
||||
Any path starting with the specified string will be ignored.
|
||||
e.g : if `prefix path` = @, all snapshots beginning with "@/..." will be ignored.
|
||||
- Default: ("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
|
||||
-Example: ~GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")~
|
||||
|
||||
*** ~GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE~
|
||||
Ignore specific type/tag of snapshot during run "grub-mkconfig".
|
||||
For snapper:
|
||||
Type = single, pre, post.
|
||||
For Timeshift:
|
||||
Tag = boot, ondemand, hourly, daily, weekly, monthly.
|
||||
- Default: ("")
|
||||
-Example: ~GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("ondemand")~
|
||||
|
||||
*** ~GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION~
|
||||
Ignore specific description of snapshot during run "grub-mkconfig".
|
||||
- Default: ("")
|
||||
-Example: ~GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION=("timeline")~
|
||||
|
||||
** DISTRIBUTION DEPENDENT SETTINGS
|
||||
|
||||
*** ~GRUB_BTRFS_BOOT_DIRNAME~
|
||||
Location of kernels/initramfs/microcode.
|
||||
Used by "grub-btrfs" to detect the boot partition and the location of kernels, initramfs and microcodes.
|
||||
- Default: "/boot"
|
||||
-Example: ~GRUB_BTRFS_BOOT_DIRNAME="/"~
|
||||
|
||||
*** ~GRUB_BTRFS_GRUB_DIRNAME~
|
||||
Location of the folder containing the "grub.cfg" file.
|
||||
Used by grub-btrfs to save the file "grub-btrfs.cfg".
|
||||
Might be grub2 on some systems.
|
||||
For example, on Fedora with EFI : "/boot/efi/EFI/fedora"
|
||||
- Default: "/boot/grub"
|
||||
-Example: ~GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"~
|
||||
|
||||
*** ~GRUB_BTRFS_MKCONFIG~
|
||||
Name/path of the command to generate the grub menu, used by "grub-btrfs.service"
|
||||
Might be 'grub2-mkconfig' on some systems (e.g. Fedora)
|
||||
Default paths are /sbin:/bin:/usr/sbin:/usr/bin, if your path is missing, report it on the upstream project.
|
||||
You can use the name of the command only or full the path.
|
||||
- Default: grub-mkconfig
|
||||
-Example: ~GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig~
|
||||
|
||||
*** ~GRUB_BTRFS_SCRIPT_CHECK~
|
||||
Name of grub-script-check command, used by "grub-btrfs"
|
||||
Might be 'grub2-script-check' on some systems (e.g. Fedora)
|
||||
- Default: grub-script-check
|
||||
- Example: ~GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check~
|
||||
|
||||
*** ~GRUB_BTRFS_MKCONFIG_LIB~
|
||||
Path of grub-mkconfig_lib file, used by "grub-btrfs"
|
||||
Might be '/usr/share/grub2/grub-mkconfig_lib' on some systems (e.g. Opensuse)
|
||||
- Default: /usr/share/grub/grub-mkconfig_lib
|
||||
- Example: ~GRUB_BTRFS_MKCONFIG_LIB=/usr/share/grub2/grub-mkconfig_lib~
|
||||
|
||||
** SECURITY
|
||||
|
||||
*** ~GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS~
|
||||
Password protection management for submenu, snapshots
|
||||
Refer to the Grub documentation https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation
|
||||
and this comment https://github.com/Antynea/grub-btrfs/issues/95#issuecomment-682295660
|
||||
Add authorized usernames separate by comma (userfoo,userbar).
|
||||
When Grub's password protection is enabled, the superuser is authorized by default, it is not necessary to add it
|
||||
- Default: "- Example: ~GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS="userfoo,userbar"~
|
||||
|
||||
*** ~GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU~
|
||||
Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
does not work if GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS is not empty
|
||||
- Default: "false"
|
||||
- Example: ~GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="true"~
|
||||
|
||||
* FILES
|
||||
/etc/default/grub-btrfs/config
|
||||
|
||||
* SEE ALSO
|
||||
#+BEGIN_MAN
|
||||
.IR btrfs (8)
|
||||
.IR btrfs-subvolume (8)
|
||||
.IR grub-btrfsd (8)
|
||||
.IR grub-mkconfig (8)
|
||||
#+END_MAN
|
||||
|
||||
* COPYRIGHT
|
||||
Copyright (c) 2022 Pascal Jäger
|
||||
81
manpages/grub-btrfsd.8.man
Normal file
81
manpages/grub-btrfsd.8.man
Normal file
@@ -0,0 +1,81 @@
|
||||
.TH "grub-btrfsd" "8"
|
||||
|
||||
.SH "NAME"
|
||||
.PP
|
||||
grub-btrfsd - An OpenRC daemon to automatically update the grub menu with
|
||||
.BR grub-btrfs (8)
|
||||
.PP
|
||||
when a new btrfs snapshot is created.
|
||||
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fCgrub\-btrfsd [\-h, \-\-help] [\-c, \-\-no\-color] [\-l, \-\-log\-file LOG_FILE] [\-s, \-\-syslog] [\-t, \-\-timeshift\-auto] [\-o, \-\-timeshift\-old] [\-v, \-\-verbose] SNAPSHOTS_DIR\fP
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
Grub-btrfsd is a shell script which is meant to be run as a daemon.
|
||||
Grub-btrfsd watches a directory where btrfs-snapshots are created or deleted via inotifywait and runs grub-mkconfig (if grub-mkconfig never ran before since grub-btrfs was installed) or \fC/etc/grub.d/41_snapshots\-btrfs\fP (when grub-mkconfig ran before with grub-btrfs installed) when something in that directory changes.
|
||||
|
||||
.SH "OPTIONS"
|
||||
.SS "\fCSNAPSHOTS_DIR\fP"
|
||||
.PP
|
||||
This argument specifies the path where grub-btrfsd looks for newly created snapshots and snapshot deletions. It is usually defined by the program used to make snapshots.
|
||||
E.g. for Snapper this would be \fC/.snapshots\fP
|
||||
|
||||
.SS "\fC\-c / \-\-no\-color\fP"
|
||||
.PP
|
||||
Disable colors in output.
|
||||
|
||||
.SS "\fC\-l / \-\-log\-file\fP"
|
||||
.PP
|
||||
This arguments specifies a file where grub-btrfsd should write log messages.
|
||||
|
||||
.SS "\fC\-s / \-\-syslog\fP"
|
||||
.PP
|
||||
Write to syslog
|
||||
|
||||
.SS "\fC\-t / \-\-timeshift\-auto\fP"
|
||||
.PP
|
||||
This is a flag to activate the auto detection of the path where Timeshift stores snapshots. Newer versions (>=22.06) of Timeshift mount their snapshots to \fC/run/timeshift/$PID/backup/timeshift\-btrfs\fP. Where \fC$PID\fP is the process ID of the currently running Timeshift session. The PID is changing every time Timeshift is opened. grub-btrfsd can automatically take care of the detection of the correct PID and directory if this flag is set. In this case the argument \fCSNAPSHOTS_DIR\fP has no effect.
|
||||
|
||||
.SS "\fC\-o / \-\-timeshift\-old\fP"
|
||||
.PP
|
||||
Look for snapshots in \fC/run/timeshift/backup/timeshift\-btrfs\fP instead of \fC/run/timeshift/$PID/backup/timeshift\-btrfs\fP. This is to be used for Timeshift versions <22.06.
|
||||
|
||||
.SS "\fC\-v / \-\-verbose\fP"
|
||||
.PP
|
||||
Let the log of the daemon be more verbose
|
||||
|
||||
.SS "\fC\-h / \-\-help\fP"
|
||||
.PP
|
||||
Displays a short help message.
|
||||
|
||||
|
||||
|
||||
.SH "CONFIGURATION"
|
||||
.PP
|
||||
The daemon is usually configured via the file \fC/etc/conf.d/grub\-btrfsd\fP on openrc-init systems and \fCsudo systemctl edit \-\-full grub\-btrfsd\fP on systemd systems. In this file the arguments (See OPTIONS), that OpenRC passes to the daemon when it is started, can be configured.
|
||||
|
||||
.SS "NOTES"
|
||||
.PP
|
||||
A common configuration for Snapper would be to set \fCSNAPSHOTS_DIR\fP to \fC/.snapshots\fP and not to set \fC\-\-timeshift\-auto\fP.
|
||||
For Timeshift \fC\-\-timeshift\-auto\fP is set to true and \fCSNAPSHOTS_DIR\fP can be left as is.
|
||||
|
||||
.SH "FILES"
|
||||
.PP
|
||||
\fC/etc/conf.d/grub\-btrfsd\fP
|
||||
\fC/usr/lib/systemd/system/grub\-btrfsd.service\fP
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.IR btrfs (8)
|
||||
.IR btrfs-subvolume (8)
|
||||
.IR grub-btrfsd (8)
|
||||
.IR grub-mkconfig (8)
|
||||
.IR inotifywait (1)
|
||||
.IR openrc (8)
|
||||
.IR rc-service (8)
|
||||
.IR timeshift (1)
|
||||
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright (c) 2022 Pascal Jäger
|
||||
71
manpages/grub-btrfsd.8.org
Normal file
71
manpages/grub-btrfsd.8.org
Normal file
@@ -0,0 +1,71 @@
|
||||
#+title: grub-btrfsd
|
||||
#+author: Pascal Jaeger
|
||||
#+man_class_option: :sectionid 8
|
||||
|
||||
* NAME
|
||||
grub-btrfsd - An OpenRC daemon to automatically update the grub menu with
|
||||
#+BEGIN_MAN
|
||||
.BR grub-btrfs (8)
|
||||
#+END_MAN
|
||||
when a new btrfs snapshot is created.
|
||||
|
||||
* SYNOPSIS
|
||||
~grub-btrfsd [-h, --help] [-c, --no-color] [-l, --log-file LOG_FILE] [-s, --syslog] [-t, --timeshift-auto] [-o, --timeshift-old] [-v, --verbose] SNAPSHOTS_DIR~
|
||||
|
||||
* DESCRIPTION
|
||||
Grub-btrfsd is a shell script which is meant to be run as a daemon.
|
||||
Grub-btrfsd watches a directory where btrfs-snapshots are created or deleted via inotifywait and runs grub-mkconfig (if grub-mkconfig never ran before since grub-btrfs was installed) or ~/etc/grub.d/41_snapshots-btrfs~ (when grub-mkconfig ran before with grub-btrfs installed) when something in that directory changes.
|
||||
|
||||
* OPTIONS
|
||||
** ~SNAPSHOTS_DIR~
|
||||
This argument specifies the path where grub-btrfsd looks for newly created snapshots and snapshot deletions. It is usually defined by the program used to make snapshots.
|
||||
E.g. for Snapper this would be ~/.snapshots~
|
||||
|
||||
** ~-c / --no-color~
|
||||
Disable colors in output.
|
||||
|
||||
** ~-l / --log-file~
|
||||
This arguments specifies a file where grub-btrfsd should write log messages.
|
||||
|
||||
** ~-s / --syslog~
|
||||
Write to syslog
|
||||
|
||||
** ~-t / --timeshift-auto~
|
||||
This is a flag to activate the auto detection of the path where Timeshift stores snapshots. Newer versions (>=22.06) of Timeshift mount their snapshots to ~/run/timeshift/$PID/backup/timeshift-btrfs~. Where ~$PID~ is the process ID of the currently running Timeshift session. The PID is changing every time Timeshift is opened. grub-btrfsd can automatically take care of the detection of the correct PID and directory if this flag is set. In this case the argument ~SNAPSHOTS_DIR~ has no effect.
|
||||
|
||||
** ~-o / --timeshift-old~
|
||||
Look for snapshots in ~/run/timeshift/backup/timeshift-btrfs~ instead of ~/run/timeshift/$PID/backup/timeshift-btrfs~. This is to be used for Timeshift versions <22.06.
|
||||
|
||||
** ~-v / --verbose~
|
||||
Let the log of the daemon be more verbose
|
||||
|
||||
** ~-h / --help~
|
||||
Displays a short help message.
|
||||
|
||||
|
||||
|
||||
* CONFIGURATION
|
||||
The daemon is usually configured via the file ~/etc/conf.d/grub-btrfsd~ on openrc-init systems and ~sudo systemctl edit --full grub-btrfsd~ on systemd systems. In this file the arguments (See OPTIONS), that OpenRC passes to the daemon when it is started, can be configured.
|
||||
|
||||
** NOTES
|
||||
A common configuration for Snapper would be to set ~SNAPSHOTS_DIR~ to ~/.snapshots~ and not to set ~--timeshift-auto~.
|
||||
For Timeshift ~--timeshift-auto~ is set to true and ~SNAPSHOTS_DIR~ can be left as is.
|
||||
|
||||
* FILES
|
||||
~/etc/conf.d/grub-btrfsd~
|
||||
~/usr/lib/systemd/system/grub-btrfsd.service~
|
||||
|
||||
* SEE ALSO
|
||||
#+BEGIN_MAN
|
||||
.IR btrfs (8)
|
||||
.IR btrfs-subvolume (8)
|
||||
.IR grub-btrfsd (8)
|
||||
.IR grub-mkconfig (8)
|
||||
.IR inotifywait (1)
|
||||
.IR openrc (8)
|
||||
.IR rc-service (8)
|
||||
.IR timeshift (1)
|
||||
#+END_MAN
|
||||
|
||||
* COPYRIGHT
|
||||
Copyright (c) 2022 Pascal Jäger
|
||||
Reference in New Issue
Block a user