From 89ada11cf9a76cf02b3d5f92fd5c66194fe40ff0 Mon Sep 17 00:00:00 2001 From: madaidan <50278627+madaidan@users.noreply.github.com> Date: Sat, 21 Mar 2020 17:49:07 +0000 Subject: [PATCH] Only remount if already mounted read-only --- .../scripts/init-bottom/sysctl-initramfs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/etc/initramfs-tools/scripts/init-bottom/sysctl-initramfs b/etc/initramfs-tools/scripts/init-bottom/sysctl-initramfs index 31b7759..e2987cc 100755 --- a/etc/initramfs-tools/scripts/init-bottom/sysctl-initramfs +++ b/etc/initramfs-tools/scripts/init-bottom/sysctl-initramfs @@ -16,10 +16,15 @@ prereqs) esac ## ${rootmnt} is mounted read-only in the initramfs so it needs to be remounted first. -mount -o remount,rw "${rootmnt}" +if mount | grep "${rootmnt}" | grep -q "(ro,"; then + remount="yes" + mount -o remount,rw "${rootmnt}" +fi sysctl -p ${rootmnt}/etc/sysctl.conf >/dev/null 2>${rootmnt}/var/log/sysctl-initramfs-error.log -sysctl -p ${rootmnt}/etc/sysctl.d/*.conf >/dev/null 2>>${rootmnt}/var/log/sysctl-initramfs-error.log -mount -o remount,ro "${rootmnt}" +sysctl -p ${rootmnt}/etc/sysctl.d/*.conf >/dev/null 2>>${rootmnt}/var/log/sysctl-initramfs-error.log +if [ "${remount}" = "yes" ]; then + mount -o remount,ro "${rootmnt}" +fi grep -v "unprivileged_userfaultfd" "${rootmnt}/var/log/sysctl-initramfs-error.log" true