Resize an ubuntu guest disk

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
MarcGirod
Posts: 8
Joined: 8. May 2013, 12:05

Resize an ubuntu guest disk

Post 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
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resize an ubuntu guest disk

Post 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.
bulletmark
Posts: 53
Joined: 16. Jun 2009, 14:48
Primary OS: Ubuntu 12.12
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,mac
Location: Brisbane Australia

Re: Resize an ubuntu guest disk

Post 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.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Resize an ubuntu guest disk

Post 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/
bulletmark
Posts: 53
Joined: 16. Jun 2009, 14:48
Primary OS: Ubuntu 12.12
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,mac
Location: Brisbane Australia

Re: Resize an ubuntu guest disk

Post 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.
MarcGirod
Posts: 8
Joined: 8. May 2013, 12:05

Re: Resize an ubuntu guest disk

Post 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
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resize an ubuntu guest disk

Post 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.
MarcGirod
Posts: 8
Joined: 8. May 2013, 12:05

Re: Resize an ubuntu guest disk

Post 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
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resize an ubuntu guest disk

Post 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.
MarcGirod
Posts: 8
Joined: 8. May 2013, 12:05

Re: Resize an ubuntu guest disk

Post 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?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resize an ubuntu guest disk

Post by Perryg »

Make a Clone of the latest snapshot and then you can resize as you please.
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: Resize an ubuntu guest disk

Post 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!
Attachments
screenshot gparted live
screenshot gparted live
Picture 14.png (71.56 KiB) Viewed 24819 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Resize an ubuntu guest disk

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resize an ubuntu guest disk

Post 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.
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: Resize an ubuntu guest disk

Post 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!
Post Reply