[HOWTO] edit: obsolete workaround to a problem with grub-btrfs

Also, this is the snapshot location for snapper.

I tried the " Timeshift >= version 22.06" instructions first:

sudo systemctl edit --full grub-btrfsd

[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

sudo systemctl restart grub-btrfsd

And then testing, snapshotting, rebooting, a few times. Same result, didnā€™t work.

Is this something?

systemctl status grub-btrfs:

[vlad@endeavouros ~]$ systemctl status grub-btrfs
Unit grub-btrfs.service could not be found.
[vlad@endeavouros ~]$

I then retried the steps

sudo systemctl start grub-btrfsd
sudo systemctl enable grub-btrfsd

And then again
systemctl status grub-btrfs

which again gives the output

[vlad@endeavouros ~]$ systemctl status grub-btrfs
Unit grub-btrfs.service could not be found.
[vlad@endeavouros ~]$

Oh I forgot it was a daemon:

ps -ef | grep grub.btrfs

gives the output

[vlad@endeavouros ~]$ ps -ef | grep grub.btrfs
vlad        2174    2087  0 15:31 pts/0    00:00:00 grep grub.btrfs
[vlad@endeavouros ~]$

There is a typo. Should be: grub-btrfsd

Could you try the manual way of creating entries for the snapshots as described in the instructions from Github?

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

systemctl status grub-btrfsd
[vlad@endeavouros ~]$ systemctl status grub-btrfsd
Ɨ grub-btrfsd.service - Regenerate grub-btrfs.cfg
     Loaded: loaded (/etc/systemd/system/grub-btrfsd.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2023-01-03 15:21:56 CET; 12min ago
   Duration: 25ms
   Main PID: 2101 (code=exited, status=1/FAILURE)
        CPU: 22ms

jan. 03 15:21:56 endeavouros grub-btrfsd[2102]: [!] inotifywait was not found, exiting. Is inotify-tools inst>
jan. 03 15:21:56 endeavouros systemd[1]: grub-btrfsd.service: Main process exited, code=exited, status=1/FAIL>
jan. 03 15:21:56 endeavouros systemd[1]: grub-btrfsd.service: Failed with result 'exit-code'.
lines 1-10/10 (END)

Install inotify-tools and try restarting the daemon.

OK, i tried

sudo /etc/grub.d/41_snapshots-btrfs

Then deleted all my snapshots, and created a single one ā€˜test1ā€™.

then rebooted to grub, it still shows the same handful snapshots I had from last i rebuilt it manually.

Try this.

Also, I think

should be run after you create a new snaphot.

Yes, this was the step suggested by the IT professor I linked to earlier. I tried it then, and it didnā€™t work for me. Iā€™d prefer a ā€œnativeā€ solution anyway.

Iā€™ll try again:


sudo pacman -S inotify-tools

sudo systemctl restart grub-btrfsd

Created another snapshot ā€˜test2ā€™, rebooted. Same results, also when creating new snapshots and rebooting again. Same old non-existent snapshots show up in grub, it has not been rebuilt.

After installing inotify-tools and restarting the daemon, could you post again:

systemctl status grub-btrfsd

?

[vlad@endeavouros ~]$ systemctl status grub-btrfsd
ā— grub-btrfsd.service - Regenerate grub-btrfs.cfg
     Loaded: loaded (/etc/systemd/system/grub-btrfsd.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-01-03 15:45:09 CET; 4min 21s ago
   Main PID: 502 (grub-btrfsd)
      Tasks: 2 (limit: 4532)
     Memory: 3.0M
        CPU: 24ms
     CGroup: /system.slice/grub-btrfsd.service
             ā”œā”€502 /bin/sh /usr/bin/grub-btrfsd --syslog --timeshift-auto
             ā””ā”€609 inotifywait -q -q -e create -e delete /run/timeshift

jan. 03 15:45:10 endeavouros grub-btrfsd[608]: Watching /run/timeshift for timeshift to start
[vlad@endeavouros ~]$

At least it is running now.

Donā€™t really know why it wonā€™t add the snapshotā€™s boot entries to grub?

Now that the daemon is running, as a last test, could you delete each and all snapshots, create a new one and then post your grub-btrfs.cfg?

Edit: correction grub.cfg >> grub-btrfs.cfg

You mean like this?

[vlad@endeavouros ~]$ systemctl cat grub-btrfsd
# /etc/systemd/system/grub-btrfsd.service
[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
[vlad@endeavouros ~]$

Since I am not using grub-btrfs so I am guessing that the file might be in /boot/grub or thereabout :blush:

OK, grub-btrfs.cfg in /boot/grub:

menuentry '|         Date        |                     Snapshot                    |     Type     |Description|' { echo }
submenu '| 2023-01-03 16:00:01 | timeshift-btrfs/snapshots/2023-01-03_16-00-01/@ | daily weekly | N/A       |' {
    submenu '| 2023-01-03 16:00:01 | timeshift-btrfs/snapshots/2023-01-03_16-00-01/@ | daily weekly | N/A |' { echo }

    menuentry '  vmlinuz-linux & initramfs-linux-fallback.img & intel-ucode.img' --class snapshots --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-snapshots-7f6441da-512e-46ad-8c4e-9837a70421a6' {
        if [ x$feature_all_video_module = xy ]; then
        insmod all_video
        fi
        set gfxpayload=keep
        insmod btrfs
        if [ x$feature_platform_search_hint = xy ]; then
            search --no-floppy --fs-uuid  --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  7f6441da-512e-46ad-8c4e-9837a70421a6
        else
            search --no-floppy --fs-uuid  --set=root 7f6441da-512e-46ad-8c4e-9837a70421a6
        fi
        echo 'Loading Snapshot: 2023-01-03 16:00:01 timeshift-btrfs/snapshots/2023-01-03_16-00-01/@'
        echo 'Loading Kernel: vmlinuz-linux ...'
        linux "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/vmlinuz-linux" root=UUID=7f6441da-512e-46ad-8c4e-9837a70421a6  nowatchdog nvme_load=YES loglevel=3 rootflags=defaults,noatime,compress=zstd,subvol="timeshift-btrfs/snapshots/2023-01-03_16-00-01/@"
        echo 'Loading Microcode & Initramfs: intel-ucode.img initramfs-linux-fallback.img ...'
        initrd "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/intel-ucode.img" "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/initramfs-linux-fallback.img"
    }

    menuentry '  vmlinuz-linux & initramfs-linux.img & intel-ucode.img' --class snapshots --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-snapshots-7f6441da-512e-46ad-8c4e-9837a70421a6' {
        if [ x$feature_all_video_module = xy ]; then
        insmod all_video
        fi
        set gfxpayload=keep
        insmod btrfs
        if [ x$feature_platform_search_hint = xy ]; then
            search --no-floppy --fs-uuid  --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  7f6441da-512e-46ad-8c4e-9837a70421a6
        else
            search --no-floppy --fs-uuid  --set=root 7f6441da-512e-46ad-8c4e-9837a70421a6
        fi
        echo 'Loading Snapshot: 2023-01-03 16:00:01 timeshift-btrfs/snapshots/2023-01-03_16-00-01/@'
        echo 'Loading Kernel: vmlinuz-linux ...'
        linux "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/vmlinuz-linux" root=UUID=7f6441da-512e-46ad-8c4e-9837a70421a6  nowatchdog nvme_load=YES loglevel=3 rootflags=defaults,noatime,compress=zstd,subvol="timeshift-btrfs/snapshots/2023-01-03_16-00-01/@"
        echo 'Loading Microcode & Initramfs: intel-ucode.img initramfs-linux.img ...'
        initrd "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/intel-ucode.img" "/timeshift-btrfs/snapshots/2023-01-03_16-00-01/@/boot/initramfs-linux.img"
    }
}

Looks like the snapshot:

has been added. Or am I mistaken?

Unfortunately I donā€™t have a similar setup to troubleshoot/investigate it further :slightly_frowning_face:

1 Like

It is working!

I deleted all snapshots and rebooted. Then I created 10 new ones, booted to grub and they showed up! Then I deleted all those and created one new, booted to grub and only this new one shows.

Thanks!

I followed those instructions earlier, from the professor blog, but they wouldnā€™t work. I was tired though. It could have been as simple as that Iā€™d lost track of testing and changes and forgotten to point it from the snapper directory to the timehift directory with

sudo systemctl edit --full grub-btrfsd

OK, so now it is working. What Iā€™m wondering is: it seems that grub-btrfs in its current state isnā€™t working as intended. This will probably be fixed and updated. How will this affect me when I update, when Iā€™ve incorporated inotify-tools?

And now this ā€œhowtoā€ is irrelevant. It should in any case have been titled ā€œWorkaroundā€.
Iā€™ll edit it to reflect this

The only ā€œissueā€ that I could spot is that inotify-tools is specified as optional dependency.

$ pacman -Si grub-btrfs
Repository : community
Name : grub-btrfs
Version : 4.12-2
Description : Include btrfs snapshots in GRUB boot options
Architecture : any
URL : https://github.com/Antynea/grub-btrfs
Licenses : GPL3
Groups : None
Provides : None
Depends On : btrfs-progs grub
Optional Deps : snapper: For snapper support
inotify-tools: For grub-btrfsd daemon

Since starting grub-btrfsd fails because of it not being installed, I think it should be specified as grub-btrfsā€™ dependency.

Perhaps you might want to report it to the developer?

1 Like