Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Ubuntu installed on a drive. The problem is it is running low on disk space. This is installed on vmware. I expanded the virtual drive and booted into ubuntu. But when I opened gparted(sudo gparted), the move/resize option is unavailable. This is the partition Ubuntu is installed on, but I need to resize it. Any ideas? I am comfortable using command line

share|improve this question
up vote 6 down vote accepted

You are almost there.
You can not resize the partition using GParted while Ubuntu is running.
You will need to attach the GParted ISO's as a CD to the VM machine and reboot the machine so that the GParted will be loaded instead of Ubuntu (I think you can boot from the virtual CD by pressing F12 immediately after machine is started).
Once you booted into GParted the option to move/resize will be enabled as Ubuntu is not currently running.

share|improve this answer

As a matter of fact, you CAN enlarge the root filesystem while Ubuntu is running (I learned this recently myself here) - this sounds incredible but it's true :)

Here's the list of steps for a simple scenario where you have two partitions, /dev/sda1 is an ext4 partition the OS is booted from and /dev/sdb2 is swap. For this exercise we want to remove the swap partition an extend /dev/sda1 to the whole disk.

  1. As always, make sure you have a backup of your data - since we're going to modify the partition table there's a chance to lose all your data if you make a typo, for example.

  2. Run sudo fdisk /dev/sda

    • use p to list the partitions. Make note of the start cylinder of /dev/sda1
    • use d to delete first the swap partition (2) and then the /dev/sda1 partition. This is very scary but is actually harmless as the data is not written to the disk until you write the changes to the disk.
    • use n to create a new primary partition. Make sure its start cylinder is exactly the same as the old /dev/sda1 used to have. For the end cylinder agree with the default choice, which is to make the partition to span the whole disk.
    • use a to toggle the bootable flag on the new /dev/sda1
    • review your changes, make a deep breath and use w to write the new partition table to disk. You'll get a message telling that the kernel couldn't re-read the partition table because the device is busy, but that's ok.
  3. Reboot with sudo reboot. When the system boots, you'll have a smaller filesystem living inside a larger partition.

  4. The next magic command is resize2fs. Run sudo resize2fs /dev/sda1 - this form will default to making the filesystem to take all available space on the partition.

That's it, we've just resized a partition on which Ubuntu is installed, without booting from an external drive.

share|improve this answer
@EliahKagan: Please have a look at the answer (from Gilles) I linked to. The idea is that it is possible to use fdisk to enlarge the partition, while the OS continues to use the smaller filesystem. Then. after a reboot, after kernel re-reads the updated partition table, we can resize the filesystem because it now lives in a larger partition. – Sergey Mar 15 '14 at 21:47
@EliahKagan: ok, you're right, I need to try it myself :) Let's see if I have a spare HDD to play with... – Sergey Mar 16 '14 at 11:30
@EliahKagan: Ok, I've tried Gilles's "recipe" and it does indeed work nicely. I've revised my answer with a detailed list of steps to enlarge a "live" partition without booting from an external medium. You may remove your downvote now ;) – Sergey Mar 16 '14 at 22:07
Great edit--thanks! – Eliah Kagan Mar 18 '14 at 0:31
@Sergey Is that also possible if the free space is before the partition to enlarge? I know the start point of the partition is important, but might it be possible to work around that? Maybe by moving/copying the first n Bytes of the partition to the new left border? – Byte Commander Feb 28 '15 at 18:17

I succeeded in enlarging my primary ext4 partiion using the methodology described here.

Some notes from my personal experience:

  • The link example is for shrinking partition, hence the order is resize2fs first and then fdisk. When enlarging partition (as in my case) the order should be fdisk first, reboot and then resize2fs. Also, when using fdisk, the primary as well as the extended partitions should be removed and re-defined.
  • I booted the ubonto from another drive and then worked on this drive which actually was mirror (using dd) of the older drive. Made it bootable using GParted
  • The current version of resize2fs (I am using ubontu 12.04LTS) support ext4 - no need to do the actions described in the link of changing it the ext2.
share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Braiam Aug 12 '13 at 5:11

protected by Community Feb 27 '15 at 18:59

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.