48aa06c3960450d8aaae654de75c4c2569502982
[live-boot-grml.git] / scripts / boot / read-only.sh
1 #!/bin/sh
2
3 #set -e
4
5 Read_only ()
6 {
7         # Marking some block devices as read-only to ensure that nothing
8         # gets written as linux still writes to 'only' read-only mounted filesystems.
9         _DEVICES="/dev/sd* /dev/vd*"
10
11         for _DEVICE in ${_DEVICES}
12         do
13                 if [ ! -b "${_DEVICE}" ]
14                 then
15                         continue
16                 fi
17
18                 echo -n "Setting ${_DEVICE} read-only..." > /dev/console
19
20                 blockdev --setro ${_DEVICE}
21                 _RETURN="${?}"
22
23                 case "${_RETURN}" in
24                         0)
25                                 echo " done, use 'blockdev --setrw ${_DEVICE}' to set read-write." > /dev/console
26                                 ;;
27
28                         *)
29                                 echo " failed." > /dev/console
30                                 ;;
31                 esac
32         done
33 }