Skip to content

Commit

Permalink
Updating read-only handling to new parameter handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-baumann committed Jun 5, 2012
1 parent be6b2f5 commit bc9ae2d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
4 changes: 1 addition & 3 deletions scripts/boot.sh
Expand Up @@ -446,9 +446,7 @@ mountroot ()

Arguments

# make sure all harddisk devices are read-only
# this is important for forensic investigations
case "${READ_ONLY}" in
case "${LIVE_READ_ONLY}" in
true)
Read_only
;;
Expand Down
9 changes: 5 additions & 4 deletions scripts/boot/arguments.sh
Expand Up @@ -7,16 +7,17 @@ Arguments ()
for ARGUMENT in $(cat /proc/cmdline)
do
case "${ARGUMENT}" in
live-boot.read-only|read-only)
LIVE_READ_ONLY="true"
export LIVE_READ_ONLY
;;

live-boot.verify-checksums|verify-checksums)
LIVE_VERIFY_CHECKSUMS="true"
export LIVE_VERIFY_CHECKSUMS
;;

# parameters below need review
read-only)
READ_ONLY="true"
;;

skipconfig)
NOFASTBOOT="true"
NOFSTAB="true"
Expand Down
28 changes: 22 additions & 6 deletions scripts/boot/read-only.sh
Expand Up @@ -4,14 +4,30 @@

Read_only ()
{
# Marking the usual block devices for harddisks read-only
for _DEVICE in /dev/sd* /dev/vd*
# 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}" ]
if [ ! -b "${_DEVICE}" ]
then
printf "Setting device %-9s to read-only mode:" ${_DEVICE} > /dev/console

blockdev --setro ${_DEVICE} && printf " done [ execute \"blockdev --setrw %-9s\" to unlock]\n" ${_DEVICE} > /dev/console || printf "failed\n" > /dev/console
continue
fi

echo -n "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
}

0 comments on commit bc9ae2d

Please sign in to comment.