summaryrefslogtreecommitdiff
path: root/scripts/live-bottom/13swap
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/live-bottom/13swap')
-rwxr-xr-xscripts/live-bottom/13swap44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/live-bottom/13swap b/scripts/live-bottom/13swap
new file mode 100755
index 0000000..fcef76c
--- /dev/null
+++ b/scripts/live-bottom/13swap
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+PREREQ=""
+DESCRIPTION="Setting up swap..."
+FSTAB=/root/etc/fstab
+
+. /scripts/live-functions
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+log_begin_msg "$DESCRIPTION"
+
+devices=""
+for device in /dev/[hs]d[a-z][0-9]*; do
+ if ! [ -b "$device" ]; then
+ continue
+ fi
+
+ 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
+
+log_end_msg