Use PERSISTENCE_PATH with a trailing "/".
[debian-live-boot.git] / components / 0020-read-only
blobfc0dde0cc7eb5dd240093febcd3c0e21a81ffcc7
1 #!/bin/sh
3 #set -e
5 Read_only ()
7 for _PARAMETER in ${LIVE_BOOT_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