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 a strange problem with my VDI based drive in VirtualBox, which is that the drive does not expand and this has for some reason also resulted in my x not being able to load.

df -H
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       4.3G  4.3G     0 100% /
udev            1.1G  4.1k  1.1G   1% /dev
tmpfs           421M  750k  420M   1% /run
none            5.3M     0  5.3M   0% /run/lock
none            1.1G     0  1.1G   0% /run/shm
none            105M  8.2k  105M   1% /run/user
overflow        1.1M     0  1.1M   0% /tmp

And the drive size:

enter image description here

Is there a way for Ubuntu to reallocate its actual space?

GParted: enter image description here

Attempt to expand not possible: enter image description here

share|improve this question
What is the size of /dev/sda reported by something like disk or fdisk? – Pavel A Feb 5 '13 at 9:57

I guess the problem here is that you have created a very small partition for / that has now run out of space. To solve your problem you need to expand the root partition (/dev/sda1 and filesystem on it). To do that, I'd go this way:

  1. Boot your VM from a live CD
  2. and extend /dev/sda1 (together with the FS) using GParted - it will take care of everything.

As for me the above approach is little more safe, however you can handle this without live CD as well - have a look at Søren Løvborg's answer here - How to resize a ext4 root partition at runtime? or if it is just the matter of resizing a partition, then CodeAddict's answer.

share|improve this answer
It seems that my VirtualBox resizing did work, but im unable to resize in GParted. Images updated in main question. – JavaCake Feb 5 '13 at 10:24
@JavaCake, before extending /dev/sda1 you need to shrink /dev/sda2 first. To do that you may have to move /dev/sda5 somewhat to the right as well. – Pavel A Feb 5 '13 at 10:41
im not sure if i entirely understand what you mean. I assume that /dev/sda5 is the LiveCD and /dev/sda1 is the my main drive which i need to extend. – JavaCake Feb 5 '13 at 10:44
@JavaCake no, all /dev/sda* are partiotions of /dev/sda hard drive. What I meant was that you have to shrink the extended partition /dev/sda2 to be able to extend the primary /dev/sda1. – Pavel A Feb 5 '13 at 11:05
Why?. sda5 is only 4 Gib. It looks to me that he only needs to move sda5 to the end of the drive (to the right on gparted) to be able to resize sda1. – Javier Rivera Feb 6 '13 at 8:26
up vote 3 down vote accepted

By using GParted i simply copied the partition i wanted to resize and pasted it into the unallocated partition and resized it. It started copying the partition over and problem was solved.

Since i have already done this i am unable to viualize by screenshots, but there is an copy and paste function when you right click on a partition, so the procedure is simply:

  1. Right click on the partition you wish to expand and click on Copy
  2. Right click on the unallocated partition and click Paste.
  3. A screen should popup where you can set the new size
  4. GParted will start copying the partition into the new resized partition
  5. Test the new partition before deleting the old one.

An image of the right click menu:

enter image description here

As you can see on the image above /dev/sda1 is the old partition that was too small. The new partition which i am booting from currently is /dev/sda3.

If you delete your old partition, you will need to install grub in the new one (no, it isn't copied together with your data). Boot with a live CD and run the following commands:

sudo mount /dev/sda3 /mnt  
sudo grub-install --root-directory=/mnt /dev/sda
share|improve this answer
Can you boot from it? I have never done something like this before. Can you, please, post how it looks like in GParted now? – Pavel A Feb 5 '13 at 11:06
I did not think it was possible at first glance, but then i noticed the "copy/paste" options. I will post an image. – JavaCake Feb 5 '13 at 13:25
okay, I see now - thank you for the edit. However this approach has 2 drawbacks: 1. you have to reconfigure the system to boot from another partition; 2. you have to copy the whole partition (in this case 4.3GB), while extending a partition to an unallocated space is pretty much effortless (it may be that you had to recreate swap at the end of the extended partition, but its number should have remained the same). Besides that, your solution is still interesting, since it is new (at least for me). Cheers! – Pavel A Feb 5 '13 at 14:12
@PavelA, i had no luck with the other approaches, which bothers me since they seem quite approved, but since i only had 4GB data and it took under 3minutes i survived. – JavaCake Feb 5 '13 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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