Package: initscripts Version: 2.86.ds1-20 Severity: wishlist Tags: patch
As discussed on #pkg-sysvinit (with pere and mbiebl) it would be great to be able to control use of swap-partitions before the system boots up. Adding support for a bootoption "noswap" would provide the option to disable the use of swap-partitions/-files before booting the system at all or manually editing /etc/fstab. Use cases for disabling swap before system startup are for example corrupt swap-partitions/files, the use of external usb/firewire devices or even (under certain circumstances of course) forensic investigations. There are two init scripts inside the initscripts package which have to be adjusted: /etc/init.d/checkroot.sh and /etc/init.d/mountall.sh I've created (tested) patches against the two files which implement the requested feature. If you do need any further information or testers please feel free to contact me. regards, -mika-
--- /etc/init.d/mountall.sh.orig 2006-09-21 00:10:45.000000000 +0200 +++ /etc/init.d/mountall.sh 2006-09-21 00:11:06.000000000 +0200 @@ -17,6 +17,11 @@ . /lib/lsb/init-functions . /lib/init/mount-functions.sh +# check for bootoption 'noswap' and do not activate swap partitions/files then +if [ -r /proc/cmdline ] ; then + grep -q ' noswap' /proc/cmdline && NOSWAP=yes || NOSWAP=no +fi + do_start() { # # Mount local file systems in /etc/fstab. @@ -76,15 +81,20 @@ # # Ignore 255 status due to swap already being enabled # - if [ "$VERBOSE" = no ] + if [ "$NOSWAP" = yes ] then - log_action_begin_msg "Activating swapfile swap" - swapon -a -e 2>/dev/null || : # Stifle "Device or resource busy" - log_action_end_msg 0 + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap as requested via bootoption noswap." else - log_daemon_msg "Will now activate swapfile swap" - swapon -a -e -v - log_action_end_msg $? + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Activating swapfile swap" + swapon -a -e 2>/dev/null || : # Stifle "Device or resource busy" + log_action_end_msg 0 + else + log_daemon_msg "Will now activate swapfile swap" + swapon -a -e -v + log_action_end_msg $? + fi fi }
--- /etc/init.d/checkroot.sh.orig 2006-09-20 23:34:26.000000000 +0200 +++ /etc/init.d/checkroot.sh 2006-09-20 23:35:27.000000000 +0200 @@ -19,6 +19,11 @@ . /lib/lsb/init-functions . /lib/init/mount-functions.sh +# check for bootoption 'noswap' and do not activate swap partitions/files then +if [ -r /proc/cmdline ] ; then + grep -q ' noswap' /proc/cmdline && NOSWAP=yes || NOSWAP=no +fi + do_start () { # # Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to @@ -102,14 +107,20 @@ ENABLE_SWAP=no case "$KERNEL" in Linux) - if [ "$swap_on_lv" = yes ] - then - [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on logical volume." - elif [ "$swap_on_file" = yes ] + if [ "$NOSWAP" = yes ] then - [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on swapfile." + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap as requested via bootoption noswap." + ENABLE_SWAP=no else - ENABLE_SWAP=yes + if [ "$swap_on_lv" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on logical volume." + elif [ "$swap_on_file" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on swapfile." + else + ENABLE_SWAP=yes + fi fi ;; *)