Expand the size of swap partition

swap

I did some partition size expansions of my centOs system and recover boot loader and file system successfully.I also changed the location and expanded the swap (5GB to 8GB) partition along with above deeds. Now the file system looks like this.

enter image description here

The problem is swap doesn't show it's full size. (look at the red circle. thought the used space is 0, unused space is still 5GB ). I want to fix this.

Here is the result of free -m

[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3711        700       3010          0         71        298
-/+ buffers/cache:        330       3380
Swap:         4999          0       4999

Here is the uuid of swap

/dev/sda7: UUID="52485c83-3929-4f5b-bd1c-60492ebd1e5c" TYPE="swap"

will the command mkswap -U 52485c83-3929-4f5b-bd1c-60492ebd1e5c help me here. Else what must I do?

Best Answer

  1. Disable the swap with swapoff /dev/sda7
  2. Re-initialize the swap partition to use its full size: mkswap /dev/sda7
  3. Re-enable the swap: swapon /dev/sda7

Note that mkswap generates a new partition UUID when run. This can prevent the new swap partition from being used normally, if it is referenced by UUID in /etc/fstab or elsewhere. If you want to keep the original UUID for your swap partition, you can specify that in step 2:

mkswap -U 52485c83-3929-4f5b-bd1c-60492ebd1e5c /dev/sda7
Related Question