Compare commits

...

22 Commits

Author SHA1 Message Date
Pascal Jäger
6bc0ee806f Makefile: Ignore ubuntu initramfs uninstall fail
this stops the Makefile with an error, if it can not find
`initramfs/ubuntu/setup` (which it wont in case of a non-Ubuntu distro.)

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2023-01-22 20:00:46 +01:00
Luis Marsano
2b9c1d2730 update Makefile for mkinitramfs
introduce feature flag for mkinitramfs in Makefile
extend install & uninstall targets when feature flag is true
document flag in help target
2023-01-15 14:26:12 -05:00
Luis Marsano
1749789f9a define uninstall subcommand for ubuntu setup
parse options and subcommands in setup script
update readme
2023-01-15 14:26:08 -05:00
Luis Marsano
695f4b06ba add setup instructions for ubuntu initramfs 2022-12-20 20:23:43 -05:00
Luis Marsano
d5541253d3 specialize overlay script & refactor
kernel parameters normally identify root filesystem as readonly before boot process remounts them writable, so the readonly parameter does not identify readonly filesystems
the script reduces scope to btrfs for simplicity
as a standard linux util, findmnt is copied & used
arrange commands so executables are checked before file system queries and short-circuit evaluation skips unavailable commands
for robustness, trap on error & exit events
replace panic with failure logging, since panic doesn't appear to break to shell
2022-12-20 20:23:38 -05:00
Luis Marsano
4e4e853f2d define initramfs scripts for ubuntu
provide a hook to require overlayfs module so the file system is available
define a general script to overlay any readonly root filesystem into a non-persistent, writable filesystem
2022-12-20 12:36:42 -05:00
Pascal Jäger
89ef805e81 grub-btrfsd: do no append with += to optional args
This does not work anymore, but it should be similar to the systemd
service file anyway, where things are just written in one line.

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-12-10 22:20:15 +01:00
Pascal Jäger
e03e87dd64 grub-btrfsd: Use bash as interpreter
Fix: #248

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-12-07 15:01:10 +01:00
Pascal Jäger
29ec43e9a6 grub-btrfsd: Fix non POSIX redirect
Squashed commit of the following:

commit d75feb59f4
Author: Pascal J <pascal.jaeger@leimstift.de>
Date:   Sun Dec 4 22:07:01 2022 +0100

    grub-btrsd: update shebang

commit a64379789c
Author: Pavin Joseph <pavinjosdev@gmail.com>
Date:   Sun Dec 4 22:52:31 2022 +0530

    Update grub-btrfsd

commit fe42568785
Author: Pavin Joseph <pavinjosdev@gmail.com>
Date:   Sun Dec 4 04:07:05 2022 +0530

    Update grub-btrfsd

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-12-04 22:11:00 +01:00
Kevin Chevreuil - Kaisen
6980771cd2 Don't display warnings when the mount command is used 2022-11-29 14:47:18 +01:00
Pascal Jäger
bc167ffe00 Readme: added instructions for --timeshift-old
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 17:59:38 +01:00
Pascal Jäger
b661e4e03f Merge branch 'fix-snap-dir-check' 2022-11-26 17:46:45 +01:00
Pascal Jäger
f594a56232 Merge branch 'improve-version-generation' 2022-11-26 17:44:06 +01:00
Pascal Jäger
fe48642596 Merge branch 'make-prefix-configurable' 2022-11-26 17:38:15 +01:00
Pascal Jäger
bfad9dcc1d grub-btrfs: Add possibility to configure where grub-btrfs.cfg is created and searched for
Closes #187

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 15:14:00 +01:00
Pascal Jäger
e3d0792a74 Post release version bump
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 15:10:28 +01:00
Pascal Jäger
efc4657aab grub-btrfsd: fixed message about flag dependencies
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 15:06:44 +01:00
Pascal Jäger
9e34f53ef8 Readme: discribe new version generation
Fix #237

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 15:03:10 +01:00
Pascal Jäger
6f154329c7 grub-btrfsd: fix if...else in daemon
add description of feature in manpage
fix non sh compatible commands in daemon

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-26 10:06:19 +01:00
Pascal Jäger
4942989d7f grub-btrfsd: add flag or old timeshift
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-25 16:58:07 +01:00
Pascal Jäger
91c4aac82c grub-btrfsd: make dir check of snapshots dir a warning
Bug #234

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-25 08:52:49 +01:00
Pascal Jäger
1d760ad730 Post release version bump
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2022-11-23 16:11:45 +01:00
15 changed files with 345 additions and 99 deletions

View File

@@ -91,6 +91,10 @@ btrfs_subvolume_sort="--sort=${GRUB_BTRFS_SUBVOLUME_SORT:-"-rootid"}"
grub_directory=${GRUB_BTRFS_GRUB_DIRNAME:-"/boot/grub"}
## Customize BOOT directory, where kernels/initrams/microcode is saved.
boot_directory=${GRUB_BTRFS_BOOT_DIRNAME:-"/boot"}
## Customize GRUB-BTRFS.cfg directory, where "grub-btrfs.cfg" file is saved
grub_btrfs_directory=${GRUB_BTRFS_GBTRFS_DIRNAME:-"/boot/grub"}
## Customize directory where "grub-btrfs.cfg" file is searched for by grub
grub_btrfs_search_directory=${GRUB_BTRFS_GBTRFS_SEARCH_DIRNAME:-"\${prefix}"}
## Password protection management for submenu
# Protection support for submenu (--unrestricted)
case "${GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU,,}" in
@@ -177,7 +181,7 @@ fi
## Create entry
entry()
{
echo "$@" >> "$grub_directory/grub-btrfs.new"
echo "$@" >> "$grub_btrfs_directory/grub-btrfs.new"
}
## menu entries
@@ -494,7 +498,7 @@ header_menu()
local lenght_title_column_right=$(((${#var}-lenght_title_column_left)+1)) #+1 is necessary for extra "|" character
header_entry+=$(printf "%${lenght_title_column_left}s%${lenght_title_column_right}s" "${title_column[${GRUB_BTRFS_TITLE_FORMAT[$key],,}]}" "|") # Final "|" is for visuals only
done
sed -i "1imenuentry '|${header_entry}' { echo }" "$grub_directory/grub-btrfs.new" # First "|" is for visuals only
sed -i "1imenuentry '|${header_entry}' { echo }" "$grub_btrfs_directory/grub-btrfs.new" # First "|" is for visuals only
}
## List of kernels, initramfs and microcode in snapshots
@@ -561,11 +565,11 @@ boot_separate()
IFS=$oldIFS
}
rm -f "$grub_directory/grub-btrfs.new"
> "$grub_directory/grub-btrfs.new" # Create a "grub-btrfs.new" file in "grub_directory"
rm -f "$grub_btrfs_directory/grub-btrfs.new"
> "$grub_btrfs_directory/grub-btrfs.new" # Create a "grub-btrfs.new" file in "grub_btrfs_directory"
# Create mount point then mounting
[[ ! -d $grub_btrfs_mount_point ]] && mkdir -p "$grub_btrfs_mount_point"
mount -o ro,subvolid=5 /dev/disk/by-uuid/"$root_uuid" "$grub_btrfs_mount_point/"
mount -o ro,subvolid=5 /dev/disk/by-uuid/"$root_uuid" "$grub_btrfs_mount_point/" > /dev/null
trap "unmount_grub_btrfs_mount_point" EXIT # unmounting mount point on EXIT signal
count_warning_menuentries=0 # Count menuentries
count_limit_snap=0 # Count snapshots
@@ -585,16 +589,16 @@ if [[ "${count_limit_snap}" = "0" || -z "${count_limit_snap}" ]]; then
fi
# Make a submenu in GRUB (grub.cfg) and move "grub-btrfs.new" to "grub-btrfs.cfg"
header_menu
if "${bindir}/${GRUB_BTRFS_SCRIPT_CHECK:-grub-script-check}" "$grub_directory/grub-btrfs.new"; then
cat "$grub_directory/grub-btrfs.new" > "$grub_directory/grub-btrfs.cfg"
rm -f "$grub_directory/grub-btrfs.new"
if "${bindir}/${GRUB_BTRFS_SCRIPT_CHECK:-grub-script-check}" "$grub_btrfs_directory/grub-btrfs.new"; then
cat "$grub_btrfs_directory/grub-btrfs.new" > "$grub_btrfs_directory/grub-btrfs.cfg"
rm -f "$grub_btrfs_directory/grub-btrfs.new"
cat << EOF
submenu '${submenuname}' ${protection_authorized_users}${unrestricted_access_submenu}{
configfile "\${prefix}/grub-btrfs.cfg"
configfile "${grub_btrfs_search_directory}/grub-btrfs.cfg"
}
EOF
else
print_error "Syntax errors were detected in generated ${grub_directory}/grub-btrfs.new file. Old grub-btrfs.cfg (if present) was not replaced."
print_error "Syntax errors were detected in generated ${grub_btrfs_directory}/grub-btrfs.new file. Old grub-btrfs.cfg (if present) was not replaced."
fi
# warn when this script is run but there is no entry in grub.cfg

View File

@@ -2,6 +2,7 @@ PKGNAME ?= grub-btrfs
PREFIX ?= /usr
INITCPIO ?= false
MKINITRAMFS ?= false
SYSTEMD ?= true
OPENRC ?= false
@@ -59,6 +60,11 @@ install:
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
@# Ubuntu like distros only :
@if test "$(MKINITRAMFS)" = true; then \
echo "Installing mkinitramfs hook"; \
initramfs/ubuntu/setup install; \
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"
@@ -80,6 +86,7 @@ uninstall:
@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"
@initramfs/ubuntu/setup uninstall || true
@rm -f "$(MAN_DIR)/man8/grub-btrfs.8.bz2"
@rm -f "$(MAN_DIR)/man8/grub-btrfsd.8.bz2"
@# Arch Linux UNlike distros only :
@@ -108,14 +115,15 @@ help:
@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 " 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 " MKINITRAMFS | bool | include mkinitramfs hook | false"
@echo " SYSTEMD | bool | include unit files | true"
@echo " OPENRC | bool | include OpenRc daemon | false"
@echo

View File

@@ -1,8 +1,6 @@
[![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)
This is version 4.12 of grub-btrfs.
## 💻 grub-btrfs
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
@@ -106,13 +104,15 @@ Disable colors in output.
* `-l / --log-file`
This arguments specifies a file where grub-btrfsd should write log messages.
* `-s / --syslog`
* `-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.
* `-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
@@ -129,7 +129,7 @@ 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
@@ -149,7 +149,7 @@ For additional information on daemon script and its arguments, run `grub-btrfsd
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
@@ -162,11 +162,9 @@ 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 # for systemd
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:
@@ -186,10 +184,11 @@ EnvironmentFile=/etc/default/grub-btrfs/config
# SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto
# Optional arguments:
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory
# -o, --timeshift-old Activate for timeshift versions <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
ExecStart=/usr/bin/grub-btrfsd --syslog /path/to/your/snapshot/directory
ExecStart=/usr/bin/grub-btrfsd --syslog /.snapshots
[Install]
WantedBy=multi-user.target
@@ -205,10 +204,9 @@ Newer Timeshift versions create a new directory named after their process ID in
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.
##### Systemd
To pass `--timeshift-auto` to grub-btrfsd, the .service-file of grub-btrfsd can be edited with
```bash
sudo systemctl edit --full grub-btrfsd # for systemd
sudo systemctl edit --full grub-btrfsd
```
The line that says
@@ -250,7 +248,7 @@ WantedBy=multi-user.target
When done, the service must be restarted with
``` bash
sudo systemctl restart grub-btrfsd # for systemd
sudo systemctl restart grub-btrfsd
```
Note:
@@ -260,7 +258,7 @@ 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
@@ -285,26 +283,24 @@ After editing, the file should look like this:
# 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="/.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
# Append options to this like this:
# optional_args="--syslog --timeshift-auto --verbose"
# Possible options are:
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
# -o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (requires --timeshift-auto)
# -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 "
optional_args="--syslog"
```
After that, the daemon should be restarted with
``` bash
sudo rc-service grub-btrfsd restart # for openRC
sudo rc-service grub-btrfsd restart
```
##### 🌟 Timeshift >= version 22.06
@@ -337,7 +333,7 @@ optional_args+="--timeshift-auto "
After that, the daemon should be restarted with
``` bash
sudo rc-service grub-btrfsd restart # for openRC
sudo rc-service grub-btrfsd restart
```
##### ❇️ Automatically update grub upon restart/boot:
@@ -386,6 +382,23 @@ 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)
- - -
### Development
Grub-btrfs uses a rudimentary system of automatic versioning to tell apart different commits. This is helpful when users report problems and it is not immediately clear what version they are using.
We therefore have the following script in `.git/hooks/pre-commit`:
``` bash
#!/bin/sh
echo "Doing pre commit hook with version bump"
version="$(git describe --tags --abbrev=0)-$(git rev-parse --abbrev-ref HEAD)-$(date -u -Iseconds)"
echo "New version is ${version}"
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${version}/" config
git add config
```
This automatically sets the version in the `config`-file to `[lasttag]-[branch-name]-[current-date-in-UTC]`.
In order to create a Tag we don't want to have this long version. In this case we set the version manually in `config` and commit with `git commit --no-verify`. This avoids running the hook.
### Special thanks for assistance and contributions
* [Maxim Baz](https://github.com/maximbaz)
* [Schievel1](https://github.com/Antynea/grub-btrfs/discussions/173#discussioncomment-1438790)

20
config
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
GRUB_BTRFS_VERSION=4.12
GRUB_BTRFS_VERSION=4.12-master-2022-12-10T21:20:15+00:00
# Disable grub-btrfs.
# Default: "false"
@@ -99,6 +99,24 @@ GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/doc
# Default: "/boot"
#GRUB_BTRFS_BOOT_DIRNAME="/boot"
# Location where grub-btrfs.cfg should be saved.
# Some distributions (like OpenSuSE) store those file at the snapshot directory
# instead of boot. Be aware that this direcory must be available for grub during
# startup of the system.
# Default: "/boot/grub"
#GRUB_BTRFS_GBTRFS_DIRNAME="/boot/grub"
# Location of the directory where Grub searches for the grub-btrfs.cfg file.
# Some distributions (like OpenSuSE) store those file at the snapshot directory
# instead of boot. Be aware that this direcory must be available for grub during
# startup of the system.
# Default: "\${prefix}" # This is a grub variable that resolves to where grub is
# installed. (like /boot/grub, /boot/efi/grub)
# NOTE: If variables of grub are used here (like ${prefix}) they need to be escaped
# with `\` before the `$`
#GRUB_BTRFS_GBTRFS_SEARCH_DIRNAME="\${prefix}"
# 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,

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
# Copyright 2022 Pascal Jaeger
# Distributed under the terms of the GNU General Public License v3
# Update GRUB when new BTRFS snapshots are created.
@@ -9,6 +9,7 @@ watchtime=0
logfile=0
snapshots=-1
timeshift_auto=false
timeshift_old=false
verbose=false
syslog=false
@@ -31,8 +32,8 @@ 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"
[ -f "$grub_btrfs_config" ] && . "$grub_btrfs_config"
[ -f "${sysconfdir}/default/grub" ] && . "${sysconfdir}/default/grub"
print_help() {
echo "${CYAN}[?] Usage:"
@@ -44,6 +45,7 @@ print_help() {
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"
@@ -97,6 +99,9 @@ while getopts :l:ctvsh-: opt; do
timeshift-auto)
timeshift_auto=true
;;
timeshift-old)
timeshift_old=true
;;
verbose)
verbose=true
;;
@@ -125,6 +130,9 @@ while getopts :l:ctvsh-: opt; do
t)
timeshift_auto=true
;;
o)
timeshift_old=true
;;
v)
verbose=true
;;
@@ -150,7 +158,7 @@ shift $(( OPTIND - 1 ))
snapshots="${1}"
# check if inotify exists, see issue #227
if ! command -v inotifywait &> /dev/null; then
if ! command -v inotifywait >/dev/null 2>&1; then
err "[!] inotifywait was not found, exiting. Is inotify-tools installed?" "${RED}" >&2
exit 1
fi
@@ -168,9 +176,15 @@ 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
@@ -204,6 +218,15 @@ create_grub_menu() {
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}"
@@ -217,7 +240,7 @@ while true; do
fi
timeshift_pid=$(ps ax | awk '{sub(/.*\//, "", $5)} $5 ~ /timeshift/ {print $1}')
if [ "${#timeshift_pid}" -gt 0 ]; then
snapshots="/run/timeshift/${timeshift_pid}/backup/timeshift-btrfs/snapshots"
set_snapshot_dir
log "detected running Timeshift at daemon startup, PID is: $timeshift_pid"
vlog "new snapshots directory is $snapshots"
else
@@ -225,7 +248,7 @@ while true; do
inotifywait ${inotify_qiet_flag} -e create -e delete /run/timeshift && {
sleep 1
timeshift_pid=$(ps ax | awk '{sub(/.*\//, "", $5)} $5 ~ /timeshift/ {print $1}')
snapshots="/run/timeshift/${timeshift_pid}/backup/timeshift-btrfs/snapshots"
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

View File

@@ -6,13 +6,12 @@ snapshots="/.snapshots" # Snapper in the root directory
#snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
## Optional arguments to run with the daemon
# Append options to this like this:
# optional_args="--syslog --timeshift-auto --verbose"
# Possible options are:
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
# -o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (requires --timeshift-auto)
# -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 "
optional_args="--syslog"

View File

@@ -13,6 +13,7 @@ EnvironmentFile=/etc/default/grub-btrfs/config
# SNAPSHOTS_DIR Snapshot directory to watch, without effect when --timeshift-auto
# Optional arguments:
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory
# -o, --timeshift-old Activate for timeshift versions <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

View File

@@ -39,6 +39,13 @@ You notice that the name of the `hook` must match the name of the 2 installed fi
Re-generate your initramfs
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
#### Ubuntu
Install initramfs scripts & re-generate initramfs.
``` shell
sudo initramfs/ubuntu/setup install
```
#### Other distribution
Refer to your distribution's documentation
or contribute to this project to add a paragraph.

View File

@@ -0,0 +1,15 @@
#!/bin/sh -e
PREREQ=
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
manual_add_modules overlay
copy_exec /usr/bin/findmnt /usr/bin

View File

@@ -0,0 +1,32 @@
#!/bin/sh -e
PREREQ=
prereqs() {
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
on_err() {
log_failure_msg 'error setting up overlay'
}
trap on_err ERR
if [ -x /usr/bin/btrfs -a -x /usr/bin/findmnt ] &&
[ "$(findmnt -no FSTYPE -M "$rootmnt")" = btrfs ] &&
[ "$(btrfs property get $rootmnt ro)" != ro=false ]
then
log_begin_msg 'remount read-only subvolume as read-only layer in non-persistent, writable overlay'
trap log_end_msg EXIT
lower_dir="$(mktemp -dp /)"
ram_dir="$(mktemp -dp /)"
upper_dir="$ram_dir"/upper
work_dir="$ram_dir"/work
mount --move "$rootmnt" "$lower_dir"
mount -t tmpfs cowspace "$ram_dir"
mkdir -p "$upper_dir" "$work_dir"
mount -t overlay -o lowerdir="$lower_dir",upperdir="$upper_dir",workdir="$work_dir" rootfs "$rootmnt"
fi

70
initramfs/ubuntu/setup Executable file
View File

@@ -0,0 +1,70 @@
#!/usr/bin/env bash
log() {
local CODE=$?
echo >&2 "$*"
return $CODE
}
print-help() {
log "\
usage: ${0##*/} [-h] [--] (install|uninstall)
Install initramfs scripts for Ubuntu.
# Options
-h display this help & exit
# Subcommands
install install initramfs scripts
uninstall remove initramfs scripts"
}
usage-error() {
print-help
exit 2
}
action-install() {
local SCRIPT_DIR="$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && pwd)"
install {"$SCRIPT_DIR",/etc/initramfs-tools}/hooks/grub-btrfs-overlay
install {"$SCRIPT_DIR",/etc/initramfs-tools}/scripts/local-bottom/grub-btrfs-overlay
}
action-uninstall() {
rm -f /etc/initramfs-tools/{hooks,scripts/local-bottom}/grub-btrfs-overlay
}
set -e
while getopts h OPT
do case "$OPT" in
h)
print-help
exit
;;
*)
usage-error
esac done
shift $(( OPTIND - 1 ))
OPTIND=1
ACTION=
case "$#" in
0)
log event: a subcommand is required
usage-error
;;
1)
case "$1" in
install|uninstall)
ACTION="action-$1"
;;
*)
log "\
event: unknown subcommand
subcommand: $1"
usage-error
esac
;;
*)
log "\
event: too many arguments
arguments: $*"
usage-error
esac
"$ACTION" || log "\
event: execution failure
suggestion: rerun with sudo"
exec update-initramfs -u

View File

@@ -48,16 +48,16 @@ Example: \fCGRUB_BTRFS_DISABLE="true"\fP
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
.IP \(em 4
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
.IP \(em 4
Example: \fCGRUB_BTRFS_LIMIT="50"\fP
.SS "\fCGRUB_BTRFS_SUBVOLUME_SORT\fP"
.PP
@@ -69,16 +69,16 @@ See Sorting section in
“-rootid” means list snapshot by new ones first.
.IP \(em 4
Default: “-rootid”
.PP
-Example: \fCGRUB_BTRFS_SUBVOLUME_SORT="+ogen,\-gen,path,rootid"\fP
.IP \(em 4
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
.IP \(em 4
Example: \fCGRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"\fP
.SS "\fCGRUB_BTRFS_ROOTFLAGS\fP"
.PP
@@ -89,8 +89,8 @@ 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
.IP \(em 4
Example: \fCGRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"\fP
.SS "\fCGRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION\fP"
.PP
@@ -99,8 +99,8 @@ 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
.IP \(em 4
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"
@@ -109,10 +109,10 @@ By default, “grub-btrfs” automatically detects most existing kernels, initra
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
.IP \(em 4
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"
@@ -122,8 +122,8 @@ 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
.IP \(em 4
Example: \fCGRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@home")\fP
.SS "\fCGRUB_BTRFS_IGNORE_PREFIX_PATH\fP"
.PP
@@ -132,8 +132,8 @@ 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
.IP \(em 4
Example: \fCGRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")\fP
.SS "\fCGRUB_BTRFS_IGNORE_SNAPSHOT_TYPE\fP"
.PP
@@ -144,16 +144,16 @@ For Timeshift:
Tag = boot, ondemand, hourly, daily, weekly, monthly.
.IP \(em 4
Default: (“”)
.PP
-Example: \fCGRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("ondemand")\fP
.IP \(em 4
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
.IP \(em 4
Example: \fCGRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION=("timeline")\fP
.SS "DISTRIBUTION DEPENDENT SETTINGS"
.SS "\fCGRUB_BTRFS_BOOT_DIRNAME\fP"
@@ -162,8 +162,8 @@ 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
.IP \(em 4
Example: \fCGRUB_BTRFS_BOOT_DIRNAME="/"\fP
.SS "\fCGRUB_BTRFS_GRUB_DIRNAME\fP"
.PP
@@ -173,8 +173,37 @@ Might be grub2 on some systems.
For example, on Fedora with EFI : “/boot/efi/EFI/fedora”
.IP \(em 4
Default: “/boot/grub”
.IP \(em 4
Example: \fCGRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"\fP
.SS "\fCGRUB_BTRFS_GBTRFS_DIRNAME\fP"
.PP
-Example: \fCGRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"\fP
Location where grub-btrfs.cfg should be saved.
Some distributions (like OpenSuSE) store those file at the snapshot directory
instead of boot. Be aware that this direcory must be available for grub during
startup of the system.
.IP \(em 4
Default: “/boot/grub”
.IP \(em 4
Example GRUB\d\s-2BTRFS\s+2\u\d\s-2GBTRFS\s+2\u\d\s-2DIRNAME\s+2\u=“/boot/grub”
.SS "\fCGRUB_BTRFS_GBTRFS_SEARCH_DIRNAME\fP"
.PP
Location of the directory where Grub searches for the grub-btrfs.cfg file.
Some distributions (like OpenSuSE) store those file at the snapshot directory
instead of boot. Be aware that this direcory must be available for grub during
startup of the system.
.IP \(em 4
Default: “\${prefix}” (This is a grub variable that resolves to where grub is
.PP
installed. (like /boot/grub, /boot/efi/grub))
.IP \(em 4
NOTE: If variables of grub are used here like ${prefix}, they need to be escaped
.PP
with `$\` before the `$`
.IP \(em 4
Example: GRUB\d\s-2BTRFS\s+2\u\d\s-2GBTRFS\s+2\u\d\s-2SEARCH\s+2\u\d\s-2DIRNAME\s+2\u=“\${prefix}”
.SS "\fCGRUB_BTRFS_MKCONFIG\fP"
.PP
@@ -184,8 +213,8 @@ Default paths are /sbin:/bin:/usr/sbin:/usr/bin, if your path is missing, report
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
.IP \(em 4
Example: \fCGRUB_BTRFS_MKCONFIG=/sbin/grub2\-mkconfig\fP
.SS "\fCGRUB_BTRFS_SCRIPT_CHECK\fP"
.PP

View File

@@ -35,12 +35,12 @@ Disable grub-btrfs if 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")~
- 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"~
- Example: ~GRUB_BTRFS_LIMIT="50"~
*** ~GRUB_BTRFS_SUBVOLUME_SORT~
Sort the found subvolumes by "ogeneration" or "generation" or "path" or "rootid".
@@ -50,12 +50,12 @@ Sort the found subvolumes by "ogeneration" or "generation" or "path" or "rootid"
#+END_MAN
"-rootid" means list snapshot by new ones first.
- Default: "-rootid"
-Example: ~GRUB_BTRFS_SUBVOLUME_SORT="+ogen,-gen,path,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"~
- Example: ~GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"~
*** ~GRUB_BTRFS_ROOTFLAGS~
Comma seperated mount options to be used when booting a snapshot.
@@ -64,14 +64,14 @@ They can be defined here as well as in the "/" line inside the respective snapsh
takes priority over `fstab` entries.
NB: Do NOT include "subvol=..." or "subvolid=..." here.
- Default: ""
-Example: ~GRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"~
- 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"~
- Example: ~GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="true"~
** CUSTOM KERNELS
@@ -79,7 +79,7 @@ Change to "true" if your boot partition is not detected as separate.
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")~
- 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")~
@@ -90,14 +90,14 @@ 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")~
- 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")~
- 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".
@@ -106,12 +106,12 @@ Type = single, pre, post.
For Timeshift:
Tag = boot, ondemand, hourly, daily, weekly, monthly.
- Default: ("")
-Example: ~GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("ondemand")~
- 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")~
- Example: ~GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION=("timeline")~
** DISTRIBUTION DEPENDENT SETTINGS
@@ -119,7 +119,7 @@ Ignore specific description of snapshot during run "grub-mkconfig".
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="/"~
- Example: ~GRUB_BTRFS_BOOT_DIRNAME="/"~
*** ~GRUB_BTRFS_GRUB_DIRNAME~
Location of the folder containing the "grub.cfg" file.
@@ -127,7 +127,27 @@ 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"~
- Example: ~GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"~
*** ~GRUB_BTRFS_GBTRFS_DIRNAME~
Location where grub-btrfs.cfg should be saved.
Some distributions (like OpenSuSE) store those file at the snapshot directory
instead of boot. Be aware that this direcory must be available for grub during
startup of the system.
- Default: "/boot/grub"
- Example GRUB_BTRFS_GBTRFS_DIRNAME="/boot/grub"
*** ~GRUB_BTRFS_GBTRFS_SEARCH_DIRNAME~
Location of the directory where Grub searches for the grub-btrfs.cfg file.
Some distributions (like OpenSuSE) store those file at the snapshot directory
instead of boot. Be aware that this direcory must be available for grub during
startup of the system.
- Default: "\${prefix}" (This is a grub variable that resolves to where grub is
installed. (like /boot/grub, /boot/efi/grub))
- NOTE: If variables of grub are used here like ${prefix}, they need to be escaped
with `\` before the `$`
- Example: GRUB_BTRFS_GBTRFS_SEARCH_DIRNAME="\${prefix}"
*** ~GRUB_BTRFS_MKCONFIG~
Name/path of the command to generate the grub menu, used by "grub-btrfs.service"
@@ -135,7 +155,7 @@ 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~
- Example: ~GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig~
*** ~GRUB_BTRFS_SCRIPT_CHECK~
Name of grub-script-check command, used by "grub-btrfs"

View File

@@ -9,7 +9,7 @@ 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] [\-v, \-\-verbose] SNAPSHOTS_DIR\fP
\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
@@ -38,6 +38,10 @@ Write to syslog
.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

View File

@@ -10,7 +10,7 @@ grub-btrfsd - An OpenRC daemon to automatically update the grub menu with
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] [-v, --verbose] SNAPSHOTS_DIR~
~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.
@@ -33,6 +33,9 @@ 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