diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 07c57ed..990c849 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -121,7 +121,7 @@ boot_hs=$(${grub_probe} --device ${boot_device} --target="hints_string" 2>/dev/n boot_fs=$(${grub_probe} --device ${boot_device} --target="fs" 2>/dev/null) # Type filesystem of boot device ## Parameters passed to the kernel -kernel_parameters="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT" +kernel_parameters="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT $GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS" ## Mount point location grub_btrfs_mount_point=$(mktemp -dt grub-btrfs.XXXXXXXXXX) ## Class for theme diff --git a/config b/config index 9432a81..7084a44 100644 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -GRUB_BTRFS_VERSION=4.12-improve-config-2022-12-05T20:15:10+00:00 +GRUB_BTRFS_VERSION=4.12-improve-config-2022-12-06T21:56:44+00:00 # Disable grub-btrfs. # Default: "false" @@ -48,6 +48,13 @@ GRUB_BTRFS_VERSION=4.12-improve-config-2022-12-05T20:15:10+00:00 # Default: ("") #GRUB_BTRFS_CUSTOM_MICROCODE=("custom-ucode.img" "custom-uc.img "custom_ucode.cpio") +# Additonal kernel command line parameters that should be passed to the kernel +# when booting a snapshot. +# For dracut based distros this could be useful to pass "rd.live.overlay.overlayfs=1" +# or "rd.live.overlay.readonly=1" to the Kernel for booting snapshots read only. +# Default: "" +#GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1" + # Comma seperated mount options to be used when booting a snapshot. # They can be defined here as well as in the "/" line inside the respective snapshots' # "/etc/fstab" files. Mount options found in both places are combined, and this variable diff --git a/initramfs/readme.md b/initramfs/readme.md index cefe56c..233f667 100644 --- a/initramfs/readme.md +++ b/initramfs/readme.md @@ -39,7 +39,11 @@ You notice that the name of the `hook` must match the name of the 2 installed fi Re-generate your initramfs `mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`) +#### Dracut based distros +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. +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. + #### Other distribution -Refer to your distribution's documentation -or contribute to this project to add a paragraph. +Refer to your distribution's documentation or contribute to this project to add a paragraph. # diff --git a/manpages/grub-btrfs.8.man b/manpages/grub-btrfs.8.man index 8a522ec..cc65311 100644 --- a/manpages/grub-btrfs.8.man +++ b/manpages/grub-btrfs.8.man @@ -1,4 +1,4 @@ -.TH "grub-btrfs" "1" +.TH "grub-btrfs" "8" .SH "NAME" .PP @@ -114,6 +114,17 @@ Example: \fCGRUB_BTRFS_NKERNEL=("kernel\-5.19.4\-custom" "vmlinux\-5.19.4\-custo \fCGRUB_BTRFS_NINIT=("initramfs\-5.19.4\-custom.img" "initrd\-5.19.4\-custom.img" "otherinit\-5.19.4\-custom.gz")\fP \fCGRUB_BTRFS_CUSTOM_MICROCODE=("custom\-ucode.img" "custom\-uc.img "custom_ucode.cpio")\fP +.SS "\fCGRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS\fP" +.PP +Additonal kernel command line parameters that should be passed to the kernelwhen +booting a snapshot. +For dracut based distros this could be useful to pass “rd.live.overlay.overlayfs=1” +or “rd.live.overlay.readonly=1” to the Kernel for booting read only snapshots. +.IP \(em 4 +Default: “” +.IP \(em 4 +Example: \fCGRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"\fP + .SS "SNAPSHOT FILTERING" .SS "\fCGRUB_BTRFS_IGNORE_SPECIFIC_PATH\fP" .PP @@ -168,7 +179,6 @@ Example: \fCGRUB_BTRFS_BOOT_DIRNAME="/"\fP .SS "\fCGRUB_BTRFS_GRUB_DIRNAME\fP" .PP Location of the folder containing the “grub.cfg” file. -Used by grub-btrfs to save the file “grub-btrfs.cfg”. Might be grub2 on some systems. For example, on Fedora with EFI : “/boot/efi/EFI/fedora” .IP \(em 4 @@ -183,9 +193,13 @@ Some distributions (like OpenSuSE) store those file at the snapshot directory instead of boot. Be aware that this direcory must be available for grub during startup of the system. .IP \(em 4 -Default: “/boot/grub” +Default: $GRUB\d\s-2BTRFS\s+2\u\d\s-2GRUB\s+2\u\d\s-2DIRNAME\s+2\u .IP \(em 4 +<<<<<<< HEAD Example: \fCGRUB_BTRFS_GBTRFS_DIRNAME="/.snapshots"\fP +======= +Example \fCGRUB_BTRFS_GBTRFS_DIRNAME="/boot/grub2"\fP +>>>>>>> e76cdc4 (grub-btrfs: add custom kernel parameters option for snapshots) .SS "\fCGRUB_BTRFS_GBTRFS_SEARCH_DIRNAME\fP" .PP @@ -204,7 +218,6 @@ with `$\` before the `$` .IP \(em 4 Example: GRUB\d\s-2BTRFS\s+2\u\d\s-2GBTRFS\s+2\u\d\s-2SEARCH\s+2\u\d\s-2DIRNAME\s+2\u=“\${prefix}” - .SS "\fCGRUB_BTRFS_MKCONFIG\fP" .PP Name/path of the command to generate the grub menu, used by “grub-btrfs.service” diff --git a/manpages/grub-btrfs.8.org b/manpages/grub-btrfs.8.org index 9eb21a2..a4d5910 100644 --- a/manpages/grub-btrfs.8.org +++ b/manpages/grub-btrfs.8.org @@ -83,6 +83,14 @@ Customs kernel, initramfs and microcodes that are not detected can be added in t ~GRUB_BTRFS_NINIT=("initramfs-5.19.4-custom.img" "initrd-5.19.4-custom.img" "otherinit-5.19.4-custom.gz")~ ~GRUB_BTRFS_CUSTOM_MICROCODE=("custom-ucode.img" "custom-uc.img "custom_ucode.cpio")~ +*** ~GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS~ +Additonal kernel command line parameters that should be passed to the kernelwhen +booting a snapshot. +For dracut based distros this could be useful to pass "rd.live.overlay.overlayfs=1" +or "rd.live.overlay.readonly=1" to the Kernel for booting read only snapshots. +- Default: "" +- Example: ~GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"~ + ** SNAPSHOT FILTERING *** ~GRUB_BTRFS_IGNORE_SPECIFIC_PATH~