GRUB strangeness with snapshot, please give me your opinion

Hi,

I had some difficulties this after afternoon with GRUB and my BTRFS filesystem. I explain my situation:

I wanted to restore a snapshot taken 5 days ago (taken the march 15th). I did it with Timeshift. So far, that’s ok.
Then i installed Pinta and a color picker and i took a new snapshot this afternoon.
The problem began when i rebooted my computer and checked if the new snapshot appears within grub menu.
I realized the new snapshot is not there whereas i updated grub with sudo update-grub

I had a look to both files /boot/grub/grub.cfg and /boot/grub/grub-btrfs.cfg

/boot/grub/grub-btrfs.cfg was OK, meaning the submenu section with the new snapshot is present.
/boot/grub/grub.cfg was refering to the snapshot taken on march 15th, i mean instead of having

linux /@/boot/vmlinuz-5.15-x86_64 root=UUID=70853cef-788d-4beb-9c26-56f4fd32adc2 rw rootflags=subvol=@ quiet udev.log_priority=3

initrd /@/boot/intel-ucode.img /@/boot/initramfs-5.15-x86_64.img

i had

linux /run/timeshift/backup/timeshift-btrfs/snapshots/2022-03-15_21-11-35/@/boot/vmlinuz-5.15-x86_64 root=UUID=70853cef-788d-4beb-9c26-56f4fd32adc2 rw rootflags=subvol=@ quiet udev.log_priority=3

initrd /run/timeshift/backup/timeshift-btrfs/snapshots/2022-03-15_21-11-35/@/boot/intel-ucode.img /@/boot/initramfs-5.15-x86_64.img

It means that even if the file /boot/grub/grub-btrfs.cfg was up to date, the one used by grub was not this one but the older one, from the snapshot taken 5 days ago, thus, without the new entry with the new snapshot.

So, i modified manually /boot/grub/grub.cfg then sudo update-grub but it does not change anything in my grub menu.

The only solution i found was to reboot my computer, press [E] to Edit the selection and made the modifications here to replace each occurence of

/run/timeshift/backup/timeshift-btrfs/snapshots/2022-03-15_21-11-35/@/

by

/@/

Then, right after boot, i updated grub, and now everything is fine.

This is weird to me that the only solution was to edit grub (not grub.cfg) but grub menu before my computer starts.

Do you know if another solution would have been possible ?

Many thanks

There are 2 possible mechanissms for grub to find its configfile:

A) mount the subvolume @

B) mount the default subvolume defined by btrfs subvolume set-default

I do not know which one grub uses :man_shrugging:

btrfs subvolume set-default -h                                                                                                         [130]
usage: btrfs subvolume set-default <subvolume>
       btrfs subvolume set-default <subvolid> <path>

    Set the default subvolume of the filesystem mounted as default.

    The subvolume can be specified by its path,
    or the pair of subvolume id and path to the filesystem.

Every time i do a manual rollback, i do

  • replace the subvolume @
    and
  • set it as new default-subvolume

You find good Information about Btrfs in the wiki

https://wiki.manjaro.org/index.php/Btrfs

and in

https://forum.manjaro.org/t/how-to-manual-rollback-with-btrfs/80230/5

https://forum.manjaro.org/t/how-to-rescue-data-from-a-damaged-btrfs-volume/79414/4

1 Like

Thanks for your answer @andreas85.

Basically, what i did to restore my older snapshot was :

  • Restore this older snapshot with Timeshift.
  • Then update-grub

I guess this is not the right way to do it, but to be honest, i do not know exactly what does Timeshift actually do.

Look, i checked right know my default-subvolume :

$ sudo btrfs subvolume get-default /
$ ID 5 (FS_TREE)

i did not modified it, i guess, the right subvolume is mounted at boot because it’s specified in my fstab (i did not touch my fstab either):

UUID=xxx-xxx-xxx / btrfs subvol=/@,…

In that case, btrfs wiki says i should not have to set-default.

What is stranged to me is that, before to fix my isse by editing grub in the boot menu, i was in a situation where:

  • The right subvolume (snapshot) was mounted at boot because i guess Timeshift copied the old snapshot in @ when i restored it (and moved @ in another snapshot).

  • BUT, grub.cfg didn’t want to take into consideration and kept using
    /run/timeshift/backup/timeshift-btrfs/snapshots/2022-03-15_21-11-35/@/ instead of /@/

So, to sum up, what i should do if i want to rollback to a older snapshot would be, instead of using Timeshift :

  • Take a snapshot of @ to @/timestamp/backup
  • mv @/the_snapshot_i_want_to_restore/ to /@/
  • sudo btrfs subvolume set-default BUT to what ? @ or ID ?
  1. sudo btrfs subvolume set-default @
  2. sudo btrfs subvolume set-default <ID>
  3. sudo btrfs subvolume set-default <ID> /

Which are the good answer ?

Basically ? How do you do that because, i guess i have to do some mount and umount operations somehow.
Do you use a live iso to do this or do you do all these operations on your current system ?

I read btrfs wiki and the posts you pointed me but, there is still some misunderstandings, i am sorry for that.

Many thanks

Btrfs is not easy, because it is so different.
But it is so good because it is so different

I think this is the one i used

This seems crazy, but i did most of it in my running system.

  • You have btrfs /@ (or another snapshot you booted with) mounted to / in your running system
  • Then mount btrfs-root (/) to /mnt/ROOT
    After that you can see into btrfs (for example with mc) and watch what happens when you use btrfs-commands

This is the way i learned to become familiar with btrfs layouts, subvolumes, snapshots and so on. Because i can see it there what happens in /mnt/ROOT/… immediately.

2 Likes

There’s a reason I prefer to name subvolumes with @, and I think others do so for similar reasons.

Many people get confused when thinking about Btrfs volume root (/) and filesystem root (/).

And this gets even worse when btrfs-subvolume-home (/home) and filesystem-home (/home) also have the same name and thus the name of the subvolume is exactly the same as the name of the mount point. :rofl:

So if we use @, this becomes a bit more clear to everyone.
In our case Btrfs-volume-root is not mounted (so no problem having to explain that / is a btrfs-volume and not the same as the filesystem-root /) :wink:

Btrfs-subvolume @home (or /@home) is mounted on filesystem-home /home
This makes it easy to understand that @home is the subvolume and /home is the mount point.

The same applies to all other subvolumes if you use @ in the name there.

:innocent:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.