How to extend a LVM swap volume?

In this case, increase by 20G:

 

Summary of commands;

cat /etc/fstab | grep swap

swapoff /dev/system/swap

lvextend -L +20G /dev/system/swap

mkswap /dev/system/swap

swapon /dev/system/swap

free -g

 

Details of above commands are below;

sdevhana01:~ # free -g

total       used       free     shared    buffers     cached

Mem:          1009         10        999          0          0          0

-/+ buffers/cache:          9        999

Swap:           31          0         31

sdevhana01:~ # cat /etc/fstab | grep swap

/dev/system/swap     swap                 swap       defaults              0 0

sdevhana01:~ # swapoff /dev/system/swap

sdevhana01:~ # free -g

total       used       free     shared    buffers     cached

Mem:          1009         10        999          0          0          0

-/+ buffers/cache:          9        999

Swap:            0          0          0

sdevhana01:~ # vgs

VG     #PV #LV #SN Attr   VSize   VFree

  system   1   2   0 wz–n- 269.83g 35.83g

sdevhana01:~ # lvextend -L +20G /dev/system/swap

Extending logical volume swap to 52.00 GiB

Logical volume swap successfully resized

sdevhana01:~ # mkswap /dev/system/swap

mkswap: /dev/system/swap: warning: don’t erase bootbits sectors

on whole disk. Use -f to force.

Setting up swapspace version 1, size = 54525948 KiB

no label, UUID=14a35aeb-6e1a-4848-a7ca-eb315e905d31

sdevhana01:~ # swapon /dev/system/swap

sdevhana01:~ # free -g

total       used       free     shared    buffers     cached

Mem:          1009         10        999          0          0          0

-/+ buffers/cache:          9        999

Swap:           51          0         51

sdevhana01:~ #

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s