(M)  s i s t e m a   o p e r a c i o n a l   m a g n u x   l i n u x ~/ · documentação · suporte · sobre

  Next Previous Contents

10. The swaphalt.sh script

This script first checks the Linux swap signature and then restores the Windows file system on it.

(Adapted from the original Swap-Space-HOWTO by H. Peter Anvin)

 
#!/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 
 

Next Previous Contents