grub-btrfs icon indicating copy to clipboard operation
grub-btrfs copied to clipboard

added initramfs scripts for debian and derivatives

Open renaudcerrato opened this issue 1 year ago • 12 comments

Just added scripts and instructions for initramfs for Ubuntu (and possibly any debian alternatives ?)

renaudcerrato avatar Dec 02 '24 16:12 renaudcerrato

+1 for this, we need support for debian distributions. @Schievel1

JMarcosHP avatar Dec 18 '24 00:12 JMarcosHP

Tested on Debian 12 with /var/log subvolume and Kde desktop, it works as expected. Can boot and use the desktop environment on a read-only snapper snapshot.

JMarcosHP avatar Dec 18 '24 06:12 JMarcosHP

Using these scripts only a /var subvolume is required.

But, I have an Opensuse btrfs subvolume style installation:

@root
@opt
@srv
@usr-local
@var
@snapshots

JMarcosHP avatar Dec 18 '24 06:12 JMarcosHP

Thanks for testing on Debian!

Using these scripts only a /var subvolume is required.

Could you elaborate on this?

renaudcerrato avatar Dec 18 '24 06:12 renaudcerrato

Could you elaborate on this?

Yes, I mean... I just followed the instructions of the main readme of this repository:

If you wish to use read-only snapshots, /var/log or even /var must be on a separate subvolume. Otherwise, make sure your snapshots are writable.

These scripts for initramfs works well, If I boot a snapshot from the grub menu and then I install a package using apt, these changes takes no effect after reboot, avoiding dpkg database inconsistencies or broken /var. Everything works like in Opensuse.

JMarcosHP avatar Dec 18 '24 19:12 JMarcosHP

So, using these scripts, there is no need to create additional subvolumes like /var/log, /var/lib/AccountsService and /var/lib/gdm3 to boot from snapshots, just create a /var subvolume like in opensuse.

JMarcosHP avatar Dec 18 '24 19:12 JMarcosHP

Those scripts will detect if the root partition is a read-only btrfs partition, and if so will add overlayfs on top of it using temporary (tmpfs) storage under the hood. Your snapshot won't be modified, but you'll still be able to boot.

If you have any other partitions declared under /etc/fstab, they'll be mounted as read/write AFAIK.

renaudcerrato avatar Dec 18 '24 20:12 renaudcerrato

I see, I encountered an issue. I installed that package on a snapshot, then I reboot and booted to the main subvolume entry, and when I try to execute the package it says is not found but apt says it is installed, what?

Captura desde 2024-12-18 15-12-33

Captura desde 2024-12-18 15-12-51

JMarcosHP avatar Dec 18 '24 21:12 JMarcosHP

I installed that package on a snapshot

What do you mean? If you booted into a (read-only) snapshot, then you can't install anything in a persistent manner. The snapshot is read-only, any changes will disappear after reboot.

apt says it is installed, what?

apt stores its database in /var. Since you told me that you have a /var subvolume, that volume was mounted and write enabled when you ran your apt-get.

grub-btrfs entries are (read-only) snapshots of @root AFAIK : anything else in /etc/fstab will be mounted as is.

Your @var and @root subvolumes are now inconsistent. In regard to your layout, you should avoid to run any command that will write to the other subvolumes while booted into a snapshot of @root.

My layout consists only of @root and @home to avoid that kind of issue : when booting from a snapshot, any changes will be non persistent, excepted under /home which is rather safe.

renaudcerrato avatar Dec 19 '24 06:12 renaudcerrato

Before merging this I need some Debian guys to test this properly. Also there should be someone to stick around to maintain those scripts if there is maintenance needed. I am not using a Debian based distro so I can not test it.

Also does this work on Ubuntu as well? Because there is also #250.

Schievel1 avatar Jan 06 '25 07:01 Schievel1

In fact, I only tested on Ubuntu as that's what I'm using, but I'm fairly confident it works exactly the same on Debian. Need some Debian testers.

renaudcerrato avatar Jan 06 '25 07:01 renaudcerrato

So this make #250 obsolete I guess.

Schievel1 avatar Jan 06 '25 09:01 Schievel1

You can write in the documentation that the user needs to add executable permissions to both scripts.

sudo chmod +x grub-btrfs-overlayfs-boot
sudo chmod +x grub-btrfs-overlayfs-hook

And it'll show you this message when starting up, but it can still get into the system from the snapshot. The file system of root directory has also been changed to overlayfs. So can we just ignore this error?

[    1.882274] systemd[1]: systemd-remount-fs.service: Main process exited, code=exited, status=1/FAILURE
[    1.882382] systemd[1]: systemd-remount-fs.service: Failed with result 'exit-code'.
[    1.882562] systemd[1]: Failed to start systemd-remount-fs.service - Remount Root and Kernel File Systems.

GrandDuke1106 avatar Aug 14 '25 15:08 GrandDuke1106

I have tested the scripts with Debian 13. The overlayfs is applied as expected. Cool, thanks for your work!

BUT: snapper rollback does not work any more when booted into the snapshot ("subvolume is not a btrfs subvolume). Too bad for me as I wanted to use grub-btrfs together with snapper. If I don't overlook something I think I have to go back to writable snapshots.

unonweb avatar Oct 27 '25 12:10 unonweb

BUT: snapper rollback does not work any more when booted into the snapshot ("subvolume is not a btrfs subvolume). Too bad for me as I wanted to use grub-btrfs together with snapper. If I don't overlook something I think I have to go back to writable snapshots.

You can use yabsnap, which can correctly roll back in read-only snapshots by passing parameters. This feature was added just yesterday.

GrandDuke1106 avatar Oct 30 '25 15:10 GrandDuke1106