1 # This file is part of the 'dragora-installer'.
3 # Purpose: Swap formatter.
5 # Check for at least one swap partition
7 if ! fdisk -l 2> /dev/null | grep -q -m 1 swap
10 --backtitle "\ZbPartitions: Swap" \
11 --title "SWAP PARTITION NOT DETECTED" \
13 "No swap partitions detected. This could be important\n\
14 to reduce the use of RAM memory...\n\n\
15 Would you like to proceed without a swap partition?.\n" 9 58 || \
18 "Please, try to create a swap partition using fdisk(8) or cfdisk(8)." \
19 "Then re-run the installer to give the proper format (if needed)."
22 else # Offer format possibility
24 list="$(fdisk -l 2> /dev/null | grep -m 1 swap)"
26 size="$(echo $list | awk '{ print $5 }')"
30 --backtitle "\ZbPartitions: Swap format" \
31 --title "SWAP PARTITION DETECTED" \
33 --cancel-label "Ignore" \
35 "A swap partition has been detected.\n\n\
36 We offer the possibility to format it properly,\n\
37 as well as you can simply ignore this part and\n\
38 continue if you previously formatted it:\n\n\
39 Device name: $device [${size}]" 14 52 1 \
40 "$device" "Check for bad blocks (slow)" off \
41 2> ${SUBTMPDIR}/return-MakeSwap || \
46 unset size # Next, we're not using it.
48 # Give format and activate swap partition
50 if test -s "${SUBTMPDIR}/return-MakeSwap"
53 --backtitle "\ZbPartitions: Formatting and checking swap partition ${device}" \
54 --title "SWAP PARTITION $device" \
55 --prgbox "mkswap -c $device" 30 72
58 --backtitle "\ZbPartitions: Formatting swap partition ${device}" \
59 --title "SWAP PARTITION $device" \
60 --prgbox "mkswap $device" 30 72
64 --backtitle "\ZbPartitions: Swap partition activation" \
65 --title "SWAP PARTITION $device" \
66 --prgbox "Activating swap partition..." "swapon -f $device" 30 72
68 # Produce fstab entry for physical swap partition
70 printf "%-15s %-15s %-11s %-16s %-5s %s\n" \
71 "$device" "swap" "swap" "defaults" "0" "0" > ${SUBTMPDIR}/fstab