Adding upstream version 4.0~a1.
[debian-live-boot.git] / scripts / boot / 0120-read-only
blob859f77105c7398475112928be0cbc896bf8a8011
1 #!/bin/sh
3 #set -e
5 Read_only ()
7 for _PARAMETER in ${_CMDLINE}
8 do
9 case "${_PARAMETER}" in
10 live-boot.read-only=*|read-only=*)
11 LIVE_READ_ONLY="true"
12 LIVE_READ_ONLY_DEVICES="${_PARAMETER#*read-only=}"
15 live-boot.read-only|read-only)
16 LIVE_READ_ONLY="true"
18 esac
19 done
21 case "${LIVE_READ_ONLY}" in
22 true)
26 return 0
28 esac
30 # Marking some block devices as read-only to ensure that nothing
31 # gets written as linux still writes to 'only' read-only mounted filesystems.
32 LIVE_READ_ONLY_DEVICES="${LIVE_READ_ONLY_DEVICES:-/dev/sd* /dev/vd*}"
34 for _DEVICE in $(echo ${LIVE_READ_ONLY_DEVICES} | sed -e 's|,| |g')
36 if [ ! -b "${_DEVICE}" ]
37 then
38 continue
41 echo -n "live-boot: Setting ${_DEVICE} read-only..." > /dev/console
43 blockdev --setro ${_DEVICE}
44 _RETURN="${?}"
46 case "${_RETURN}" in
48 echo " done, use 'blockdev --setrw ${_DEVICE}' to set read-write." > /dev/console
52 echo " failed." > /dev/console
54 esac
55 done