Skip to content

Commit

Permalink
Enable swap for haliburton device. (#11746)
Browse files Browse the repository at this point in the history
Signed-off-by: Xichen Lin <[email protected]>

Signed-off-by: Xichen Lin <[email protected]>
  • Loading branch information
Xichen96 authored and qiluo-msft committed Oct 3, 2022
1 parent 64ce669 commit a16843a
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
# Short-Description: Setup Haliburton board.
### 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
start)
echo -n "Setting up board... "
Expand Down Expand Up @@ -74,6 +94,8 @@ start)

/bin/sh /usr/local/bin/platform_api_mgnt.sh init

setup_swap 2

echo "done."
;;

Expand Down

0 comments on commit a16843a

Please sign in to comment.