Swap volumes created in a non rootdg/bootdg disk group are not added as swap devices during system boot on SUSE Linux.

book

Article ID: 100002322

calendar_today

Updated On:

Resolution

 
This situation occurs because disk groups other than bootdg/rootdg are imported and their volumes are started later in the boot cycle. Therefore, these secondary swap volumes are not available to be enabled automatically for secondary swap space.If possible, add any secondary swap volumes to the bootdg/rootdg disk group. If this is not possible, two options are available:
 
1. Enable the secondary swap space manually after the system has booted.
2. Add a script to the start sequence to enable the secondary swap space during boot.
 
Here is a sample procedure for automatically enabling additional swap space that is not in rootdg/bootdg.


Create a Volume Manager volume for use as a swapdevice in a non rootdg/bootdg disk group (here we use volume swapvol indatadg):

sprs1850a9-07:/etc/rc.d # vxassist -g datadg make swapvol 1g
sprs1850a9-07:/etc/rc.d # vxprint -g datadg -htq
dg datadg      default      default  0        1276866148.9.sprs1850a9-07

dm datadg01     sdc          auto    65536    20823808-

v  swapvol      -            ENABLED  ACTIVE  2097152  SELECT    -        fsgen
pl swapvol-01   swapvol      ENABLED  ACTIVE  2097152  CONCAT    -        RW
sd datadg01-01  swapvol-01   datadg010        2097152  0        sdc      ENA
sprs1850a9-07:/etc/rc.d#


Initialize the volume as a swap device:

sprs1850a9-07:/etc/rc.d # mkswap -v1/dev/vx/dsk/datadg/swapvol
Setting up swapspace version 1, size = 1073737kB
sprs1850a9-07:/etc/rc.d #


Add the volume as an active swap area:

# swapon -v /dev/vx/dsk/datadg/swapvol
swapon on/dev/vx/dsk/datadg/swapvol
sprs1850a9-07:/etc/rc.d #

Note that the volume is now listed as an active swap device:

sprs1850a9-07:/etc/rc.d #swapon-s
Filename                                Type            Size    Used    Priority
/dev/sda2                              partition       4200988 0      -1
/dev/vx/dsk/datadg/swapvol            partition       1048568 0      -2
sprs1850a9-07:/etc/rc.d #


Update /etc/fstab to indicate that the volume should be used as a swapdevice:

/dev/vx/dsk/datadg/swapvol      swap    swap            0 0


Note:  If the system is rebooted, the disk group is imported and volume started; however, the volume is NOT added as a swap device during the boot process.  It is necessary to do a few more steps.


Add a start script in the /etc/rc.d directory.

Here is a sample script that should work, although some modification may be required.  Of special interest is the "/bin/sleep 120" line.  Before adding this line, the script did not import the disk group because the vxconfigd daemon was not running when the script tried to import the disk group.  Make sure the script is executable.

sprs1850a9-07:/etc/rc.d # ls -l rc.swapon
-rwxr-xr-x 1root root 2186 Jun 23 14:55 rc.swapon          <===rc.swapon is executable
sprs1850a9-07:/etc/rc.d#

sprs1850a9-07:/etc/rc.d # more rc.swapon
#!/bin/sh
#
# If linked properly, this script will be executed after all the other init scripts.
#
# For example:
#              /etc/rc.d/rc3.d/S10swapon->../rc.swapon
#              /etc/rc.d/rc5.d/S10swapon->../rc.swapon

swapdg=datadg
swapvol=swapvol
swapdev=/dev/vx/dsk/datadg/swapvol

case "$1" in
   start)

   /bin/echo "Begin adding secondary swap" > /tmp/rc-swapon.out
   /bin/sleep 120

#Check the diskgroup is imported

   /usr/sbin/vxdg list | awk'{print $1}' | grep $swapdg >> /tmp/rc-swapon.out
   if [ $?-ne 0 ] ; then
   # diskgroup is not imported, so run vxdctl enable and try to import it.
       /bin/echo "Diskgroup for secondary swap volume is not imported - will try to import it">> /tmp/rc-swapon.out
       /usr/sbin/vxdctl enable
       /usr/sbin/vxdisk list &>/tmp/rc-swapon2.out

       /usr/sbin/vxdg import$swapdg
       if [ $? -ne 0 ] ;then
           /bin/echo "Unable to import secondary swap disk group - secondary swap not added" >>/tmp/rc-swapon.out
           /usr/sbin/vxprint -o alldgs list 2>&1/tmp/rc-swapon2.out
           exit1
       fi
   fi

# Check the volume is started

   /usr/sbin/vxprint -qtrg $swapdg $swapvol| grep ^v | awk '{print $4}' | grep ENABLED >>/tmp/rc-swapon.out
   if [ $? -ne 0 ] ; then
   #volume is not started, so start it
       /usr/sbin/vxrecover -g $swapdg-bs
       /usr/sbin/vxprint -qtrg $swapdg $swapvol |grep ^v | awk '{print $4}' | grep ENABLED >>/tmp/rc-swapon.
out
       if [ $? -ne 0 ] ;then
           /bin/echo "Unable to recover secondary swap volume - secondary swap not added" >>/tmp/rc-swapon.out
           exit 1
       fi
   fi

# Add secondary swap

   /sbin/swapon $swapdev &>/dev/null
   if [ $? -ne 0 ] ;then
       echo "Unable to add secondary swap; swapon failed" >> /tmp/rc-swapon.out
       exit 1
   fi

   /bin/echo "Finish adding secondary swap" >>/tmp/rc-swapon.out

       ;;

   stop)

#Turn off the swapping on the secondary device.  Don't try to deport the disk group since other volumes might still be in use.

       /sbin/swapoff $swapdev
       ;;

   *)
       /bin/echo "Usage: $0 {start|stop}"
       exit 1
       ;;
esac
sprs1850a9-07:/etc/rc.d#


Add the appropriate links to the desired run levels.  Here there are links in rc3.d and rc5.d

sprs1850a9-07:/etc/rc.d#
sprs1850a9-07:/etc/rc.d # ls -l rc*.d/*swapon
lrwxrwxrwx 1 root root 12Jun 22 08:29 rc3.d/S10rc.swapon -> ../rc.swapon     <=== links are executable
lrwxrwxrwx 1 root root 12 Jun 22 08:29 rc5.d/S10rc.swapon-> ../rc.swapon
sprs1850a9-07:/etc/rc.d #


Use chkconfig to enable the rc.swapon script.

Just adding the links to the appropriate run level directories (for example rc3.d and rc5.d) does not enable therc.swapon script.  Use the chkconfig command to do this; for example:


sprs1850a9-07:/etc/rc.d # chkconfig -l | grep rc.swapon
rc.swapon                0:off  1:off  2:off  3:off  4:off  5:off  6:off    <=== rc.swapon is "off" for all run levels.
sprs1850a9-07:/etc/rc.d#
sprs1850a9-07:/etc/rc.d # chkconfig rc.swapon on
sprs1850a9-07:/etc/rc.d#
sprs1850a9-07:/etc/rc.d # chkconfig -l | grep rc.swapon
rc.swapon                0:off  1:off  2:off  3:on   4:off  5:on  6:off     <=== rc.swapon is "on" for run levels 3 and5.

sprs1850a9-07:/etc/rc.d #


Hints for debugging.

Check the debug output in the /tmp/rc-swapon.out and tmp/rc-swapon2.out* files.  Here is an example of the message when vxconfigd is not running when the script tries to import the diskgroup.

sprs1850a9-07:~ # more /tmp/rc-swapon2.out
VxVM vxdisk ERRORV-5-1-684 IPC failure: Configuration daemon is not accessible
sprs1850a9-07:~#


 
 

 

Issue/Introduction

Swap volumes created in a non rootdg/bootdg disk group are not added as swap devices during system boot on SUSE Linux.