X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Fboot%2Fread-only.sh;h=48aa06c3960450d8aaae654de75c4c2569502982;hb=5a6fb1a5946c4945416d932d86e8f59671c80228;hp=c8990dfcf0dbeb6fea44fab532cbd56bf814f287;hpb=9657ab15cc02aa4c8311ed66dcc95a0b350ce1bb;p=live-boot-grml.git diff --git a/scripts/boot/read-only.sh b/scripts/boot/read-only.sh index c8990df..48aa06c 100755 --- a/scripts/boot/read-only.sh +++ b/scripts/boot/read-only.sh @@ -4,14 +4,30 @@ Read_only () { - # Marking the usual block devices for harddisks read-only - for _DEVICE in /dev/sd* /dev/vd* + # Marking some block devices as read-only to ensure that nothing + # gets written as linux still writes to 'only' read-only mounted filesystems. + _DEVICES="/dev/sd* /dev/vd*" + + for _DEVICE in ${_DEVICES} do - if [ -b "${_DEVICE}" ] + if [ ! -b "${_DEVICE}" ] then - printf "Setting device %-9s to read-only mode:" ${_DEVICE} > /dev/console - - blockdev --setro ${_DEVICE} && printf " done [ execute \"blockdev --setrw %-9s\" to unlock]\n" ${_DEVICE} > /dev/console || printf "failed\n" > /dev/console + continue fi + + echo -n "Setting ${_DEVICE} read-only..." > /dev/console + + blockdev --setro ${_DEVICE} + _RETURN="${?}" + + case "${_RETURN}" in + 0) + echo " done, use 'blockdev --setrw ${_DEVICE}' to set read-write." > /dev/console + ;; + + *) + echo " failed." > /dev/console + ;; + esac done }