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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions initramfs/Debian/grub-btrfs-overlayfs-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

PREREQ=""

prereqs()
{
echo "$PREREQ"
}


case $1 in
prereqs)
prereqs
exit 0
;;
esac

. /scripts/functions

current_dev=$(resolve_device "${ROOT}")

if [[ $(blkid "${current_dev}" -s TYPE -o value) = "btrfs" ]] && [[ $(btrfs property get ${rootmnt} ro) != "ro=false" ]]; then # run only on a read only snapshot
lower_dir=$(mktemp -d -p /)
ram_dir=$(mktemp -d -p /)
mount --move ${rootmnt} ${lower_dir} # move new_root to lower_dir
mount -t tmpfs tmpfs ${ram_dir}
mkdir -p ${ram_dir}/upper
mkdir -p ${ram_dir}/work
mount -t overlay -o lowerdir=${lower_dir},upperdir=${ram_dir}/upper,workdir=${ram_dir}/work rootfs ${rootmnt}
fi

10 changes: 10 additions & 0 deletions initramfs/Debian/grub-btrfs-overlayfs-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

. /usr/share/initramfs-tools/hook-functions

manual_add_modules btrfs
manual_add_modules overlay
copy_exec $(which btrfs)
copy_exec $(which btrfsck)
copy_exec $(which blkid)

12 changes: 12 additions & 0 deletions initramfs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
`sudo cp grub-btrfs-overlayfs-hook /etc/initramfs-tools/hooks/`

2. Copy [grub-btrfs-overlayfs-boot](Debian/grub-btrfs-overlayfs-boot) script to initramfs-tools local-bottom scripts directory:
`sudo cp grub-btrfs-overlayfs-boot /etc/initramfs-tools/scripts/local-bottom/`

3. Update your initramfs
`sudo update-initramfs -u`


#### Other distribution
Refer to your distribution's documentation or contribute to this project to add a paragraph.
#