From 5a888f7e35b452c0cb42dc75cbd3e84213638652 Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Fri, 17 Jan 2020 11:51:49 +0000 Subject: [PATCH] 20200117 release OverlayFS - remove initramfs when disabled --- debian/changelog | 5 +++-- raspi-config | 39 +++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/debian/changelog b/debian/changelog index b6192ee..8b7aad1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -raspi-config (20200109) UNRELEASED; urgency=medium +raspi-config (20200117) buster; urgency=medium * Add proxy configuration * Handle cases where SUDO_USER is unset @@ -6,8 +6,9 @@ raspi-config (20200109) UNRELEASED; urgency=medium * Install required packages when changing GL settings * Add warning when enabling SSH * OverlayFS - try loading module from rootfs + * OverlayFS - remove initramfs when disabled - -- Serge Schneider Thu, 09 Jan 2020 14:38:50 +0000 + -- Serge Schneider Fri, 17 Jan 2020 11:50:54 +0000 raspi-config (20191210) buster; urgency=medium diff --git a/raspi-config b/raspi-config index 1b90b5c..40d31b4 100755 --- a/raspi-config +++ b/raspi-config @@ -1860,6 +1860,11 @@ get_bootro_conf() { grep /boot /etc/fstab | grep -q "defaults.*,ro " } +is_uname_current() { + test -d "/lib/modules/$(uname -r)" + return $? +} + enable_overlayfs() { KERN=$(uname -r) INITRD=initrd.img-"$KERN"-overlay @@ -1875,11 +1880,7 @@ enable_overlayfs() { BOOTRO=no fi - # check that the modified initramfs is available for the current kernel version - if [ ! -e /boot/"$INITRD" ]; then - # generate the modified initramfs - check that the overlay file is available - if [ ! -e /etc/initramfs-tools/scripts/overlay ]; then - cat > /etc/initramfs-tools/scripts/overlay << 'EOF' + cat > /etc/initramfs-tools/scripts/overlay << 'EOF' # Local filesystem mounting -*- shell-script -*- # @@ -1933,20 +1934,18 @@ local_mount_root() overlay ${rootmnt} } EOF - fi - # add the overlay to the list of modules - if ! grep overlay /etc/initramfs-tools/modules > /dev/null; then - echo overlay >> /etc/initramfs-tools/modules - fi - - # build the new initramfs - update-initramfs -c -k "$KERN" - - # rename it so we know it has overlay added - mv /boot/initrd.img-"$KERN" /boot/"$INITRD" + # add the overlay to the list of modules + if ! grep overlay /etc/initramfs-tools/modules > /dev/null; then + echo overlay >> /etc/initramfs-tools/modules fi + # build the new initramfs + update-initramfs -c -k "$KERN" + + # rename it so we know it has overlay added + mv /boot/initrd.img-"$KERN" /boot/"$INITRD" + # there is now a modified initramfs ready for use... # modify config.txt @@ -1966,6 +1965,7 @@ EOF } disable_overlayfs() { + KERN=$(uname -r) # mount the boot partition as writable if it isn't already if get_bootro_now ; then if ! mount -o remount,rw /boot 2>/dev/null ; then @@ -1979,6 +1979,7 @@ disable_overlayfs() { # modify config.txt sed -i /boot/config.txt -e "/initramfs.*/d" + update-initramfs -d -k "${KERN}-overlay" # modify command line sed -i /boot/cmdline.txt -e "s/\(.*\)boot=overlay \(.*\)/\1\2/" @@ -2010,6 +2011,12 @@ do_overlayfs() { DEFAULT=--defaultno CURRENT=0 STATUS="disabled" + + if [ "$INTERACTIVE" = True ] && ! is_uname_current; then + whiptail --msgbox "Could not find modules for the running kernel ($(uname -r))." 20 60 1 + return 1 + fi + if get_overlay_conf; then DEFAULT= CURRENT=1