Expanding a (used) Virtualbox disk

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Expanding a (used) Virtualbox disk

Postby viking60 » 14 Sep 2015, 13:47

Image
We all know the problem your disk gets full and on some distros (like Suse) that does fubar your upgrade. It is not a good thing so we start expanding partitions with Gparted (on the Viking multi rescue disk) to make room or you start to delete stuff to make room etc.

In Virtualbox you get the same problem but here you can simply increase the size of you Virtual disk to make space - so after having fubared a Suse upgrade that took way to much space on my 8 G Virtual disk; I decided to make it bigger.

It is the same thing as buying a bigger hard disk so I bought myself a 15 G hard disk like this:

First I found the name of the disk under storage in the Virtualbox control panel.
Then I found that disk - which is actually a file - in ~/.VirtualBox/HardDisks/
In my case the hard disk was called Centos64_bit.vdi

Yes I know I have Suse on it but that is what I called it when I created it - it does not matter.

So time to enter the magic command then:

Code: Select all

VBoxManage modifyhd /home/viking/.VirtualBox/HardDisks/Centos64_bit.vdi --resize 15480

And that was it ! The hard disk was resized to 15G!

I logged in to Suse in VB and it was all there but I had not gotten more space though. :f

Even if it is a Virtual Machine we have to resize the partition so I booted the VM with the Viking Ultimate rescue DVD and fired up Systemrescuecd and there i Started Gparted.
And true enough there was a 6 G unused partition there so I simply stretched it with Gparted and hit that green execute check thing.

And it failed.. due to unsuccessful file system check.

Now Suse is btrfs but repeated attempts simply did not go through so I decided to do it the Cli way:

First I made a directory

Code: Select all

mkdir /mnt/suse

Then I checked in Gparted where the Suse install was - and it was in /dev/sda2 so I mounted it like this:

Code: Select all

mount -t btrfs /dev/sda2 /mnt/suse

Then I went to /mnt/suse and the Suse files were there.

Here I did the good old

Code: Select all

fsck -t btrfs

And it went so fast I thought I had done something wrong so I did it several times.

Then I went back to Gparted ans stretched the partition again ... and this time it went through with flying colors.

Time to reboot then..
And the Suse install was still there with lots of additional disk space :B

The Viking Ultimate rescue Multi DVD saved the day +1
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

Return to “Tips & Tricks”