Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added initramfs scripts for debian and derivatives #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renaudcerrato
Copy link

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

@JMarcosHP
Copy link

JMarcosHP commented Dec 18, 2024

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

@JMarcosHP
Copy link

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
Copy link

JMarcosHP commented Dec 18, 2024

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

@renaudcerrato
Copy link
Author

renaudcerrato commented Dec 18, 2024

Thanks for testing on Debian!

Using these scripts only a /var subvolume is required.

Could you elaborate on this?

@JMarcosHP
Copy link

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
Copy link

JMarcosHP commented Dec 18, 2024

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.

@renaudcerrato
Copy link
Author

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.

@JMarcosHP
Copy link

JMarcosHP commented Dec 18, 2024

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

@renaudcerrato
Copy link
Author

renaudcerrato commented Dec 19, 2024

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.

@@ -44,6 +44,18 @@ Distributions that use Dracut to make their initramfs (many of the Fedora based
Grub-btrfs provides the variable `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS` to add any command to the kernel command line. Set it to `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"` to make snapshots immutable when booted into.
After changing this run `sudo /etc/grub.d/41_snapshots-btrfs` to generate a new snapshot-submenu with the parameter added.

#### Debian based distros

1. Copy [grub-btrfs-overlayfs-hook](Debian/grub-btrfs-overlayfs-hook) script to initramfs-tools hooks directory:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make this available as an option for sudo make install? See the variables in the make file for OPENRC and SYSTEMD.

@Schievel1
Copy link
Collaborator

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.

@renaudcerrato
Copy link
Author

renaudcerrato commented Jan 6, 2025

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.

@Schievel1
Copy link
Collaborator

So this make #250 obsolete I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants