Antynea / grub-btrfs

Include btrfs snapshots at boot options. (Grub menu)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make "grub-mkconfig_lib" file path configurable

pandom79 opened this issue · comments

Hi,
I just updated grub-btrfs on my distro (openSUSE Tumbleweed).
I had two problems:

  1. It is not able to find "grub-script-check" which i resolved adding the configuration variable in the "config" file
  2. 41_snapshot-btrs is exiting on this line
    because on openSUSE (maybe also Fedora....maybe all Rpm based distros) have a different path, that is:
    "$datarootdir/grub2/grub-mkconfig_lib", not "$datarootdir/grub/grub-mkconfig_lib".

Maybe you should also add this as configuration variable
Regards

Hello,
Thank you for your feedback.

I need to improve the support for these distributions.
A lot of things seem broken.
I will take care of this soon.

Hello,
Can you try this #181 ?
You must specify the full path of the grub-mkconfig_lib file in the config file with the new variable GRUB_BTRFS_MKCONFIG_LIB.

On Fedora 35, the path is correct, and doesn't need to be changed to /usr/share/grub2/grub-mkconfig_lib.
I haven't tried it on other rpm based distros.

Hello, Can you try this #181 ? You must specify the full path of the grub-mkconfig_lib file in the config file with the new variable GRUB_BTRFS_MKCONFIG_LIB.

On Fedora 35, the path is correct, and doesn't need to be changed to /usr/share/grub2/grub-mkconfig_lib. I haven't tried it on other rpm based distros.

Ok, tomorrow I'll try it but I think that it should work well.

sorry, due to very job i forgot answer you. anyway, it works fine. Thanks

@pandom79 I'm also trying to make this work on openSUSE Tumbleweed. Could you actually get the snapshots to boot? This is what I'm getting:

Screenshot from 2021-11-20 18-00-42

Screenshot from 2021-11-20 17-59-54

From what I've read I gather that the subvol= part is a problem, so I tried removing it, but that gives a different error:

Screenshot from 2021-11-20 18-01-24

@Antynea any suggestions? Thanks a lot! Here's what my test system looks like:

sam@sam-virtualbox:~> cat /etc/fstab 
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /              btrfs   subvol=/@,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /home          btrfs   subvol=/@home,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /var/cache     btrfs   subvol=/@cache,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /var/log       btrfs   subvol=/@log,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0

sam@sam-virtualbox:~> sudo btrfs sub list /
ID 257 gen 158 top level 5 path @
ID 258 gen 158 top level 5 path @home
ID 259 gen 158 top level 5 path @cache
ID 260 gen 158 top level 5 path @log
ID 267 gen 149 top level 257 path .snapshots
ID 268 gen 105 top level 258 path @home/.snapshots
ID 269 gen 112 top level 267 path .snapshots/1/snapshot
ID 270 gen 113 top level 267 path .snapshots/2/snapshot
[...]
ID 286 gen 148 top level 267 path .snapshots/18/snapshot

@pandom79 I'm also trying to make this work on openSUSE Tumbleweed. Could you actually get the snapshots to boot? This is what I'm getting:

Screenshot from 2021-11-20 18-00-42

Screenshot from 2021-11-20 17-59-54

From what I've read I gather that the subvol= part is a problem, so I tried removing it, but that gives a different error:

Screenshot from 2021-11-20 18-01-24

@Antynea any suggestions? Thanks a lot! Here's what my test system looks like:

sam@sam-virtualbox:~> cat /etc/fstab 
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /              btrfs   subvol=/@,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /home          btrfs   subvol=/@home,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /var/cache     btrfs   subvol=/@cache,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0
UUID=1d9d72f6-8ef9-4440-a542-4ba1a279b8fb /var/log       btrfs   subvol=/@log,defaults,noatime,space_cache,autodefrag,compress=zstd 0 0

sam@sam-virtualbox:~> sudo btrfs sub list /
ID 257 gen 158 top level 5 path @
ID 258 gen 158 top level 5 path @home
ID 259 gen 158 top level 5 path @cache
ID 260 gen 158 top level 5 path @log
ID 267 gen 149 top level 257 path .snapshots
ID 268 gen 105 top level 258 path @home/.snapshots
ID 269 gen 112 top level 267 path .snapshots/1/snapshot
ID 270 gen 113 top level 267 path .snapshots/2/snapshot
[...]
ID 286 gen 148 top level 267 path .snapshots/18/snapshot

Actually, I am using a custom installation of Opensuse TW. (no installer)
I have done that only to understand if it can be installed via this method to have full installation control. (for educational purpose).
Anyway, when i have written that "grub-btrfs" works, actually, i mean that it can generate the grub snapshot entries but i didn't test them.
It doesn't work for me too.
I am able to boot up the snapshot, adding
initrd /initrd-5.15.2-1-default
which is missing, but, anyway, some systemd services can't start like auditd and then neither sddm etc etc.
Probably, opensuse has its own method to generate/boot up the snapshot via grub...I don't know.

I have this entry (like an example):

echo 'Loading Snapshot: 2021-11-20 19:00:11 @/.snapshots/979/snapshot'
        echo 'Loading Kernel: vmlinuz-5.15.2-1-default ...'
        linux "/vmlinuz-5.15.2-1-default" root=UUID=77134633-c108-4cf4-b32a-1e8abeb4fc76 splash=silent quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_level=3 mitigations=auto vt.global_cursor_default=0 resume=UUID=77134633-c108-4cf4-b32a-1e8abeb4fc76 resume_offset=1226572  rootflags=rw,relatime,ssd,space_cache,compress=zstd:3,defaults,subvol="@/.snapshots/979/snapshot"
    }

which has been changed so to allow boot up it:

echo 'Loading Snapshot: 2021-11-20 19:00:11 @/.snapshots/979/snapshot'
        echo 'Loading Kernel: vmlinuz-5.15.2-1-default ...'
        linux /vmlinuz-5.15.2-1-default root=UUID=77134633-c108-4cf4-b32a-1e8abeb4fc76 splash=silent quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_level=3 mitigations=auto vt.global_cursor_default=0 resume=UUID=77134633-c108-4cf4-b32a-1e8abeb4fc76 resume_offset=1226572  rootflags=subvol=@/.snapshots/979/snapshot
        initrd /initrd-5.15.2-1-default 
    }

Removing some double quotes and writing correctly rootflags, i can boot up the snapshot.
Sddm can't start but if i run "startplasma-wayland or x11" at the prompt...i am able to start kde and to browser the file system

Well, i have a classic opensuse installation in virt manager and i can confirm that the grub snapshot entries are generate by Yast.
As supposed, there is a different management, this is an example:

if [ -f "/.snapshots/4/snapshot/boot/grub2/grub.cfg" ]; then
    snapshot_found=true
    saved_subvol=$btrfs_subvol
    menuentry  " openSUSE Tumbleweed  (5.14.14-1,2021-10-31T16:14,post,zypp(zypper))" "/.snapshots/4/snapshot" "/@/.snapshots/4/snapshot" {
        btrfs_subvol="$3"
        extra_cmdline="rootflags=subvol=$3"
        export extra_cmdline
        snapshot_num=4
        export snapshot_num
        configfile "$2/boot/grub2/grub.cfg"
        btrfs_subvol=$saved_subvol
      }
fi

Hi @pandom79 , thanks a lot for your very helpful reply.

Yes, mine is also a custom installation of openSUSE with Calamares and a Snapper config that I created:
snapper -c root create-config /
snapper -c home create-config /home

So it looks like the issue with grub-btrfs is that it's not finding the initrd. I imagine a new bug report should be opened for that? Even if a limited snapshot environment could be booted that would be helpful for running the snapper rollback command.

As for vanilla openSUSE, yes, the YaST installer creates the snapper configurations, and it also includes a package called grub2-snapper-plugin that adds the file /etc/grub.d/80_suse_btrfs_snapshot to generate those GRUB menus.

Hi @pandom79 , thanks a lot for your very helpful reply.

Yes, mine is also a custom installation of openSUSE with Calamares and a Snapper config that I created: snapper -c root create-config / snapper -c home create-config /home

So it looks like the issue with grub-btrfs is that it's not finding the initrd. I imagine a new bug report should be opened for that? Even if a limited snapshot environment could be booted that would be helpful for running the snapper rollback command.

As for vanilla openSUSE, yes, the YaST installer creates the snapper configurations, and it also includes a package called grub2-snapper-plugin that adds the file /etc/grub.d/80_suse_btrfs_snapshot to generate those GRUB menus.

Actually, I also have grub2-snapper-plugin package, but i only use it only for rollback which set the default subvol because i use efistub.
/etc/grub.d/80_suse_btrfs_snapshot can't generate the entries because each snapshot should contain grub-snapshot.cfg file which is created by Yast.
We don't use yast and then it cannot works.
Now, about grub-btrfs, I tried to examine the cmdline when the snapshot boots up on the classic opensuse installation and the parameters are identical. I don't understand because it can't correctly start in our case. Sddm and other services fail...I must manually start plasma.
Sure, grub-btrfs doesn't correctly generate the cmdline...but, I'm wondering: "even if it correctly generates the cmdline, will be enough?". I don't know if this is a bug or grub-btrfs should exclude Opensuse from its supports.

hello,

@Antynea any suggestions? Thanks a lot! Here's what my test system looks like:

Your screenshots indicate that no init{rd,ramfs} was found:
Kernel panic - not syncing: VFS: Unable to mount root fs....(0,0)

@pandom79 indicates that the official initrd name for OpenSUSE is: initrd-5.15.2-1-default
So already I have problems with this distribution which allows some freedom...

  • Rename Grub to Grub2, ok I adapt ...
  • Use a file name without extension for an initrd, I want to adapt, but there are limits to the bullshit ...

So the solution is simple, grub-btrfs, does not support this file naming convention.
Should I make this kind of behavior compatible? I dont know ...

even if it correctly generates the cmdline, will be enough?

No, you boot into a snapshot in read-only mode.
There is work in progress for this.

@pandom79 indicates that the official initrd name for OpenSUSE is: initrd-5.15.2-1-default So already I have problems with this distribution which allows some freedom...

So the solution is simple, grub-btrfs, does not support this file naming convention. Should I make this kind of behavior compatible? I dont know ...

As you prefer, the important is that we have understood the reasons.

@Antynea

Use a file name without extension for an initrd

Hmm sorry I didn't quite get this, do you mean that the -default part is confusing the script?

As you prefer, the important is that we have understood the reasons.

The init list detected by grub-btrfs is no longer up-to-date with the Grub list.
By resynchronising the list, the problem should be solved.

let's open a new issue.

let's open a new issue.

Want me to create it? Or @pandom79 ? Thanks a lot, appreciate your time.

@Antynea Thanks! :)

@geckolinux, you :)

Done!
#183