Search This Blog

Sunday, July 19, 2015

How to use the swapoff command



This article explains the features of the HP-UX 11i v3 swapoff command incorporated on the September 2008 release. This command provides the ability to remove swap devices without rebooting the system. This feature is enabled by the command and an enhanced system call swapctl(2):

"The HP-UX Swapoff command, swapoff(1M), is a Software Pack product and is delivered as an optional product on all Operating Environments. For more information about Software Pack, see ?Software Pack (Optional HP-UX 11i v3 Core Enhancements)".
The swapctl(2) system call has been enhanced through patches delivered in the FEATURE11i patch bundle.

Contents

1 Abstract
2 Procedure
3 Usage
4 Example
5 Reference
6 Authors

Procedure

This enhancement to the swapctl(2) is automatically delivered through a patch in the September 2008 FEATURE11i bundle. To add the swapon installation of the Swapoff Enhancement bundle is required. This bundle is available on current DVD media and for download at the Software Depot website:

HP-UX Swapoff
1. Verified that the HP-UX 11i v3 has installed the FEATURE11i bundle.

# swlist -l bundle | grep -e HPUX11i -e FEATURE11i

  FEATURE11i            B.11.31.0809.326a Feature Enablement Patches for HP-UX 11i v3, September 2008

  HPUX11i-VSE-OE        B.11.31.0803   HP-UX Virtual Server Operating Environment

2. Install the swapoff bundle.

# swinstall -s /var/tmp/swapoff_B.11.31.0809.02_HP-UX_B.11.31_IA_PA.depot \*

=======  11/08/08 22:41:59 MST  BEGIN swinstall SESSION
         (non-interactive) (jobid=zx6000-0015)

       * Session started for user "root@zx6000".

       * Beginning Selection
       * Target connection succeeded for "zx6000:/".
       *
         "zx6000:/var/tmp/swapoff_B.11.31.0809.02_HP-UX_B.11.31_IA_PA.depot":
         Cannot open the logfile on this target or source.  Possibly
         the media is read-only or there is a permission problem.
         Check the daemon logfile and "/var/tmp/swagent.log" on this
         host for more information.
       * Source:
         /var/tmp/swapoff_B.11.31.0809.02_HP-UX_B.11.31_IA_PA.depot
       * Targets:                zx6000:/
       * Software selections:
             swapoff,r=B.11.31.0809.02,a=HP-UX_B.11.31_IA/PA,v=HP
             Swapoff.SWAPOFF,r=B.11.31.0809.02,a=HP-UX_B.11.31_IA/PA,v=HP,fr=B.11.31.0809.02,fa=HP-UX_B.11.31_IA
             Swapoff.SWAPOFF-ENG-MAN,r=B.11.31.0809.02,a=HP-UX_B.11.31_IA/PA,v=HP,fr=B.11.31.0809.02,fa=HP-UX_B.11.31_IA
       * Selection succeeded.


       * Beginning Analysis and Execution
       * Session selections have been saved in the file
         "/.sw/sessions/swinstall.last".
       * The analysis phase succeeded for "zx6000:/".
       * The execution phase succeeded for "zx6000:/".
       * Analysis and Execution succeeded.


NOTE:    More information may be found in the agent logfile using the
         command "swjob -a log zx6000-0015 @ zx6000:/".

=======  11/08/08 22:42:26 MST  END swinstall SESSION (non-interactive)
         (jobid=zx6000-0015)
Usage

Complete details of the usage of the swapoff command is described on it's manpage.

# man swapoff

 swapoff(1M)                                                     swapoff(1M)

 NAME
      swapoff - online disabling of swap device

 SYNOPSIS
      /usr/sbin/swapoff device ...

 DESCRIPTION
      The swapoff command disables swapping on the specified swap device(s)
      for the current boot.  (NOTE: the term swap refers to an obsolete
      implementation of virtual memory; HP-UX actually implements virtual
      memory by way of paging rather than swapping.  This command and others
      retain names derived from swap for historical reasons.)

    Notes
      +    The swapoff command will not remove entry from /etc/fstab for the
           device.  The /etc/fstab file needs to be modified to remove the
           device entries.

      +    The swapoff command is guaranteed to disable the swap devices for
           the current boot only when the devices were enabled for swapping
           through swapon (see swapon(1M).

      +    A swap device will not be disabled if the current available
           system swap space without the device is not sufficient for the
           system to operate.

 RETURN VALUE
      swapoff returns one of the following values:

            0   Successful completion.
           >0   Error condition occurred.

 EXAMPLE
      The following example disable paging on block device

           /usr/sbin/swapoff /dev/dsk/c10t0d0

 AUTHOR
      swapoff was developed by HP.

 SEE ALSO
      swapinfo(1M), swapon(1M), swapctl(2), fstab(4).

 Hewlett-Packard Company            - 1 -      HP-UX 11i Version 3: May 2008
Example

The following example demonstrates the usage of the swapoff to remove swap devices without rebooting the system, an LVM logical volume is used as swap device for the demonstration.

# swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev       12288       0   12288    0%       0       -    1  /dev/vg00/lvol2
reserve       -     391    -391
memory     1938     628    1310   32%
total     14226    1019   13207    7%       -       0    -

# lvcreate -L 1024 -n swap2 /dev/vg01
Logical volume "/dev/vg01/swap2" has been successfully created with
character device "/dev/vg01/rswap2".
Logical volume "/dev/vg01/swap2" has been successfully extended.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

# swapon -p 1 /dev/vg01/swap2

# swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev       12288       0   12288    0%       0       -    1  /dev/vg00/lvol2
dev        1024       0    1024    0%       0       -    1  /dev/vg01/swap2
reserve       -     391    -391
memory     1938     628    1310   32%
total     15250    1019   14231    7%       -       0    -

# swapoff /dev/vg01/swap2

# swapinfo -tam
             Mb      Mb      Mb   PCT  START/      Mb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev       12288       0   12288    0%       0       -    1  /dev/vg00/lvol2
reserve       -     391    -391
memory     1938     628    1310   32%
total     14226    1019   13207    7%       -       0    -

# lvremove /dev/vg01/swap2
The logical volume "/dev/vg01/swap2" is not empty;
do you really want to delete the logical volume (y/n) : y
Logical volume "/dev/vg01/swap2" has been successfully removed.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

Thank you for Reading,
For Reading other article, visit to “https://sites.google.com/site/unixwikis/

No comments:

Post a Comment