Expanding virtual hard disk

Discussions about using Solaris guests in VirtualBox.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Expanding virtual hard disk

Post by rasta »

I'm running a Solaris 10 64-bit guest on a WinXP x64 host. The Solaris VM was migrated from an x86 host using the Export VM tool, and then imported as a VM on the x64 system. I am running out of space on the virtual hard disk, which will not automatically expand. I thought that I had originally created the VM on the old x86 system as having a dynamically-resizeable virtual disk.

Why will my VM virtual disk not automatically expand as needed? How can I get it to expand? Will I have to make a new VM with an expandable disk and somehow copy the contents of the old vdisk into that one?

Thank you...
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

My VM is in vmdk format, if that matters.

The manual says:

"For more flexible storage management, use a dynamically expanding image.
This will initially be very small and not occupy any space for unused virtual disk
sectors, but the image file will grow every time a disk sector is written to for the
first time. While this format takes less space initially, the fact that VirtualBox
needs to constantly expand the image file consumes additional computing resources,
so until the disk has fully expanded, write operations are slower than
with fixed size disks. However, after a dynamic disk has fully expanded, the
performance penalty for read and write operations is negligible."

What exactly does "full expanded" mean here? I assume that it means when a request is made for more space by the guest OS, the disk expands dynamically as needed, and that during the expansion, disk access is slowed. When I try and create more files in the guest, I get a "no space left on device" message from Solaris.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

It appears that "fully expanded" refers to the max size specified when the virtual disk was created. I don't know what max size I specified for the original disk.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

I'm using Vbox 3.1.2.
tb2571989
Posts: 145
Joined: 10. Sep 2009, 14:28
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Windows Server 2003, Windows Server 2008 R2, Ubuntu 9.10, Ubuntu 10.10

Re: Expanding virtual hard disk

Post by tb2571989 »

That's correct. If you craete a fixed size hard disk then virtualbox will create a file of that size on your computer. For example, if you create a 10GB Fixed Size HD then VB will create a 10GB file on your computer (which may take a while).
On the other hand, you can choose an expanding hand disk in which the virtual computer appears to have a HD of the specified size but doesn't take up the whole disk space on the computer. If you created, for example, a 10GB dynamic image then to strt with the disk on your actualy computer will be serveral kb. once files are created on this disk the file will increase in size up to the size of the virtual hard disk.

If you have a virtual hard disk that is nearly full, the only way, currently, is to clone the virtual disk to another, larger, virtual disk. You could use CloneZilla for this or the [url]http://forums.virtualbox.org/viewtopic.php?f=6&t=22422[CloneVDI tool/url].
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

Thank you for the info. Expanding a hard disk seems like a fairly common and obvious need that is not covered in the User Manual. Odd.

So, the built-in clonehd function in vboxmanage will only clone a hd to a new one of the same size? There is no parameter to specify the size of the output clone. So, is your tool the only way to "clone and grow" a virtual hard drive?
tb2571989
Posts: 145
Joined: 10. Sep 2009, 14:28
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Windows Server 2003, Windows Server 2008 R2, Ubuntu 9.10, Ubuntu 10.10

Re: Expanding virtual hard disk

Post by tb2571989 »

Persoally, I don't use the built in tool, I prefer to use CloneZilla as that's what I know how to use. I'm not sure then, but i epextc you would be able to find an answer on the forums.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

CloneVDI cloned and enlarged my virtual disk, but I do not know how to expand the partition inside the VM to fill the enlarged disk. He mentions the gparted tool, but I don't think that will work for a Solaris guest, will it? Is there some Solaris command that I can use to enlarge the partition (there is only one partition in the guest)?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Expanding virtual hard disk

Post by mpack »

Since no-one else has answered, I will have a go, even though I'm not a Solaris user.

In fact the answer depends on which filesystem is being used; you haven't provided that information, and I don't know if Solaris gives you options in that area. If the answer is "ZFS" - the Solaris filesystem, then the OS presents storage from all available block devices as one continuous filesystem (though I imagine that doesn't apply to removable devices).

So, the answer to your question seems to be to create and format a new partition on the disk to fill all of the remaining space, then (if it isn't automatic) somehow add this new "block device" to the set managed by ZFS, and the apparant space available to ZFS should grow suitably. Since I'm not a Solaris user the details are somewhat hazy, but I found some related documentation here. Perhaps you can work it out, or find more directly applicable documents on the same site.

I advise you, of course, to back up your VDI file before you try any of this stuff.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

Thank you for your suggestion. The Solaris growfs command appears to be what I need. However, after booting the guest from the Solaris iso, the command isn't working so far. I wonder if I will have to create a new partition and append it onto the present one, as you said? This all seems pretty complicated, and the lesson here is to be sure to create a virtual disk of appropriate size when you start out with Vbox.

Solaris uses ufs file systems, so I don't think gparted will do what I need.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Expanding virtual hard disk

Post by mpack »

rasta wrote:The Solaris growfs command appears to be what I need
My research was admittedly brief, but I seem to recall that "growfs" adds more slices to an existing partition - meaning you would have to expand the partition first, and I don't think you have any tools which can do that without destroying the filesystem inside (I hope you took a backup as I suggested!).

I still think the correct steps are to use fdisk to create a new partition on the drive, then use (something) to format that partition and add it to the filesystem.
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

I think that you are generally correct. The method of expanding the / partition is apparently quite complicated, and is still under investigation:

http://forums.sun.com/thread.jspa?threa ... 0&tstart=0
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Expanding virtual hard disk

Post by mpack »

rasta wrote:I think that you are generally correct. The method of expanding the / partition is apparently quite complicated, and is still under investigation:
General comments.

One thing I see is not being made clear to your colleagues in that forum: when you enlarge a drive using CloneVDI you are enlarging the drive, not any filesystems or partitions on the drive. It's the same effect you would get in the physical world if you had some low level tool which copied all of the sectors off a 20GB drive and over to a 40GB one, and then put the 40GB drive into your PC. Everything would still work (driver issues aside), but the filesystem is still only using the first 20GB of the drive, and that's precisely the situation you have here.

Dynamically growing drives in VBox don't grow the filesystem either. As far as the Solaris filesystem is concerned, the drive (rather, the root partition) has always been ~20GB. However, unknown to Solaris, some of the sectors in that space are only allocated on demand (i.e. when first written to). So, until every sector has been written to the host VDI file will be less than 20GB.

Your colleagues mention that you can't add extents to the root volume of a UFS system - that's something I hadn't appreciated.

Bear in mind also that you have a backup, so you can try the "dangerous" VTOC zapping ideas with in fact no danger at all. If it doesn't work you just restore your backup, or create another clone of the original.

If I understand the suggestion correctly, you are supposed to use fdisk to delete the existing partition (this should just mark the partition table entry as empty, without actually changing any data in there). You then create a new partition that fills the drive. The first 20GB of that partition should contain the old data. Then somehow you need to zap the old VTOC label - I don't quite grasp how that is done, but maybe you do.

Don't worry about the cylinder size changing. A cylinder is always 63 sectors in a VBox virtual disk.

Incidentally, I'm still not sure you've pinned down what filesystem you are using with certainty. Both UFS and ZFS have been mentioned. This is a rather fundamental question!
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

mpack,

It is definitely ufs, not zfs. Gparted doesn't support growing slices in either. I agree that the / slice deletion and VTOC zapping appear to be the only ways to get a slice to expand into the cloned/enlarged disk with a ufs file system. Maybe I will try that today, if I can figure it out. Making a new Vbox disk for data storage and mounting it onto the guest is another way to go. Thanks again for your helpful comments and ideas!
rasta
Volunteer
Posts: 215
Joined: 24. Jul 2008, 00:25

Re: Expanding virtual hard disk

Post by rasta »

Here is the answer.

1) Use CloneVDI to clone your disk to a new one which is expandable to a larger desired size.

2) Follow instructions in reply #14 of this thread:

http://forums.sun.com/thread.jspa?threa ... 0&tstart=0
Post Reply