swap in Solaris 11

  • -s To view the summary of the current swap space allocation:# swap -s total: 106256k bytes allocated + 8512k reserved = 114768k used, 587512k available
  • -l  To list details of the system’s virtual swap space:

    # swap -l
    swapfile dev swaplo blocks free
    /dev/dsk/c0t0d0s1 136,1 16 1206736 1084736
    /export/data/swapfile -16 40944 40944
     
  • -d To delete a swap slice or swap slice from the current swap configuration.# swap -d /dev/dsk/c1t0d0s3
     To prevent the swap slice from being configured as part of the swap configuration during a reboot or change of run level, edit the /etc/vfstab file, and remove the swap slice entry from the file.Operations on swap file are similar to operation on swap slice:
    • Delete a swap file from the current swap configuration.
      # swap -d /export/data/swapfile
       
    • Remove the file to free the disk space that it is occupying.# rm /export/data/swapfile
    • To prevent the swap file from being configured as part of the swap  configuration during a reboot or change of run level, edit the /etc/vfstab file, and remove the swap file entry.

      Note – The output of the df -h /export/data/swapfile command shows the space in use until you remove the swap file.
  • -a To add additional swap area
    • To add a swap slice Edit the /etc/vfstab file to add information describing the swap slice.  # vi /etc/vfstab #device device mount FS fsck mount mount #to mount to fsck point type pass at boot optAdd the following line to create the swap slice./dev/dsk/c1t0d0s3 --swap -no -Use the swap -a command to add additional swap area.# swap -a /dev/dsk/c1t0d0s3Note – When the system is subsequently rebooted, the new swap slice /dev/dsk/c1t0d0s3 will be automatically included as part of the swap space as a result of adding the entry to the /etc/vfstab file.  
    • Adding Swap Files. Swap files can be used when you need to add swap space and do not have a free partition to use. To add a swap file, complete the following steps:
      1. Create a 1G swap file named swapfile in the partition that have enough free space, for example /export/data directory.# mkfile 1000m /export/data/swapfile
      2. Add the swap file to the system’s swap space.# swap -a /export/data/swapfile
      3. List the details of the modified system swap space with swap -l
      4. List a summary of the modified system swap space with swap -s
      5. To use a swap file when the system is subsequently rebooted, add an entry for the swap file in the /etc/vfstab file.# vi /etc/vfstab
        #device device mount FS fsck mount mount
        #to mount to fsck point type pass at boot opt
        /export/data/swapfile –swap -no –