Page 1 of 1

Resize an ubuntu guest disk

Posted: 7. Jun 2013, 02:55
by MarcGirod
Hello,
I want to grow the single (hence boot, SATA port 0) disk on my ubuntu guest.
I first increased the vm from 8 to 16Gb.
Then I understand I need to use resize2fs in ubuntu.
But for this, I need to add a second disk, to boot from it, and to resize the umounted file system.
1. Is this correct?
2. How to do it?
I could add another vdi image to port 1 of the SATA controller, but couldn't find how to make my vm boot from it instead of from the initial disk.
Maybe the question is more of an ubuntu one?
I found the udisks utility, and it detects the new disk, but reports the initial sizes (or at least ignore the 16Gb).

~> udisks --enumerate
/org/freedesktop/UDisks/devices/sdb1
/org/freedesktop/UDisks/devices/sdb
/org/freedesktop/UDisks/devices/sdb2
/org/freedesktop/UDisks/devices/sdb5
/org/freedesktop/UDisks/devices/sda1
/org/freedesktop/UDisks/devices/sda2
/org/freedesktop/UDisks/devices/sda
/org/freedesktop/UDisks/devices/sda5
/org/freedesktop/UDisks/devices/sr0

Besides, in this output, in which the sdb* entries are new, it is sda1, not sdb which has a size slightly different from sda.
I must make some wrong assumptions...
Marc

Re: Resize an ubuntu guest disk

Posted: 7. Jun 2013, 03:07
by Perryg
I would use Gparted and download the live CD which you can then mount to the virtual CD of the guest and do what you need.

Re: Resize an ubuntu guest disk

Posted: 7. Jun 2013, 08:16
by bulletmark
Perryg wrote:I would use Gparted and download the live CD which you can then mount to the virtual CD of the guest and do what you need.
I've done it exactly this way a couple of times and it works well.

Re: Resize an ubuntu guest disk

Posted: 7. Jun 2013, 12:51
by mpack
Here's the download link (you just need the live cd ISO which you'll mount in the VM):
http://sourceforge.net/projects/gparted ... ve-stable/

Re: Resize an ubuntu guest disk

Posted: 7. Jun 2013, 13:12
by bulletmark
mpack wrote:Here's the download link (you just need the live cd ISO which you'll mount in the VM):
No need for that. Just boot from your ubuntu install/live cd as it includes gparted. That is what I used.

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 00:15
by MarcGirod
Hello,
Thanks for your help, but I have to confess that I don't know how to follow the instructions.
How do I boot my VBox from a different image (be it the downloaded gparted.iso, or the one under install CD--I have none: only an image)
I did download and mount the gparted image from my running session, hence too late:

tmp> sudo mkdir /gparted
tmp> sudo mount gparted-live-0.16.1-1-i686-pae.iso /gparted

I need instead to reboot from it, right?

From the VBox doc, I cannot see any suitable option to startvm...

Thanks

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 00:25
by Perryg
Shut down the guest and put the Gparted live CD in the virtual CD/DVD drive and boot the guest.
It works just like on metal in that respect.
Once you have booted you should be able to figure out what to do, or read the help files for Gparted.

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 01:46
by MarcGirod
OK. Thanks. Now I got it, and could boot the gparted disk.
Now, it only shows me the original disk (i.e. the initial 8GB); it doesn't 'see' the current 16GB reported by the VirtualBox Manager...
Besides, it displays a partition of the 8GB that make /dev/sda into 7.50GB for sd1 (ext4), and 510MB for sd2 (extended) --also used as sd5 (swap)?
Shall I be able to extend the disk without losing any data?
Should I get back to the command line to use /sbin/resize2fs?
Thanks

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 01:59
by Perryg
I don't tutor people on Gparted or any other partitioning tool. Way too many things can go wrong, and since I can't see it anything would be just a guess.
But the fact that you do not see any free space tells me you probably have snapshots, do you? If so resize will not work.
If you want to use resize2fs that is of course up to you but I would make certain that I had a good backup before trying too many things.

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 02:08
by MarcGirod
I do have snapshots, indeed...
It didn't come to my mind that this might be related.
Of course... it makes sense.
I should rather back up to a clone?

Re: Resize an ubuntu guest disk

Posted: 11. Jun 2013, 02:23
by Perryg
Make a Clone of the latest snapshot and then you can resize as you please.

Re: Resize an ubuntu guest disk

Posted: 22. Aug 2013, 09:45
by manuli
hello,

i have come so far as to boot from GParted Live image now, though now I am experiencing the following problem (see picture in attachment): between the /dev/sda1 and the unallocated space there is another one. therefore i seem to only be able to resize the middle one, but not /dev/sda1... Anyone who could help me here how to achieve that?
running guest ubuntu 12.04 on mac osx 10.8.3 host... thank you in advance!

Re: Resize an ubuntu guest disk

Posted: 22. Aug 2013, 09:49
by mpack
I see Resize/Move on a button there. Please be aware that this is not a GParted support forum, so there cannot be a lengthy discussion about this.

Re: Resize an ubuntu guest disk

Posted: 22. Aug 2013, 14:48
by Perryg
I will say that sda1 is your primary partition and sda5 is the Linux swap partition.
You can not extend the primary partition because the swap partition is in the way. You have to move it to the far right and then you can extend the primary to use the rest of the free space.

Re: Resize an ubuntu guest disk

Posted: 22. Aug 2013, 17:08
by manuli
thank you for your support! after i have figured out i have to concatenate several resizes & moves in order to achieve it, it worked out smoothly!