summaryrefslogtreecommitdiff
path: root/scripts/boot/0120-read-only
blob: 588d57b569b76f678dd1e39cb34797426699e41d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

#set -e

Read_only ()
{
	# 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}" ]
		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
}