69 lines
1.2 KiB
Bash
Executable File
69 lines
1.2 KiB
Bash
Executable File
#! /sbin/sh
|
|
#Tag 0x00000f00
|
|
|
|
# Add/Delete swap files other than /dev/swap
|
|
# "$Revision: 1.13 $"
|
|
|
|
cd /
|
|
|
|
case $1 in
|
|
'start')
|
|
if /sbin/chkconfig verbose
|
|
then
|
|
echo "Adding swap areas declared in /etc/fstab\c"
|
|
fi
|
|
|
|
# Mount swap according to file system table /etc/fstab.
|
|
# Example:
|
|
# /swap/1 swap swap pri=3 0 0
|
|
#
|
|
/sbin/suattr -C CAP_SWAP_MGT+ip -c "/sbin/swap -m"
|
|
|
|
if /sbin/chkconfig verbose
|
|
then
|
|
echo "."
|
|
fi
|
|
|
|
if /sbin/chkconfig vswap
|
|
then
|
|
vswaplen=80000
|
|
if [ -s /etc/config/vswap.options ] ; then
|
|
. /etc/config/vswap.options
|
|
fi
|
|
#
|
|
# for now don't let users override vswapfile since an error
|
|
# could be costly because of the rm -rf below
|
|
#
|
|
vswapfile=/.swap.virtual
|
|
if /sbin/chkconfig verbose ; then
|
|
echo "Adding virtual swap."
|
|
fi
|
|
if [ ! -f ${vswapfile} ] ; then
|
|
rm -rf ${vswapfile}
|
|
fi
|
|
touch ${vswapfile}
|
|
/sbin/suattr -C CAP_SWAP_MGT+ip -c "/sbin/swap -a -v${vswaplen} ${vswapfile} 0 0"
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
'stop')
|
|
if /sbin/chkconfig verbose
|
|
then
|
|
echo "Removing swap areas\c"
|
|
fi
|
|
|
|
/sbin/suattr -C CAP_SWAP_MGT+ip -c "/sbin/swap -u"
|
|
|
|
if /sbin/chkconfig verbose
|
|
then
|
|
echo "."
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo "usage: /etc/init.d/swap {start|stop}"
|
|
;;
|
|
esac
|