4


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?

4
  • Try this, 'swapon -a' and 'swapon -s' Sep 21, 2015 at 9:45
  • Thanks Ram. Don't I want to swapoff? Can you explain it little bit? I'm little bit new to this.
    – PrazSam
    Sep 21, 2015 at 9:56
  • You will need swapoff only if your swap is in use (but it won't do any harm if the swap was already off). If you just have resized your partitions, they are probably still unmounted so you don't need swapoff, but if you have restarted since then, your swap could have been mounted again. Sep 21, 2015 at 10:08
  • Yes, you can swapoff, no issue. But make sure that you turn it ON back. swapon commands makes sure that all your swap partition which is listed in /etc/fstab are turned ON & available for the system to use. Note: Its not good practice running Linux without SWAP partition Sep 21, 2015 at 10:17

1 Answer 1

5
  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
2
  • Thanks Dmitry, Are you sure that the mkswap command without specifying the uuid will work correctly? Will uuid be changed? If current uuid changes, will it effect badly to the file system?
    – PrazSam
    Sep 21, 2015 at 9:51
  • Fair remark, I have updated my answer. Personally I don't use UUIDs, but your system might. Sep 21, 2015 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .