Skip to content

Commit 44dfbb0

Browse files
authored
Add more information for booting read-only snapshots on Dracut distros
Adapted from #399 (comment)
1 parent 5b56725 commit 44dfbb0

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

‎initramfs/readme.md‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,39 @@ Re-generate your initramfs
4040
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
4141

4242
#### Dracut based distros
43-
Distributions that use Dracut to make their initramfs (many of the Fedora based Distros) simply have to pass either `rd.live.overlay.readonly=1` (to boot into the snapshot read only) or `rd.live.overlay.overlayfs=1` (to act like a livedisk, that is files can be changed but changes will be lost on the next boot) to their kernel command line in grub.
44-
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.
43+
Distributions that use Dracut to make their initramfs (many of the Fedora based Distros) have to include the `overlayfs` module into the initramfs and pass either `rd.live.overlay.readonly=1` (to boot into the snapshot read only) or `rd.live.overlay.overlayfs=1` (to act like a livedisk, that is files can be changed but changes will be lost on the next boot) to their kernel command line in grub.
44+
45+
1. Include `overlayfs` module into dracut
46+
47+
```bash
48+
echo 'add_dracutmodules+=" overlayfs "' | sudo tee /etc/dracut.conf.d/overlayfs.conf
49+
```
50+
51+
2. Fix for dracut <109
52+
53+
Unfortunately, dracut version <109 has a bug that prevents overlayfs mount from properly working. [A fix has been commited into dracut version 109](https://github.com/dracut-ng/dracut-ng/commit/deeb670c28d12a478bbea95e29677e436d1912fb). If you are still on version < 109, instead of editing `/usr/lib/dracut/modules.d/70overlayfs/mount-overlayfs.sh` directly on your system, which will get overwritten on updates to the dracut package, we can duplicate the whole module with a lower priority number and carry out the patch there. As explained in this [very old notes about dracut](https://wwoods.fedorapeople.org/doc/dracut-notes.html):
54+
55+
> dracut refuses to overwrite files when installing things into the initramfs, so things installed by the the lower numbered modules have priority over the higher ones.
56+
57+
```bash
58+
sudo cp -r /usr/lib/dracut/modules.d/70overlayfs /usr/lib/dracut/modules.d/69overlayfs
59+
sudoedit /usr/lib/dracut/modules.d/69overlayfs/mount-overlayfs.sh
60+
```
61+
62+
Edit the file as per [the commit](https://github.com/dracut-ng/dracut/commit/deeb670c28d12a478bbea95e29677e436d1912fb)
63+
64+
3. Regenerate the initramfs
65+
66+
```
67+
# for current kernel's initramfs
68+
sudo dracut -f
69+
# for all kernels
70+
sudo dracut -f --regenerate-all
71+
```
72+
73+
4. Add kernel parameter and regenerate grub snapshot-submenu
74+
75+
Grub-btrfs provides the variable `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS` in `/etc/default/grub-btrfs/config` 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.
4576
After changing this run `sudo /etc/grub.d/41_snapshots-btrfs` to generate a new snapshot-submenu with the parameter added.
4677

4778
#### Other distribution

0 commit comments

Comments
 (0)