©2015 -
HOW TO ADD SWAP SPACE IN SOLARIS
Quite often when you install a software, it would do a pre-
How to add swap file in Solaris UFS
How to remove swap file in Solaris UFS
How to add or resize swap space in Solaris ZFS
HOW TO ADD SWAP FILE IN SOLARIS UFS
1. Check current swap usage and size:
# swap -
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 136,1 16 1040384 1040384
# swap -
total: 25344k bytes allocated + 5472k reserved = 30816k used, 1331024k available
2. Locate a mount point with disk space for the additional swap file.
oracle>df -
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 10326052 10313752 0 100% /
/proc 0 0 0 0% /proc
mnttab 0 0 0 0% /etc/mnttab
fd 0 0 0 0% /dev/fd
swap 1325440 40 1325400 1% /var/run
swap 1325416 16 1325400 1% /tmp
/dev/dsk/c0t0d0s3 66099228 10341225 55097011 16% /space
* In this example, /space has more available disk space.
3. Create a file for use as UNIX swap file.
# mkfile 2048m /space/swapfile
4. Activate the file as a swap file.
# /usr/sbin/swap -
5. Verify swap list.
# swap -
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 136,1 16 1040384 1040384
/space/swapfile -
# swap -
total: 26160k bytes allocated + 5720k reserved = 31880k used, 3422408k available
6. Make the swap file available during reboot by declaring it in
/etc/vfstab file.
# cp vfstab vfstab.bak1
# vi vfstab
"vfstab" 10 lines, 323 characters
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/proc -
fd -
swap -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /space ufs 1 yes -
/dev/dsk/c0t0d0s1 -
/space/swapfile -
HOW TO REMOVE A SWAP FILE IN SOLARIS UFS
1. Become root.
2. Remove the swap space.
# /usr/sbin/swap -
3. Edit /etc/vfstab and remove the entry of swap file.
4. Recover the disk space.
# rm /space/swapfile
HOW TO ADD OR RESIZE SWAP SPACE IN SOLARIS ZFS
Note: you must be root to perform the tasks.
1. Check existing swap volume and determin if it is currently in use (free size is lower than total blocks size).
example:
root@s111oem:~# swap -
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 285,2 8 4194296 4194296
2. Resize the swap volume.
If the swap is _not_ in use, proceed to resize existing volume.
example resize to 12gb:
root@s111oem:~# zfs get volsize rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap volsize 2G local
root@s111oem:~# zfs set volsize=12g rpool/swap
root@s111oem:~# zfs get volsize rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap volsize 12G local
root@s111oem:~#
root@s111oem:~# swap -
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 285,2 8 4194296 4194296
/dev/zvol/dsk/rpool/swap 285,2 4194312 20971512 20971512
root@s111oem:~#
If swap is currently in use, proceed to add another swap volume.
root@s111oem:~# zfs create -
now, activate the new swap volume
root@s111oem:~# swap -
root@s111oem:~# swap -
3. If necessary, reboot the server.
shutdown -
then, verify the swap size:
root@s111oem:~# swap -
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 285,2 8 25165816 25165816
root@s111oem:~#