Skip to content

Commit 0533d1d

Browse files
committed
remount-ro: nothing to do if device is already read-only
1 parent b0fdba7 commit 0533d1d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sbin/safeboot

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,15 +874,17 @@ remount_ro()
874874
{
875875
DEV="${1:-${ROOTDEV}}"
876876

877-
warn "${DEV}: remounting read-only"
877+
if [ "$(blockdev --getro "${DEV}")" == 1 ] ; then
878+
warn "${DEV}: already read-only"
879+
return 0
880+
fi
878881

882+
warn "${DEV}: remounting read-only"
879883
if mount -o ro,noatime,remount "${DEV}" ; then
880884

881-
if [ "$(blockdev --getro "${DEV}")" != 1 ] ; then
882-
warn "${DEV}: forcing fsck"
883-
fsck.ext4 -f "${DEV}" \
884-
|| die "${DEV}: Could not fsck"
885-
fi
885+
warn "${DEV}: forcing fsck"
886+
fsck.ext4 -f "${DEV}" \
887+
|| die "${DEV}: Could not fsck"
886888

887889
warn "${DEV}: setting block dev readonly"
888890
blockdev --setro "${DEV}" \

0 commit comments

Comments
 (0)