1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-22 02:59:47 +01:00

Add overlayfs setup for /etc and /var/lib

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-01-18 14:23:48 +01:00
parent ec9e6f8857
commit 9b7c8c5730
6 changed files with 57 additions and 6 deletions

View file

@ -5183,7 +5183,7 @@ CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
CONFIG_OCFS2_FS_STATS=y
CONFIG_OCFS2_DEBUG_MASKLOG=y
# CONFIG_OCFS2_DEBUG_FS is not set
CONFIG_BTRFS_FS=m
CONFIG_BTRFS_FS=y
CONFIG_BTRFS_FS_POSIX_ACL=y
# CONFIG_BTRFS_FS_CHECK_INTEGRITY is not set
# CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not set
@ -5220,7 +5220,9 @@ CONFIG_QUOTACTL=y
CONFIG_AUTOFS4_FS=y
CONFIG_FUSE_FS=m
CONFIG_CUSE=m
CONFIG_OVERLAY_FS=m
CONFIG_OVERLAY_FS=y
# CONFIG_OVERLAY_FS_REDIRECT_DIR is not set
# CONFIG_OVERLAY_FS_INDEX is not set
#
# Caches

View file

@ -10,6 +10,7 @@ busybox mount -t devtmpfs none /dev
root_sfs=""
root=""
overlay_dev=""
singleuser=0
for param in `cat /proc/cmdline`; do
@ -20,6 +21,9 @@ for param in `cat /proc/cmdline`; do
root_sfs=*)
root_sfs="${param##root_sfs=}"
;;
overlay_dev=*)
overlay_dev="${param##overlay_dev=}"
;;
single*)
singleuser=1
;;
@ -41,6 +45,20 @@ while [ ! -e ${root} ]; do
busybox sleep 1
done
# file system setup
overlay_mount() {
local lower=/newroot/${1}
local upper=/newroot/${2}
local work=/newroot/${2}_work
local target=/newroot/${3}
mount -t overlay overlay -olowerdir=${lower},upperdir=${upper},workdir=${work} ${target}
}
bind_mount() {
mount --bind /newroot/${1} /newroot/${2}
}
mount ${root} /images
if [ ! -e /images/${root_sfs} ]; then
@ -68,6 +86,21 @@ mkdir -p /newroot/var/tmp
ln -s /run /newroot/var/run
ln -s /run/lock /newroot/var/lock
if [ ! -z "$overlay_dev" ]; then
while [ ! -e ${overlay_dev} ]; do
echo "Waiting for overlay device"
busybox sleep 1
done
mount ${overlay_dev} /newroot/cfg/overlay
overlay_mount "cfg/preserve/etc" "cfg/overlay/etc" "etc"
overlay_mount "cfg/preserve/var_lib" "cfg/overlay/var_lib" "var/lib"
else
bind_mount "cfg/preserve/etc" "etc"
bind_mount "cfg/preserve/var_lib" "var/lib"
fi
# cleanup mounts
umount -l /images
umount -l /dev

View file

@ -3,4 +3,4 @@ totaltimeout 50
default linux
label linux
kernel /KERNELFILE
append root=/dev/sda1 root_sfs=/ROOTFSFILE
append root=/dev/sda1 overlay_dev=/dev/sda2 root_sfs=/ROOTFSFILE

View file

@ -1 +1 @@
console=serial0,115200 console=tty0 root=/dev/mmcblk0p1 elevator=deadline rootwait root_sfs=ROOTFSFILE
console=serial0,115200 console=tty0 root=/dev/mmcblk0p1 elevator=deadline rootwait root_sfs=ROOTFSFILE overlay_dev=/dev/mmcblk0p2

View file

@ -4,7 +4,9 @@ build() {
local DEPLOY="$3"
# setup skeleton
mkdir -pv ${BUILD}/{bin,etc,dev,sys,proc,tmp,var,run}
mkdir -pv ${BUILD}/{bin,lib,etc,dev,sys,proc,tmp,var,run}
mkdir -pv ${BUILD}/{boot,usr,srv,mnt,opt}
mkdir -pv ${BUILD}/cfg/{preserve,overlay}
echo "/lib" > "$BUILD/etc/ld-musl-i386.path"
@ -22,6 +24,12 @@ build() {
cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkgname}/* "$BUILD"
done < "$BUILD/etc/packages"
# move configuration to preserve directory
mv ${BUILD}/etc ${BUILD}/cfg/preserve
mkdir -p ${BUILD}/etc
mv ${BUILD}/var/lib ${BUILD}/cfg/preserve/var_lib
}
deploy() {

View file

@ -4,7 +4,9 @@ build() {
local DEPLOY="$3"
# setup skeleton
mkdir -pv ${BUILD}/{bin,etc,dev,sys,proc,tmp,var,run}
mkdir -pv ${BUILD}/{bin,lib,etc,dev,sys,proc,tmp,var,run}
mkdir -pv ${BUILD}/{boot,usr,srv,mnt,opt}
mkdir -pv ${BUILD}/cfg/{preserve,overlay}
echo "/lib" > "$BUILD/etc/ld-musl-arm.path"
echo "/opt/vc/lib" >> "$BUILD/etc/ld-musl-arm.path"
@ -23,6 +25,12 @@ build() {
cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkgname}/* "$BUILD"
done < "$BUILD/etc/packages"
# move configuration to preserve directory
mv ${BUILD}/etc ${BUILD}/cfg/preserve
mkdir -p ${BUILD}/etc
mv ${BUILD}/var/lib ${BUILD}/cfg/preserve/var_lib
}
deploy() {