diff options
author | Sven Gothel <[email protected]> | 2021-06-26 15:55:25 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-06-26 15:55:25 +0200 |
commit | 785f9054390a077ee28829cbe919a5c237e03c53 (patch) | |
tree | db683c89d52fccab2426036fe88d297fa4639860 /stage2 | |
parent | 5d85fc5ed790e9a2761815c1606232493f776b18 (diff) |
ro: Inject overlayfs, using DATADEV '/data' partition as 'upper'; Disable rootfs resize @ init (1st boot)
/etc/fstab didn't work to mount the overlayfs (boot freeze due to some dependencies).
Hence we use our own 'overlay_mount.service' Before 'local_fs.target',
which mounts '/data' and its overlays.
We also disable rootfs resize @ init (1st boot),
since the rootfs is immutable from here on.
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/01-sys-tweaks/00-patches/series | 1 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/01-run.sh | 9 | ||||
-rwxr-xr-x | stage2/01-sys-tweaks/files/overlay_mount | 28 | ||||
-rw-r--r-- | stage2/01-sys-tweaks/files/overlay_mount.service | 13 |
4 files changed, 49 insertions, 2 deletions
diff --git a/stage2/01-sys-tweaks/00-patches/series b/stage2/01-sys-tweaks/00-patches/series index aee0402..19b04f5 100644 --- a/stage2/01-sys-tweaks/00-patches/series +++ b/stage2/01-sys-tweaks/00-patches/series @@ -2,4 +2,3 @@ 02-swap.diff 04-inputrc.diff 05-path.diff -07-resize-init.diff diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index c1836f9..95a4d74 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -1,5 +1,8 @@ #!/bin/bash -e +install -m 644 files/overlay_mount.service "${ROOTFS_DIR}/lib/systemd/system/" +install -m 755 files/overlay_mount "${ROOTFS_DIR}/etc/init.d/" + install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d" @@ -40,12 +43,16 @@ if [ "${USE_QEMU}" = "1" ]; then install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" on_chroot << EOF systemctl disable resize2fs_once +systemctl enable overlay_mount EOF echo "leaving QEMU mode" else on_chroot << EOF -systemctl enable resize2fs_once +#systemctl enable resize2fs_once +systemctl disable resize2fs_once +systemctl enable overlay_mount EOF + echo "leaving normal mode" fi on_chroot <<EOF diff --git a/stage2/01-sys-tweaks/files/overlay_mount b/stage2/01-sys-tweaks/files/overlay_mount new file mode 100755 index 0000000..50a8965 --- /dev/null +++ b/stage2/01-sys-tweaks/files/overlay_mount @@ -0,0 +1,28 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: overlay_mount +# Required-Start: +# Required-Stop: +# Default-Start: 3 +# Default-Stop: +# Short-Description: Overlay the root filesystem with rw folder +# Description: +### END INIT INFO +. /lib/lsb/init-functions +case "$1" in + start) + log_daemon_msg "Starting overlay_mount" + /bin/mount -t ext4 DATADEV -odefaults,noatime /data && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/etc,upperdir=/data/etc/upper,workdir=/data/etc/work /etc && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/home,upperdir=/data/home/upper,workdir=/data/home/work /home && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/srv,upperdir=/data/srv/upper,workdir=/data/srv/work /srv && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/tmp,upperdir=/data/tmp/upper,workdir=/data/tmp/work /tmp && + /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/var,upperdir=/data/var/upper,workdir=/data/var/work /var && + log_end_msg $? + ;; + *) + echo "Usage: $0 start" >&2 + exit 3 + ;; +esac + diff --git a/stage2/01-sys-tweaks/files/overlay_mount.service b/stage2/01-sys-tweaks/files/overlay_mount.service new file mode 100644 index 0000000..f3687c9 --- /dev/null +++ b/stage2/01-sys-tweaks/files/overlay_mount.service @@ -0,0 +1,13 @@ +[Unit] +Description=OverlayFS mount service +DefaultDependencies=no +Before=local-fs.target + +[Service] +Type=oneshot +ExecStart=/etc/init.d/overlay_mount start + +[Install] +WantedBy=local-fs.target +Alias=overlay_mount.service + |