Skip to content

Commit a16843a

Browse files
Xichen96qiluo-msft
authored andcommitted
Enable swap for haliburton device. (sonic-net#11746)
Signed-off-by: Xichen Lin <[email protected]> Signed-off-by: Xichen Lin <[email protected]>
1 parent 64ce669 commit a16843a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.init

+22
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@
1111
# Short-Description: Setup Haliburton board.
1212
### END INIT INFO
1313

14+
setup_swap () {
15+
SWAPFILE=/host/myswapfile
16+
17+
if [ ! -f $SWAPFILE ]; then
18+
availspace=`df -h --output=avail /host | sed '1d;s/\s//g;s/[^0-9].*//g'`
19+
diff=$(( availspace - 2*$1 ))
20+
if [ $diff -gt 0 ]; then
21+
fallocate -l ${1}G $SWAPFILE
22+
chmod 600 $SWAPFILE
23+
echo "swap file created successfully"
24+
else
25+
echo "not enough disk space to turn on swap."
26+
return
27+
fi
28+
fi
29+
mkswap $SWAPFILE
30+
swapon $SWAPFILE
31+
echo "swap on successfully"
32+
}
33+
1434
case "$1" in
1535
start)
1636
echo -n "Setting up board... "
@@ -74,6 +94,8 @@ start)
7494

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

97+
setup_swap 2
98+
7799
echo "done."
78100
;;
79101

0 commit comments

Comments
 (0)