Add a noswap option to avoid accessing drives

Asked by Lucas Magasweran

I would like to propose the following patch that adds a "noswap" Kernel parameter that disables casper's automatic discovery and activation of any present swap partitions. The purpose is to not have the drives and drivers in use so that they can be accessed or unloaded without issue.

=== modified file 'debian/manpage/casper.7'
--- old/debian/manpage/casper.7 2010-11-29 12:49:36 +0000
+++ new/debian/manpage/casper.7 2013-06-27 22:21:58 +0000
@@ -88,6 +88,11 @@
 .TP
 .BI noprompt
 Do not prompt to eject the CD on reboot.
+.TP
+.BI noswap
+Adding this parameter, casper will not attempt to find and activate swap partitions requiring manual use of
+.B swapon
+as needed. This is useful to avoid accessing drives that may be present in the system.

 .SH FILES
 .B /etc/casper.conf

=== modified file 'scripts/casper'
--- old/scripts/casper 2013-05-28 10:19:04 +0000
+++ new/scripts/casper 2013-06-27 22:23:14 +0000
@@ -71,6 +71,8 @@
                 export CMD_USERFULLNAME="${x#userfullname=}" ;;
             username=*)
                 export CMD_USERNAME="${x#username=}" ;;
+ noswap)
+ export DISABLE_SWAP="Yes" ;;
         esac
     done
     if [ "${UNIONFS}" = "" ]; then

=== modified file 'scripts/casper-bottom/13swap'
--- old/scripts/casper-bottom/13swap 2013-03-13 14:24:28 +0000
+++ new/scripts/casper-bottom/13swap 2013-06-27 22:23:36 +0000
@@ -22,25 +22,29 @@
 log_begin_msg "$DESCRIPTION"

 devices=""
-for device in /dev/[hsv]d[a-z][0-9]*; do
- if ! [ -b "$device" ]; then
- continue
- fi
-
- /sbin/blkid -o udev -p ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue
-
- magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
-
- if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
-# log "Found $device"
- devices="$devices $device"
+if [[ -n "$DISABLE_SWAP" ]]; then
+ echo -n "disabled via kernel cmdline: noswap."
+else
+ for device in /dev/[hsv]d[a-z][0-9]*; do
+ if ! [ -b "$device" ]; then
+ continue
         fi
-done
-
-for device in $devices; do
- cat >> $FSTAB <<EOF
+
+ /sbin/blkid -o udev -p ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue
+
+ magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
+
+ if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
+# log "Found $device"
+ devices="$devices $device"
+ fi
+ done
+
+ for device in $devices; do
+ cat >> $FSTAB <<EOF
 $device swap swap defaults 0 0
 EOF
-done
+ done
+fi

 log_end_msg

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu casper Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#1

I suggest you report a bug

Revision history for this message
Lucas Magasweran (lucasrangit) said :
#2

Thanks actionparsnip, that solved my question.