|
2 | 2 | mounts an overlay filesystem over the root filesystem |
3 | 3 |
|
4 | 4 | I use this for my Raspberry Pi, but it should work on any Debian or derivative. |
5 | | -It uses initramfs. Stock Raspbian doesn't use one so step one would be to get initramfs working. Something like: |
| 5 | + |
| 6 | +The root file system on the sd-card is mounted read-only on /overlay/lower, and / is a |
| 7 | +read-write copy on write overlay. |
| 8 | + |
| 9 | +It uses initramfs. Stock Raspbian doesn't use one so step one would be to get initramfs working. |
| 10 | +Something like: |
6 | 11 |
|
7 | 12 | ```bash |
8 | 13 | sudo mkinitramfs -o /boot/init.gz |
@@ -42,17 +47,39 @@ if [ ! -z "${IMCHROOTED}" ]; then |
42 | 47 | PS1="chroot(${IMCHROOTED})\w:# " |
43 | 48 | fi |
44 | 49 | ``` |
45 | | -I use rootwork to work on the real root filesystem. |
46 | | -I put it in ~/bin and add ~/bin to my path |
47 | | - |
48 | | -After rebooting, the root filesystem should be an overlay. If it's on tmpfs any changes made will be lost after a reboot. If you want to upgrade packages, for example, run `rootwork`, the prompt should change to |
49 | 50 |
|
| 51 | +After rebooting, the root filesystem should be an overlay. If it's on tmpfs any changes |
| 52 | +made will be lost after a reboot. If you want to upgrade packages, for example, |
| 53 | +run `rootwork`, the prompt should change to |
50 | 54 | ```bash |
51 | 55 | chroot(/overlay/lower)/:# |
52 | 56 | ``` |
53 | | -You're now making changes to the sdcard, and changes will be permanent. |
54 | 57 |
|
55 | | -After you've finished working on the sdcard run `exit`. rootwork tries to clean up by umounting all the mounts it mounted, but often it can't umount a filesystem due to a lock file or something else causing the filesystem to be busy. It's probably a good idea to reboot now for 2 reasons, 1 to clear the mounts that couldn't be umounted, and also to test it still boots ok after the changes you've just made. |
| 58 | +You're now making changes to the sdcard, and changes will be permanent. |
| 59 | + |
| 60 | +I use `rootwork` to work on the real root filesystem. |
| 61 | +I put it in ~/bin and add ~/bin to my path. |
| 62 | + |
| 63 | +The /run directory is problematic to umount, so atm `rootwork` --rbind mounts it |
| 64 | +on the sd-card root file system, /overlay/lower, and it isn't umounted like /boot |
| 65 | +/proc /sys and /dev are. |
| 66 | + |
| 67 | +After you've finished working on the sd-card run `exit`. `rootwork` tries to clean up |
| 68 | +by umounting all the mounts it mounted and remount /overlay/lower read-only, but |
| 69 | +often it can't due to an open file or something else causing the filesystem to be busy. |
| 70 | +It's probably a good idea to reboot now for 2 reasons: |
| 71 | + |
| 72 | +- leaving /overlay/lower read-write could cause file corruption on power loss. |
| 73 | +- to test it still boots ok after the changes you've just made. |
| 74 | + |
| 75 | +Whenever the kernel is updated you need to rerun |
| 76 | + |
| 77 | +```bash |
| 78 | +sudo mkinitramfs -o /boot/init.gz |
| 79 | +``` |
| 80 | + |
| 81 | +TODO: see if there's a hook to automatically run `sudo mkinitramfs -o /boot/init.gz` |
| 82 | +on kernel install |
56 | 83 |
|
57 | 84 | There are comments in some of the files you might want to read |
58 | 85 | and that's about it. |
0 commit comments