From 077f72f529f55029e5f3e528541d81be166f1ac3 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 23 Jan 2018 16:34:33 +0100 Subject: [PATCH] Some rootfs restructuring - Dedicate home directory for root user (classic /root) - Root homedirectory is overlay mounted - Allows us to have an empty user directory that we directly mount, i.e. without using overlay fs Signed-off-by: David Oberhollenzer --- pkg/base-files/build | 8 ++++---- pkg/base-files/passwd | 2 +- pkg/initrd/initrd.skel | 2 ++ pkg/release-alix/genimage.sh | 1 + pkg/release-alix/install.sh | 1 + pkg/release-rpi3/genimage.sh | 1 + pkg/release-rpi3/install.sh | 1 + pkg/rootfs-alix/build | 4 ++++ pkg/rootfs-rpi3/build | 4 ++++ 9 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/base-files/build b/pkg/base-files/build index f63e6b4..269cb3b 100644 --- a/pkg/base-files/build +++ b/pkg/base-files/build @@ -8,11 +8,11 @@ deploy() { local DEPLOY="$3" # home directory of root user - mkdir -p "$DEPLOY/usr/root" - chmod 750 "$DEPLOY/usr/root" + mkdir -p "$DEPLOY/root" + chmod 750 "$DEPLOY/root" - cp "$SCRIPTDIR/pkg/base-files/bash_profile" "$DEPLOY/usr/root/.bash_profile" - cp "$SCRIPTDIR/pkg/base-files/bashrc" "$DEPLOY/usr/root/.bashrc" + cp "$SCRIPTDIR/pkg/base-files/bash_profile" "$DEPLOY/root/.bash_profile" + cp "$SCRIPTDIR/pkg/base-files/bashrc" "$DEPLOY/root/.bashrc" # /etc base files mkdir -p "$DEPLOY/etc/skel" diff --git a/pkg/base-files/passwd b/pkg/base-files/passwd index 585df8a..aebc492 100644 --- a/pkg/base-files/passwd +++ b/pkg/base-files/passwd @@ -1 +1 @@ -root:x:0:0:root:/usr/root:/bin/bash +root:x:0:0:root:/root:/bin/bash diff --git a/pkg/initrd/initrd.skel b/pkg/initrd/initrd.skel index 3fdf133..19cc5a1 100644 --- a/pkg/initrd/initrd.skel +++ b/pkg/initrd/initrd.skel @@ -96,9 +96,11 @@ if [ ! -z "$overlay_dev" ]; then overlay_mount "cfg/preserve/etc" "cfg/overlay/etc" "etc" overlay_mount "cfg/preserve/var_lib" "cfg/overlay/var_lib" "var/lib" + overlay_mount "cfg/preserve/root" "cfg/overlay/root" "root" else bind_mount "cfg/preserve/etc" "etc" bind_mount "cfg/preserve/var_lib" "var/lib" + bind_mount "cfg/preserve/root" "root" fi # cleanup mounts diff --git a/pkg/release-alix/genimage.sh b/pkg/release-alix/genimage.sh index f1813fe..868853f 100755 --- a/pkg/release-alix/genimage.sh +++ b/pkg/release-alix/genimage.sh @@ -47,6 +47,7 @@ mount -t btrfs ${LODEV}p2 /tmp/mnt.$$ MOUNTED=1 mkdir /tmp/mnt.$$/etc /tmp/mnt.$$/etc_work mkdir /tmp/mnt.$$/var_lib /tmp/mnt.$$/var_lib_work +mkdir /tmp/mnt.$$/root /tmp/mnt.$$/root_work umount /tmp/mnt.$$ MOUNTED=0 diff --git a/pkg/release-alix/install.sh b/pkg/release-alix/install.sh index 0068efe..e1df9d1 100755 --- a/pkg/release-alix/install.sh +++ b/pkg/release-alix/install.sh @@ -57,6 +57,7 @@ mount -t btrfs ${DEVICE}2 /tmp/mnt.$$ MOUNTED=1 mkdir /tmp/mnt.$$/etc /tmp/mnt.$$/etc_work mkdir /tmp/mnt.$$/var_lib /tmp/mnt.$$/var_lib_work +mkdir /tmp/mnt.$$/root /tmp/mnt.$$/root_work umount /tmp/mnt.$$ MOUNTED=0 diff --git a/pkg/release-rpi3/genimage.sh b/pkg/release-rpi3/genimage.sh index 396df48..bb7588a 100755 --- a/pkg/release-rpi3/genimage.sh +++ b/pkg/release-rpi3/genimage.sh @@ -44,6 +44,7 @@ mount -t btrfs ${LODEV}p2 /tmp/mnt.$$ MOUNTED=1 mkdir /tmp/mnt.$$/etc /tmp/mnt.$$/etc_work mkdir /tmp/mnt.$$/var_lib /tmp/mnt.$$/var_lib_work +mkdir /tmp/mnt.$$/root /tmp/mnt.$$/root_work umount /tmp/mnt.$$ MOUNTED=0 diff --git a/pkg/release-rpi3/install.sh b/pkg/release-rpi3/install.sh index bd49f48..a3a88c9 100755 --- a/pkg/release-rpi3/install.sh +++ b/pkg/release-rpi3/install.sh @@ -54,6 +54,7 @@ mount -t btrfs ${DEVICE}p2 /tmp/mnt.$$ MOUNTED=1 mkdir /tmp/mnt.$$/etc /tmp/mnt.$$/etc_work mkdir /tmp/mnt.$$/var_lib /tmp/mnt.$$/var_lib_work +mkdir /tmp/mnt.$$/root /tmp/mnt.$$/root_work umount /tmp/mnt.$$ MOUNTED=0 diff --git a/pkg/rootfs-alix/build b/pkg/rootfs-alix/build index e0fc8dc..4f16f4e 100755 --- a/pkg/rootfs-alix/build +++ b/pkg/rootfs-alix/build @@ -30,6 +30,10 @@ build() { mkdir -p ${BUILD}/etc mv ${BUILD}/var/lib ${BUILD}/cfg/preserve/var_lib + + mv ${BUILD}/root ${BUILD}/cfg/preserve + mkdir -p ${BUILD}/root + chmod 750 ${BUILD}/root } deploy() { diff --git a/pkg/rootfs-rpi3/build b/pkg/rootfs-rpi3/build index 12d4001..b929918 100755 --- a/pkg/rootfs-rpi3/build +++ b/pkg/rootfs-rpi3/build @@ -31,6 +31,10 @@ build() { mkdir -p ${BUILD}/etc mv ${BUILD}/var/lib ${BUILD}/cfg/preserve/var_lib + + mv ${BUILD}/root ${BUILD}/cfg/preserve + mkdir -p ${BUILD}/root + chmod 750 ${BUILD}/root } deploy() {