From 31c6cacb0a92d4fc8d024ca51eb83058398bb6b5 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 9 Oct 2007 21:10:53 +0000 Subject: Always remount root rw if it's not --- init.d/checkroot | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'init.d/checkroot') diff --git a/init.d/checkroot b/init.d/checkroot index 0dfd0047..a392ea36 100755 --- a/init.d/checkroot +++ b/init.d/checkroot @@ -30,6 +30,11 @@ do_mtab() { rm -f /etc/mtab~ /etc/mtab~~ } +root_rw() { + echo 2>/dev/null >/.test.$$ || return 1 + rm -f /.test.$$ +} + do_fsck() { local retval=0 opts= case "${RC_UNAME}" in @@ -42,9 +47,8 @@ do_fsck() { return 0 fi - if echo 2>/dev/null >/.test.$$ ; then + if root_rw; then einfo "root filesystem is mounted read-write - skipping" - rm -f /.test.$$ return 0 fi @@ -106,18 +110,22 @@ do_fsck() { fi fi - ebegin "Remounting root filesystem read/write" - if [ "${RC_UNAME}" = "Linux" ] ; then - mount -n -o remount,rw / - else - mount -u -o rw / - fi - eend $? "Root filesystem could not be mounted read/write :(" } start() { do_fsck || return 1 + if ! root_rw; then + ebegin "Remounting root filesystem read/write" + if [ "${RC_UNAME}" = "Linux" ] ; then + mount -n -o remount,rw / + else + mount -u -o rw / + fi + eend $? "Root filesystem could not be mounted read/write :(" + return $? + fi + # Only Linux has mtab [ "${RC_UNAME}" = "Linux" ] && do_mtab -- cgit v1.2.3