diff --git a/README.md b/README.md index 92d07a3..7c13ea6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ I use this for my Raspberry Pi, but it should work on any Debian or derivative. The root file system on the sd-card is mounted read-only on /overlay/lower, and / is a read-write copy on write overlay. +There are two sets of instructions below: [Raspbian](#raspbian) and [Ubuntu for ARM](#ubuntu-for-arm). + +## Raspbian + It uses initramfs. Stock Raspbian doesn't use one so step one would be to get initramfs working. Something like: @@ -39,6 +43,33 @@ then rerun ```bash sudo mkinitramfs -o /boot/init.gz ``` +Now skip down to [all distributions](#all-distributions) to finish the installation. + +## Ubuntu for ARM + +Add the following line to /etc/initramfs-tools/modules +``` +overlay +``` + +Copy the following files +- hooks-overlay to /etc/initramfs-tools/hooks/ +- init-bottom-overlay to /etc/initramfs-tools/scripts/init-bottom/ + +install busybox-static +```bash +sudo apt-get install busybox-static +``` + +then run + +```bash +sudo update-initramfs -k $(uname -r) -u +``` + +Now continue to [all distributions](#all-distributions) to finish the installation. + +## all distributions add to .bashrc @@ -72,12 +103,18 @@ It's probably a good idea to reboot now for 2 reasons: - leaving /overlay/lower read-write could cause file corruption on power loss. - to test it still boots ok after the changes you've just made. -Whenever the kernel is updated you need to rerun +Whenever the kernel is updated, for Raspbian you need to rerun ```bash sudo mkinitramfs -o /boot/init.gz ``` +and for Ubuntu for ARM + +```bash +sudo update-initramfs -k $(uname -r) -u +``` + TODO: see if there's a hook to automatically run `sudo mkinitramfs -o /boot/init.gz` on kernel install diff --git a/rootwork b/rootwork index add1e04..9d7850d 100755 --- a/rootwork +++ b/rootwork @@ -56,11 +56,13 @@ test_mountpoints () { } mount -o remount,rw "$ROOT" || { echo "error remounting $ROOT rw"; exit 1; } -if is_mounted /boot; then - mount -o remount,rw /boot || { echo "error remounting /boot rw"; exit 1; } -fi +for DIR in boot boot/firmware; do + if is_mounted "/$DIR"; then + mount -o remount,rw "/$DIR" || { echo "error remounting \"/$DIR\" rw"; exit 1; } + fi +done -for DIR in boot run; do +for DIR in boot boot/firmware run; do if test_mountpoints "/$DIR" "$ROOT/$DIR"; then mount --rbind "/$DIR" "$ROOT/$DIR" fi @@ -90,15 +92,17 @@ fi # with mount --rbind /run $ROOT/run, umounting $ROOT/run is problematic as it's busy and if you umount -lf it umounts directories in /run/. # I think because / is an overlay of $ROOT. So we don't unmount $ROOT/run -for DIR in boot; do +for DIR in boot/firmware boot; do if is_mounted "$ROOT/$DIR"; then umount -lf "$ROOT/$DIR" fi done -if is_mounted /boot; then - mount -o remount,ro /boot -fi +for DIR in boot/firmware boot; do + if is_mounted "/$DIR"; then + mount -o remount,ro "/$DIR" + fi +done mount -o remount,ro "$ROOT" || { echo "Failed to remount $ROOT read-only, possibly because of an open file."