Skip to content

Commit 30339c5

Browse files
committed
Make the mount points of the overlayfs visible via config options
1 parent 0319d1c commit 30339c5

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

raspi-config

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,7 +2547,7 @@ enable_overlayfs() {
25472547
BOOTRO=no
25482548
fi
25492549

2550-
cat > /etc/initramfs-tools/scripts/overlay << 'EOF'
2550+
sed -e "s!MOUNT_POINT!$MOUNT_POINT!g" > /etc/initramfs-tools/scripts/overlay << 'EOF'
25512551
# Local filesystem mounting -*- shell-script -*-
25522552
25532553
#
@@ -2580,24 +2580,24 @@ local_mount_root()
25802580
checkfs ${ROOT} root "${FSTYPE}"
25812581
25822582
# Create directories for root and the overlay
2583-
mkdir /lower /upper
2583+
mkdir MOUNT_POINT/lower MOUNT_POINT/upper
25842584
2585-
# Mount read-only root to /lower
2585+
# Mount read-only root to MOUNT_POINT/lower
25862586
if [ "${FSTYPE}" != "unknown" ]; then
2587-
mount -r -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /lower
2587+
mount -r -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} MOUNT_POINT/lower
25882588
else
2589-
mount -r ${ROOTFLAGS} ${ROOT} /lower
2589+
mount -r ${ROOTFLAGS} ${ROOT} MOUNT_POINT/lower
25902590
fi
25912591
2592-
modprobe overlay || insmod "/lower/lib/modules/$(uname -r)/kernel/fs/overlayfs/overlay.ko"
2592+
modprobe overlay || insmod "MOUNT_POINT/lower/lib/modules/$(uname -r)/kernel/fs/overlayfs/overlay.ko"
25932593
2594-
# Mount a tmpfs for the overlay in /upper
2595-
mount -t tmpfs tmpfs /upper
2596-
mkdir /upper/data /upper/work
2594+
# Mount a tmpfs for the overlay in MOUNT_POINT/upper
2595+
mount -t tmpfs tmpfs MOUNT_POINT/upper
2596+
mkdir MOUNT_POINT/upper/data MOUNT_POINT/upper/work
25972597
25982598
# Mount the final overlay-root in $rootmnt
25992599
mount -t overlay \
2600-
-olowerdir=/lower,upperdir=/upper/data,workdir=/upper/work \
2600+
-olowerdir=MOUNT_POINT/lower,upperdir=MOUNT_POINT/upper/data,workdir=MOUNT_POINT/upper/work \
26012601
overlay ${rootmnt}
26022602
}
26032603
EOF
@@ -2609,6 +2609,9 @@ EOF
26092609

26102610
# build the new initramfs
26112611
update-initramfs -c -k "$KERN"
2612+
if [ $? -ne 0 ] ; then
2613+
echo "Failed to delete ${KERN}-overlay"
2614+
fi
26122615

26132616
# rename it so we know it has overlay added
26142617
mv /boot/initrd.img-"$KERN" /boot/"$INITRD"
@@ -2647,6 +2650,9 @@ disable_overlayfs() {
26472650
# modify config.txt
26482651
sed -i /boot/config.txt -e "/initramfs.*/d"
26492652
update-initramfs -d -k "${KERN}-overlay"
2653+
if [ $? -ne 0 ] ; then
2654+
echo "Failed to delete ${KERN}-overlay"
2655+
fi
26502656

26512657
# modify command line
26522658
sed -i /boot/cmdline.txt -e "s/\(.*\)boot=overlay \(.*\)/\1\2/"
@@ -2675,6 +2681,14 @@ disable_bootro() {
26752681
}
26762682

26772683
do_overlayfs() {
2684+
if [ ! "$INTERACTIVE" = True -a ! "$1" ]; then echo '
2685+
do_overlayfs status [ writable [ invisible ] ]
2686+
"status" can be 0=enable or 1=disable overlayfs (default)
2687+
"writable" can be 0=read-only (default) or 1=writable boot partition
2688+
"invisible" (used when enabling the overlayfs) can be 0=visible mounts or 1=invisible mounts (default)
2689+
'
2690+
return 1
2691+
fi
26782692
DEFAULT=--defaultno
26792693
CURRENT=0
26802694
STATUS="disabled"
@@ -2695,7 +2709,26 @@ do_overlayfs() {
26952709
else
26962710
RET=$1
26972711
fi
2712+
case "$RET" in ''|*[!01]*) RET=1;; esac
26982713
if [ $RET -eq $CURRENT ]; then
2714+
MOUNT_POINT="/run"
2715+
if [ "$INTERACTIVE" = True -a $RET -eq 0 ]; then
2716+
whiptail --yesno "Would you like the mount points of the overlay file system to be visible under '$MOUNT_POINT/upper' (rw) and '$MOUNT_POINT/lower' (ro)?" $DEFAULT 20 60 2
2717+
MP=$?
2718+
else
2719+
MP=$3
2720+
fi
2721+
case "$MP" in ''|*[!01]*) MP=1;; esac
2722+
if [ $MP -eq 1 ]; then
2723+
MOUNT_POINT=""
2724+
if [ ! "$INTERACTIVE" = True ]; then
2725+
echo "Invisible mount points"
2726+
fi
2727+
else
2728+
if [ ! "$INTERACTIVE" = True ]; then
2729+
echo "Mount points under '$MOUNT_POINT'"
2730+
fi
2731+
fi
26992732
if [ $RET -eq 0 ]; then
27002733
if enable_overlayfs; then
27012734
STATUS="enabled"
@@ -2739,19 +2772,26 @@ do_overlayfs() {
27392772
whiptail --yesno "Would you like the boot partition to be write-protected?" $DEFAULT 20 60 2
27402773
RET=$?
27412774
else
2742-
RET=$1
2775+
RET=$2
27432776
fi
2777+
case "$RET" in ''|*[!01]*) RET=0;; esac
27442778
if [ $RET -eq $CURRENT ]; then
27452779
if [ $RET -eq 0 ]; then
27462780
if enable_bootro; then
27472781
STATUS="read-only"
2782+
if [ ! "$INTERACTIVE" = True ]; then
2783+
echo "Boot partition is $STATUS"
2784+
fi
27482785
ASK_TO_REBOOT=1
27492786
else
27502787
STATUS="unchanged"
27512788
fi
27522789
elif [ $RET -eq 1 ]; then
27532790
if disable_bootro; then
27542791
STATUS="writable"
2792+
if [ ! "$INTERACTIVE" = True ]; then
2793+
echo "Boot partition is $STATUS"
2794+
fi
27552795
ASK_TO_REBOOT=1
27562796
else
27572797
STATUS="unchanged"

0 commit comments

Comments
 (0)