slitaz-boot-scripts rev 132
Update swap in fstab
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Feb 16 17:26:41 2009 +0000 (2009-02-16) |
parents | 328bf7e4f920 |
children | 1dc47d7c92cc |
files | etc/init.d/bootopts.sh |
line diff
1.1 --- a/etc/init.d/bootopts.sh Sun Feb 15 11:55:47 2009 +0100 1.2 +++ b/etc/init.d/bootopts.sh Mon Feb 16 17:26:41 2009 +0000 1.3 @@ -3,6 +3,14 @@ 1.4 # 1.5 . /etc/init.d/rc.functions 1.6 1.7 +# Update fstab for swapon/swapoff 1.8 +add_swap_in_fstab() 1.9 +{ 1.10 + grep -q "$1 " /etc/fstab || cat >> /etc/fstab <<EOT 1.11 +$1 swap swap default 0 0 1.12 +EOT 1.13 +} 1.14 + 1.15 # Check if swap file must be generated in /home: swap=size (Mb). 1.16 # This option is used with home=device. 1.17 gen_home_swap() 1.18 @@ -14,6 +22,7 @@ 1.19 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE 1.20 # Make the Linux swap filesystem. 1.21 mkswap /home/swap 1.22 + add_swap_in_fstab /home/swap 1.23 fi 1.24 } 1.25 1.26 @@ -129,16 +138,16 @@ 1.27 1.28 # Activate an eventual swap file in /home and on local HD. 1.29 # 1.30 -if [ -f "/home/swap" ]; then 1.31 - echo "Activating swap (/home/swap) memory..." 1.32 - swapon /home/swap 1.33 -fi 1.34 if [ "`fdisk -l | grep swap`" ]; then 1.35 for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do 1.36 echo "Swap memory detected on: $SWAP_DEV" 1.37 - swapon $SWAP_DEV 1.38 + add_swap_in_fstab $SWAP_DEV 1.39 done 1.40 fi 1.41 +if grep -q swap /etc/fstab; then 1.42 + echo "Activating swap memory..." 1.43 + swapon -a 1.44 +fi 1.45 1.46 # Check for a specified locale (lang=*). 1.47 #