Sie sind auf Seite 1von 3

Swap Management in Solaris

A systems virtual memory is a combination of RAM and disk space. Portions of the virtual
memory are reserved as swap space.

Swap space can be dened as a temporary storage location that is used when the systems
memory requirements exceed the size of available RAM.

# swap -s ==> to list a summary of the systems virtual swap space

# swap -l ==> to list the details of the systems physical swap areas

Note There can be a discrepancy in available and free swap space size between the swap -s and
swap -l outputs. The swap -s output does not take into account pre-allocated swap space that has
not yet been used by a process.

Adding Swap Slices:

1. Edit the /etc/vfstab le to add information describing the swap slice

# vi /etc/vfstab

2. Add the following line to create the swap slice

/dev/dsk/c1d0s1 - - swap - no -

3. Use the swap -a command to add additional swap area

# swap -a /dev/dsk/c1d0s1

Note When the system is subsequently rebooted, the new swap slice /dev/dsk/c1t3d0s1 is
automatically included as part of the swap space as a result of adding the entry to the /etc/vfstab
le.
Adding Swap Files:

1. Identify a le system that has adequate space to create an additional swap le, preferably on
another drive.

2. Make a directory to hold the swap le.

# mkdir -p /usr/local/swap

3. Create a 20-Mbyte swap le named swapfile in /usr/local/swap directory.

# mkfile 20m /usr/local/swap/swapfile

4. Add the swap le to the systems swap space.

# swap -a /usr/local/swap/swapfile

5. List the details of the modied system swap space.

# swap -l

6. List a summary of the modied system swap space.

# swap -s

7. To use a swap le when the system is subsequently rebooted, add an entry for the swap le in
the /etc/vfstab le.

# vi /etc/vfstab

/usr/local/swap/swapfile - - swap - no -

Removing Swap Slices:


1. Delete a swap slice from the current swap conguration.

# swap -d /dev/dsk/c1d0s1

2. To prevent the swap slice from being congured as part of the swap conguration during a
reboot or change of run level, edit the /etc/vfstab le, and remove the swap slice entry from the
le.

< !--[if !supportLineBreakNewLine]-->


< !--[endif]-->

Removing Swap Files:

1. Delete a swap le from the current swap conguration.

# swap -d /usr/local/swap/swapfile

2. Remove the le to free the disk space that it is occupying.

# rm /usr/local/swap/swapfile

3. To prevent the swap le from being congured as part of the swap conguration during a
reboot or change of run level, edit the /etc/vfstab le, and remove the swap le entry.

Note The output of the df -h command shows the space used by the swap le until it is
removed.