2008/09/03

Resize and Reassign Swap Partition

Fact: if for some reason you resize your Linux swap partition (using a liveCD with Gparted), the next time you boot into Linux it won't use the newly resized partition.

How do you know if Linux is using the swap partition? Just type: "swapon -s", if no partition is returned, no swap partiton is being used.

Reason: the resize opearation changed the partition UUID (like a unique identifier) used to reference the partition in the fstab file by some Linux distributions (like Linux Mint) instead of the more common device id (eg. sda1).

Solution: replace the old UUID of the partition in /etc/fstab.

How to know the partition's new UUID? Type: "sudo ls -l /dev/disk/by-uuid"

By the way, if you deleted the swap partition before creating a new one in the same place, chances are Linux will assign the partition a different device id (even if the UUID remains the same). In this case Linux won't boot at all.

Solution:
  1. Boot from a liveCD
  2. Open Gparted to show the device id of your boot partition in your hard disk
  3. Create a directory in your liveCD home dir and mount your hard disk boot partition there (eg "sudo mount /dev/sda7 mynewdir")
  4. Locate /boot/grub/menu.lst (Grub's boot configuration file) in your mounted hard drive Linux boot partition
  5. Check the assigned partition parameters in each menu entry. Remember that Grub partition notation (hdn,n) is different than Linux default notatio (sdan). Eg, the sda7 notation corresponds to hd0,6 Grub notation.
Hope that's helpful :)