From 6190410c99fc694906f8ef1db4a18af2ebb49840 Mon Sep 17 00:00:00 2001 From: Rahammetoela Toekiman Date: Thu, 17 Oct 2024 15:47:50 -0300 Subject: [PATCH] unmount /var/cache/apt and /var/lib/apt if they were mounted when remounting as readonly --- remount | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/remount b/remount index 9aef8b5..e170331 100755 --- a/remount +++ b/remount @@ -3,22 +3,26 @@ BEGIN { FS = "[ ,]" ARGC=2; ARGV[1]="/proc/mounts"; + system("sudo -K"); } { if ( $2 == "/" && $3 != "rootfs" ) { - if ( $4 == "ro" ) { + rootfs = $4; + if ( rootfs == "ro" ) { print "remounting rootfs as readwrite"; - system("sudo -K"); system("set -x; sudo mount -t tmpfs tmpfs /var/lib/apt"); system("set -x; sudo mount -t tmpfs tmpfs /var/cache/apt"); system("set -x; sudo mount -o remount,rw /"); - system("sudo -K"); } - if ( $4 == "rw" ) { + if ( rootfs == "rw" ) { print "remounting rootfs as readonly"; - system("sudo -K"); system("set -x; sudo mount -o remount,ro /"); - system("sudo -K"); } } + if ( /apt/ && rootfs == "rw" ) { + system("set -x; sudo umount "$2); + } +} +END { + system("sudo -K"); }