package: starfive: Optimize the swapon partition

Check if the swap partition ("hibernation") exist or not
before swapon command.
Since the partlabel appears late, change the script
excution sequence to 99.

Signed-off-by: Mason Huo <mason.huo@starfivetech.com>
This commit is contained in:
Mason Huo
2023-04-14 10:57:39 +08:00
parent 868e6d3437
commit 8d66d14452
2 changed files with 7 additions and 2 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
#
# hibernation This shell script to turn on swap partition and
# set the image_size as big as ram size.
case "$1" in
start)
# Set the hibernation image_size as large as the ram size.
total_mem=$(cat /proc/meminfo | sed -n '1p')
echo $((${total_mem: 10: 15}*1024)) > /sys/power/image_size
FILE=/dev/disk/by-partlabel/hibernation
if [ -b "$FILE" ];then
swapon PARTLABEL="hibernation"
else
echo "No PARTLABEL=hibernation!"
fi
;;
stop)
swapoff PARTLABEL="hibernation"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0