Skip to content

Commit

Permalink
unmount /var/cache/apt and /var/lib/apt if they were mounted when rem…
Browse files Browse the repository at this point in the history
…ounting as readonly
  • Loading branch information
Fuseteam committed Oct 17, 2024
1 parent 4c02333 commit 6190410
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions remount
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 6190410

Please sign in to comment.