Professional Documents
Culture Documents
Published
by
ben
in Enterprise Linux
First of all a little disclaimer - although I've done this a few times and never had any problems, one
should never consider resizing partitions a completely foolproof exercise. Things can go wrong. With
regards to swap though, don't worry if your swap partition is destroyed as this will not harm your
system - most healthy systems will not ever need swap and unlike Windows, Linux only starts using
swap when it needs it and can quite easily survive without it. You can trash it and format it as many
times as you like as long as it's not in use. And of course take backups of any important data first!
• Is your swap on a logical volume (LVM)? If so then skip below to the LVM section. If not then
read on:
• Download gparted (Gnome Partition Manager), burn the iso and then boot into it.
• Gparted will identify the filesystems on each partition so your target will be clearly labelled as
swap.
• Reize your partitions as required. Try to minimise the overall number of resize and move
When you reboot swap not be enabled - if you check using top (or htop) orfree -m, you will see 0
mb of swap available. The reason for this is the UUID of the partition changed when it was resized by
GParted, and this confuses the system when it tries to mount the volumes in /etc/fstab. The solution
is to relabel your swap partition, by reformatting it as swap and specifying the correct label.
Make a note of the label for the swap partition from fstab:
e.g.
LABEL=SW-cciss/c0d0p3 swap
Now format your partition as swap, specifiying the label exactly as shown in the fstab.
You can then enable the swap space straight away by using swapondevicename, or just reboot and
If your swap partition is on a logical volume it can be resized without rebooting your system. However
you will need free space to extend into, if you do not have free space you will need to shrink another
volume or add another physical disk into your volume group (see this post which explains how to do
this).
lvdisplay /dev/VolGroup00/LogVol01
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID RVIFz3-B8kp-z9KV-JYtG-N997-JOQ6-ETaJaJ
LV Status available
# open 1
LV Size 512.00 MB
Current LE 24
Segments 1
Allocation inherit
swapoff /dev/VolGroup00/LogVol01
Resizing the volume to 768Mb (assuming you have the space to extend into)
swapon /dev/VolGroup00/LogVol01
free -m