VirtualBox drive does not expand automatically

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

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 can I resize an ext root partition at runtime? or if it is just the matter of resizing a partition, then CodeAddict's answer.