Add a script to remount devices with extra rights

To be able to run updates such as apt, dpkg, grub,…
This commit is contained in:
Jeremy Gardais 2018-03-12 10:49:39 +01:00
parent de6a86ba5d
commit 0bb95412a2
1 changed files with 28 additions and 0 deletions

28
remountrw Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# Remount some partitions with less restrictive permissions, e.g:
# * to be able to run updates (apt, dpkg, grub,…)
if [ "$(id -u)" -eq 0 ]; then
# RW permissions
## get the mountpath list from fstab
for mountpath in /boot /opt /usr /var; do
# ensure "${mountpath}" is already mounted
if grep -q " ${mountpath} " /etc/mtab; then
mount "${mountpath}" -o remount,rw,suid,dev
fi
done
# EXEC + RW permissions
## get the mountpath list from fstab
for mountpath in /tmp /var/tmp /dev/shm; do
# ensure "${mountpath}" is already mounted
if grep -q " ${mountpath} " /etc/mtab; then
mount "${mountpath}" -o remount,rw,suid,dev,exec
fi
done
else
sudo "${0}"
fi
exit 0