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 <lukelin0907@gmail.com>

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
  • Loading branch information
Xichen96 committed Sep 22, 2022
1 parent f8494d1 commit 8af369a
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 8af369a

Please sign in to comment.