此脚本首先检查 Linux 交换签名,然后在其上恢复 Windows 文件系统。
(改编自 H. Peter Anvin 的原始交换空间 HOWTO)
#!/bin/sh
#
# swaphalt.sh This file is executed through the /etc/rc.d/init.d/halt
# script after swapping and accounting has been turned off.
#
# Author: Rahul U. Joshi
#
# check swap partition signature and restore Windows swap info
loopcount=0
# flag to indicate whether the swap info has been restored or not
restored=0
# check for swap signature 3 times before giving up
while [ $loopcount -lt 3 ]
do
if [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=10 skip=4086`" = 'SWAP-SPACE' ]; then
echo "Restoring DOS/Windows swap info , iteration $loopcount"
/bin/zcat /etc/winswap.gz > /dev/winswap
restored=1
break
else
loopcount=loopcount+1
fi
done
if [ $restored -ne 1 ] ; then
echo "Swap signature not found after $loopcount tries"
echo "Skipping restoring"
fi