diff options
| author | Daniel Baumann <mail@daniel-baumann.ch> | 2013-04-26 09:39:47 +0200 |
|---|---|---|
| committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-05-06 13:54:17 +0200 |
| commit | cdeea6bf8b114e499c650e14549fd0affd5d5b4a (patch) | |
| tree | 477b4fb322a2ca41484883e1cdd3de07afbeb24b /scripts/boot/0020-read-only | |
| parent | 53bb5b1c1f1747f2a4fb0e31321a85302692c920 (diff) | |
| download | live-boot-cdeea6bf8b114e499c650e14549fd0affd5d5b4a.tar.gz live-boot-cdeea6bf8b114e499c650e14549fd0affd5d5b4a.zip | |
Renumbering the first three early scripts.
Diffstat (limited to 'scripts/boot/0020-read-only')
| -rwxr-xr-x | scripts/boot/0020-read-only | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/boot/0020-read-only b/scripts/boot/0020-read-only new file mode 100755 index 0000000..859f771 --- /dev/null +++ b/scripts/boot/0020-read-only @@ -0,0 +1,56 @@ +#!/bin/sh + +#set -e + +Read_only () +{ + for _PARAMETER in ${_CMDLINE} + do + case "${_PARAMETER}" in + live-boot.read-only=*|read-only=*) + LIVE_READ_ONLY="true" + LIVE_READ_ONLY_DEVICES="${_PARAMETER#*read-only=}" + ;; + + live-boot.read-only|read-only) + LIVE_READ_ONLY="true" + ;; + esac + done + + case "${LIVE_READ_ONLY}" in + true) + ;; + + *) + return 0 + ;; + esac + + # Marking some block devices as read-only to ensure that nothing + # gets written as linux still writes to 'only' read-only mounted filesystems. + LIVE_READ_ONLY_DEVICES="${LIVE_READ_ONLY_DEVICES:-/dev/sd* /dev/vd*}" + + for _DEVICE in $(echo ${LIVE_READ_ONLY_DEVICES} | sed -e 's|,| |g') + do + if [ ! -b "${_DEVICE}" ] + then + continue + fi + + echo -n "live-boot: 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 +} |
