Enable swap for haliburton device. (#11746)
Signed-off-by: Xichen Lin <lukelin0907@gmail.com> Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
This commit is contained in:
parent
64ce6696bb
commit
a16843a67c
@ -11,6 +11,26 @@
|
|||||||
# Short-Description: Setup Haliburton board.
|
# Short-Description: Setup Haliburton board.
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
|
setup_swap () {
|
||||||
|
SWAPFILE=/host/myswapfile
|
||||||
|
|
||||||
|
if [ ! -f $SWAPFILE ]; then
|
||||||
|
availspace=`df -h --output=avail /host | sed '1d;s/\s//g;s/[^0-9].*//g'`
|
||||||
|
diff=$(( availspace - 2*$1 ))
|
||||||
|
if [ $diff -gt 0 ]; then
|
||||||
|
fallocate -l ${1}G $SWAPFILE
|
||||||
|
chmod 600 $SWAPFILE
|
||||||
|
echo "swap file created successfully"
|
||||||
|
else
|
||||||
|
echo "not enough disk space to turn on swap."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mkswap $SWAPFILE
|
||||||
|
swapon $SWAPFILE
|
||||||
|
echo "swap on successfully"
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Setting up board... "
|
echo -n "Setting up board... "
|
||||||
@ -74,6 +94,8 @@ start)
|
|||||||
|
|
||||||
/bin/sh /usr/local/bin/platform_api_mgnt.sh init
|
/bin/sh /usr/local/bin/platform_api_mgnt.sh init
|
||||||
|
|
||||||
|
setup_swap 2
|
||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user