Monday, May 6, 2013

Resizing partitions in Linux Ubuntu

Resizing partitions in Linux is possible and effective task although very time consuming... Let's say that you have a disk /dev/sda with three partitions and no unused space:

Primary boot partition /dev/sda1 /boot size=190MB
Extended partition /dev/sda2 that is devided into:

  • Linux swap partition /dev/sda5
  • Linux root partition /dev/sda6
We want  to increase the size of the /boot partition by reducing the size of the root partition.

We need to create a Linux startup disk or download the Linux Ubuntu desktop Live CD iso from the Ubuntu site equiped with the gparted disk utility. Alternatively you may download the gparted live iso.

Because  /boot is included in the primary volume partition, you have to pay attention in the fact that after resizing/shrinking extended partition it is not possible to Move the Extended partition in the end of the volume (or move the empty space before  the extended partition!!! The task is accomplished with the steps below:
  1. Boot from the Live/Startup CD
  2. Run gparted
  3. Resize/shrink the last /dev/sda6 root partition as much as you wish in order to free space to transfer to your boot partition
  4. Move the /dev/sda6 root partition to the end of the volume
  5. Move the swap partition /dev/sda5 right before the /dev/sda6 partition with no empty space between them. Now the empty space was moved in the start of the extended partition /dev/sda2
  6. Resize the extended partition to free-up the unused space. Now the unused space was moved before the extended partition i.e. in the primary partition.
  7. Resize the primary boot partition to include the empty space
The whole process took about 4 to 5h for a 120Gb volume. It is a good practice to ensure that the power will be uninteruptible (e.g. using a UPS) or pray not to have a power outage during this procedure... Good luck!

No comments:

Post a Comment