In certain situations you may need to increase the swap space on your linux server. For example, installing new version of Oracle on an existing linux server.
Linux has two types of swap space:
1) The swap partition. The swap partition is an independent section of the hard disk used solely for swapping; no other files can exist there.
2) The swap file. The swap file is a special file in the filesystem that exists with your other files.
Below steps are showing how to increase space swap space by adding another swap partition using logical volume.
All these steps has to be done as root user.
1. Create a logical volume
Pre-req: Enough free space must be available on volume group.
a) open logical volume manager using system-config-lvm
b) Click on logical view
c) Click on "Create New Logical Volum Button"
d) Give the LV name like "swap2"
e) Specify the size required in GBs
f) Keep all other values unchanged and click OK to create volume
g) Note down the new logical volume full path (ex: /dev/vgdata/swap2) from voluem properties and close the GUI.
2. Format the newly created volume with swap file system
a) # mkswap </full/path to/new volume>
ex: mkswap /dev/vgdata/swap2
3. Activate the new swap
a) # swapon </full/path to/new volume>
ex: swapon /dev/vgdata/swap2
4. Add the following line to fstab to persist swap configuration after re-boot.
</full/path to/new volume> swap swap defaults 0 0
ex: /dev/vgdata/swap2 swap swap defaults 0 0
5. verify the swap
a) free -m
b) cat /proc/swaps
Linux has two types of swap space:
1) The swap partition. The swap partition is an independent section of the hard disk used solely for swapping; no other files can exist there.
2) The swap file. The swap file is a special file in the filesystem that exists with your other files.
Below steps are showing how to increase space swap space by adding another swap partition using logical volume.
All these steps has to be done as root user.
1. Create a logical volume
Pre-req: Enough free space must be available on volume group.
a) open logical volume manager using system-config-lvm
b) Click on logical view
c) Click on "Create New Logical Volum Button"
d) Give the LV name like "swap2"
e) Specify the size required in GBs
f) Keep all other values unchanged and click OK to create volume
g) Note down the new logical volume full path (ex: /dev/vgdata/swap2) from voluem properties and close the GUI.
2. Format the newly created volume with swap file system
a) # mkswap </full/path to/new volume>
ex: mkswap /dev/vgdata/swap2
3. Activate the new swap
a) # swapon </full/path to/new volume>
ex: swapon /dev/vgdata/swap2
4. Add the following line to fstab to persist swap configuration after re-boot.
</full/path to/new volume> swap swap defaults 0 0
ex: /dev/vgdata/swap2 swap swap defaults 0 0
5. verify the swap
a) free -m
b) cat /proc/swaps
No comments:
Post a Comment