Difference between revisions of "Manipulating swap space on a running Solaris system"

From Peter Pap's Technowiki
Jump to: navigation, search
(Adding swap space)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
 
== Listing swap files in use ==
 
== Listing swap files in use ==
  
Line 29: Line 28:
 
      
 
      
 
   swap -l
 
   swap -l
 +
 
 
   swapfile            dev  swaplo blocks  free
 
   swapfile            dev  swaplo blocks  free
 
   /dev/md/dsk/d10    85,10    16 8389632 8389632
 
   /dev/md/dsk/d10    85,10    16 8389632 8389632
 
   /export/tempfile      -      16 6291440 6291440
 
   /export/tempfile      -      16 6291440 6291440
 +
  
 
== Delete a swap file ==
 
== Delete a swap file ==
Line 38: Line 39:
  
 
   swap -d /export/tempfile
 
   swap -d /export/tempfile
 +
 +
 +
 +
== Adding Swap space to a system with ZFS root pool ==
 +
 +
So the system you're running is using as ZFS based root pool to boot.  In order to add swap space above what the system was built with you will need to first create a new ZFS pool and then add it to swap:
 +
 +
1. Create a new ZFS pool
 +
 +
  zfs create -V 2G rpool/swap2
 +
 +
2. Add the file associated with the new pool to the running swap space
 +
 +
  swap -a /dev/zvol/dsk/rpool/swap2
 +
 +
As per usual the added swap space will disappear after a reboot, but you'll have to manually delete the new ZFS pool you've created.
 +
 +
If you want to make a permanent change to the size of swap, you can do the following:
 +
 +
  zfs set volsize=4G rpool/swap
 +
 +
This will of course change the size of swap to 4Gb.  On reboot it will become available.
 +
 +
To get rid of the extra swap space you've create:
 +
 +
  zfs destroy rpool/swap2

Latest revision as of 00:58, 17 May 2011

Listing swap files in use

The following command will list all active swap files:

  swap -l

with output looking like this:

  swapfile             dev  swaplo blocks   free
  /dev/md/dsk/d10     85,10     16 8389632 8389632


Adding swap space

So you need more swap temporarily. Here's how:

1. Make a file to add to swap

  mkfile 2g /export/tempfile

This will crate a 2Gb file.

2. Add the file to the swap pool

  swap -a /export/tempfile

then check it worked with

  swap -l
  
  swapfile             dev  swaplo blocks   free
  /dev/md/dsk/d10     85,10     16 8389632 8389632
  /export/tempfile      -       16 6291440 6291440


Delete a swap file

Finished with your temporary swap file. Delete it:

 swap -d /export/tempfile


Adding Swap space to a system with ZFS root pool

So the system you're running is using as ZFS based root pool to boot. In order to add swap space above what the system was built with you will need to first create a new ZFS pool and then add it to swap:

1. Create a new ZFS pool

 zfs create -V 2G rpool/swap2

2. Add the file associated with the new pool to the running swap space

 swap -a /dev/zvol/dsk/rpool/swap2

As per usual the added swap space will disappear after a reboot, but you'll have to manually delete the new ZFS pool you've created.

If you want to make a permanent change to the size of swap, you can do the following:

 zfs set volsize=4G rpool/swap

This will of course change the size of swap to 4Gb. On reboot it will become available.

To get rid of the extra swap space you've create:

 zfs destroy rpool/swap2