Howto increase hard disk size after installing a guest OS

This is for discussing general topics about how to use VirtualBox.
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Post by stefan.becker »

That is a Solution :)
Ingo
Volunteer
Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

Post by Ingo »

OK, THIS solution for Windows XP saves time ;-)

1. have a second running WinXP virtual machine
2. create a new VDI of the size you want
3. detach your working VDI from your working VM
4. attach your working VDI to the second VM as primary slave
5. attach the new (resized) VDI to the second VM as secondary slave
6. start the second VM
7. format target drive F: (the new resized one!)
8. don't forget to set it active (set boot flag) in the disk manager
9. to really copy all flags and whistles I use

Code: Select all

xcopy D:\ F:\ /s /e /c /q /g /h /k /o /x /y
you should get one error message "access denied" for the "System Volume Information" folder
EDIT: if you get more then something is going wrong

10. shut down the second VM
11. detach the new (resized) VDI from the second VM
12. attach the new (resized) VDI to your working VM as primary master
13. start your working VM with the resized virtual disk

that's it and only some clicks except the boring wait for xcopy.
For cloning a physical partition into a virtual disk image I have a solution here:
http://forums.virtualbox.org/viewtopic.php?t=1404
What a surprise, it's the same principle.
klix
Posts: 1
Joined: 15. Feb 2008, 10:05

Another solution

Post by klix »

1. create a new VDI image with the size you want
2. attach your new image as the slave
3. boot some linux live CD in your virtual machine
4. check /proc/paritions which drive is original and which is new (watch the size :-))
5. dd if=/dev/olddrive of=/dev/newdrive (in the most cases dd if=/dev/hda of=/dev/hdb)
6. reboot
7. attach your new image as the primary master
8. boot the OS and use some software for resizing partitions (e.g. parted in linux or partition magic in windows - if you use linux you can't use parted on master partition, so you can use your live linux cd ;-))
9. well done - tested on Windows XP guest and FC6 host and it works perfectly

Klix
efffourthirty
Posts: 8
Joined: 25. Feb 2008, 01:24

Post by efffourthirty »

Klix,

I like your method and it worked great for me. I did the following to go from 6GB to 10GB

1. Booted up using the SYSRECCD from http://www.sysresccd.org
2. I executed 'fdisk -l' to see both the partitioned 6GB drive (hda) and the unpartitioned 10GB drive (hdb)
3. I executed 'dd if=/dev/hda of=/dev/hdb'. Both vdi files were about 5.4GB
4. I executed 'fdisk -l' which now showed hdb as a partitioned drive - cool
5. I started gparted and both partitions looked good. I could have resized it then but decided to test it first by making the 10GB drive the primary and dropping the 6GB drive then starting windows - everything was good
6. Booted up to SYSRESCD again and this time used gparted to resize the first parttion to use the full 10GB disk - size on disk unchanged at 5.4GB
7. Booted up to windows again and as expected it ran a disk check and everything was perfect - windows sees 10GB and the vdi will grow as needed

Efffourthirty
BitBasher
Posts: 13
Joined: 25. Feb 2008, 10:51

Post by BitBasher »

I made a bigger WinXP VM using BARTPE (XPE) + Acronis TI11. Worked like a charm. My steps (from memory)...

1. Release old WinXP VDI from VM.
2. In vbox GUI, make a new VDI the size you want (probably bigger).
3. In vbox GUI, make a HD-less VM to host a BartPE ISO image (set type to XP). Set the CDROM to your BartPE ISO image.
4. Attach the old WinXP VDI to the BartPE VM primary IDE.
5. Attach the new (unused) VDI to the BartPE VM secondary slave IDE.
6. Boot your handy-dandy BartPE VM - it'll be fast if hosted via ISO.
7. Run your favorite disk cloning software under BartPE.

Typically, the old image will be C: but the new unformatted VDI will not have a drive letter. Most good cloning software (like TI11) do not need drive letters - they work off the partitions themselves.

8. After cloning, shutdown the BartPE VM and RELEASE both VDIs from it.
9. Reattach the old WinXP VDI to your old VM (if you had one).
*10. Create a new WinXP VM and attach the new WinXP VDI to it.

*I'm not sure if a new VM is required for the new VDI, but that's what I did. If you attached the new VDI to the original WinXP VM it might work.

The above isn't theory - I did this and it worked great. I upped my WinXP VDI size from 10GB to 16GB. On the first boot of the new WinXP VDI, the OS will discover the "new" harddisk and suggest you reboot. Once you do that, it'll run flawlessly.

Bit.
SoftDux
Posts: 26
Joined: 4. Jul 2007, 15:30
Location: Johannesburg, South Africa
Contact:

Post by SoftDux »

I'd like to give some input on this, and maybe a sort of feature request.

The ONLY reason one can't increase space on a physical HDD, is cause of the physical limitations of the HDD. But, increasing the space on a smaller logical volume on that same HDD is fairly easy, for example with LVM (Logical Volume Man agent) in Linux, it's as easy as decreasing one of the other volumes, and and increasing the one in questions, or differently put. If you setup only the needed volumes on Linux, and leave space for growth, then it's easy to increase the size of one of the partitions when needed.

So, why not have the same characteristics on the VB VDI's? They are after all logical just files, which reside on a partition (regardless of the file system & HDD)
Jaime
Posts: 33
Joined: 5. Mar 2008, 11:54

Any other official way...

Post by Jaime »

So is there any other way to increase the disk size or logical volume without having to clone or re-create a new disk? I'm just wondering since I too ran out of space, but created all automatically expanding vm's. I remember I did this with the vmware and well, Meaning I was able to just increase the disk size with a command since I wasn't using the whole assigned space of the vm. I was just wondering if VirtualBox can do something like it as well. I looked through the manual, but can't find anything like that.
postfix
Posts: 40
Joined: 14. Jan 2008, 13:05

Post by postfix »

Just kidding :wink:

In the evening I will trying to increase a vdi file directly. I want to see whats going on and what should be changed somewhere else.

Using a clonevdi-copied of a working vdi file I, than trying to increase it on a winxp-host unsing

Code: Select all

imdisk -e [-b offset] [-s size] [-o  opt1[,opt2 ...]] [-u unit | -m mountpoint]
as discribed in thread http://forums.virtualbox.org/viewtopic.php?t=4748

Of course increasing the file system structure must be done, too.
alexsurender
Posts: 1
Joined: 2. May 2008, 20:01

For windows xp in linux to increase vdi size

Post by alexsurender »

1.In current running winxp vm, in its details click on the hard disk.
2.In primary slave add a new vdi file to current working primary master.
3.Now start winxp vm, when os completes loading the new vdi will not be visible in my computer.
4.Goto control panel->administration tools->computer management->disk management.
5.Now u will see the new vdi hd space, right click and initialize it then windows will ask u volume name and will ask to format in ntfs.
6.Give volume name dont format, after finishing close the disk management.
7.Goto my computer u will see the new partition now format it to ntfs or fat32 and use it.
8.enjoy
9.Long live virtualbox
jimrippon
Posts: 1
Joined: 8. May 2008, 17:29

How-to move XP to larger drive

Post by jimrippon »

I second the feature request to be able to extend the size of a VDI file, I would prefer to be able to have a source VDI which I clone to make new machines that is only as large as it needs to be.

In the absence of this functionality I am now using the following steps to create new Windows XP machines (I am sure these would transfer to other OS's as you are only limited by filesystem support in GPARTED):

First Obtain ISO image of EASEUS Disk Copy from http://www.easeus.com/disk-copy/index.htm

Also you must Obtain ISO image of GPARTED Live CD from http://gparted.sourceforge.net/livecd.php

To clone from your smaller VDI to your new larger one:
* Attach your existing (source) VDI to primary slave
* Attach your new (target) VDI to primary master
* Attach the Disk Copy ISO to the CDROM
* Ensure CDROM is selected as a boot option above Hard Drive and start VM
* Accept default boot option
* Follow on-screen prompts once Disk Copy has started:
-- "Welcome to the Disk Copy wizard" - press Next
-- "Select copy mode" - select "Disk Copy" and press Next
-- "Select source disk" - select "Disk 1" (check sizes) and press Next
-- "Select destination disk" - select "Disk 0" (check sizes) and press Next
-- "Task preview" - Check settings and press "Proceed" when happy
-- Wait for process to finish, the press Quit to exit.
-- Host+Q and powerdown machine when completed.
* Detach your source disk from Primary Slave

To expand your cloned data to fill the new VDI:
* Attach the GParted-Live ISO to the CDROM and start VM
* Accept default boot option
* Follow startup prompts to select your preferred keyboard layout, select "vesa" graphics and select your preferred language
* Once GParted has started, select your new partition and choose "Resize/Move" from toolbar
* Stretch partition to fill drive and click "Resize/Move"
* Click "Apply" on toolbar and follow prompts
* Exit GParted and Host-Q and power off VM
* Unmount CD and ensure Hard Drive is selected as a boot option
* Start VM - all done :D

Hope this helps some of you, it works reliably for me and involves minimal downloads and disk space for ISOs - I had previously been using UBCD as it includes all the tools required, but a larger ISO image.

Jim
mattcornell
Posts: 2
Joined: 12. May 2008, 20:34

Migrate windows from HW disk to bigger vm - using ntbackup

Post by mattcornell »

I have for the first time in my life said "Wow that microsoft software worked exactly as I wanted it to".

ntbackup on a windows 2000 server is the bomb. And cursory review suggests that it has gotten better with xp on.

What I did was create a virtual machine with a vanilla install of windows 2000 and made sure it could see my network's shares.

Then I went to the source machine which was a real life server (800mhz and in need of upgrade) and stopped any services I could. Ran ntbackup saving the whole C: drive and the system state to a network location.

After waiting an hour for the 20 gig or so backup to finish I just shut down the real machine so that there wouldn't be any contention for it's IP address or for Domain control.

Went to the virtual machine and used ntbackup to restore from the backup image on the network (making sure to allow for the 'write over local files always' option). After another hour or so all I had to do was reboot; reconfigure the network because that device had changed and I was all set.

I image you could use the same process just to move one virtual windows server with a 20GB disk to another virtual server with a 40GB drive. It was a unexpectedly easy experience.
upandgone
Posts: 3
Joined: 14. Jun 2008, 17:40

Post by upandgone »

Hey Jim,

Thank you so much for you reply. All tools are free, reliable and fast. The solution you suggested works perfectly.

Cheers

PS: Since when has XP become so big? 4 GB was much to small...
virtuoso
Posts: 24
Joined: 29. Jun 2008, 23:13
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Win7x32
Location: $HOME/.VirtualBox

Post by virtuoso »

I've been trying to resize a partition myself; however, the problem I am faced with is snapshots.

I like to use snapshots in order to someday make clones, as well as so I only need to install Windows once, e.g. when the next service pack comes out, I'll just revert to initial install and make a new branch.

BUT, if you take the approaches given here, where you attach another VDI and copy over files from the latest snapshot, VB still associates the previous VDI with your earlier snapshots. E.g. I have to keep my old 20GB (full) VDI around because I'll need it if I want to revert to a snapshot. So now I have a completely new 40GB VDI with 20GB of the same files. :x

I'm not familiar with how VB tracks changes between snapshots: do differences remain with the VDI or are kept separately?

We really need a feature to resize VDIs within VB... copying contents of VDIs doesn't appear to work with snapshots too well. I'd be willing to help develop. I haven't coded in a few yrs though so I'm probably pretty rusty :(... but good reason to get back into it. :D
virtuoso
Posts: 24
Joined: 29. Jun 2008, 23:13
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Win7x32
Location: $HOME/.VirtualBox

Post by virtuoso »

upandgone wrote:PS: Since when has XP become so big? 4 GB was much to small...
My Vista install is 20GB before I even started using the damn machine! That's incl. Office, Project, Visio, VStudio, Quicken- all the things I can't leave just yet. I know Vista doesn't compare well to XP in terms of size, but I'm still shocked at the bloat!!!!!!
MisterGoupil
Posts: 1
Joined: 10. Nov 2008, 14:31

Post by MisterGoupil »

reptile wrote:I did this ages ago using acronis disk manager partition software.

I created a new dynamic disc and added it to the machine.

i opened up the disk manager sofware and chose to copy the partition and mbr

then it asked if i wanted it resized to fit the space and i said yes.

it worked perfectly.
Hello,

I try today with Acronis Disk Director 10.0.2.173

I had a 1st disk with one dynamic partition (letter C: Windows XP Home) of 5,25Gb and a non assigned partition of 7,844Mb created by VBox

I created a new dynamic disk of 25 Gb (max) and attached it to the VM at first Primary Slave on VM.

I have launched DiskDirector (Already installed on the first disk/partition of 5,25Gb)

I choose to copy only the 1st (too small !) dynamic partition to the new bigger 2nd dynamic partition (25Gb) ( Active with letter D:)

I resized to fit the space but limited to 25Gb minus 7,844Mb to respect the first configuration of disk1

BUT I don't copy the MBR from 1st Disk to new bigger disk/partition.

I proceed, i reboot once and i stopped the VM

After with Virtual Disks Manager, i detached the 1st Disk of 5,25Gb
And i attached the 2nd Disk of 25 Gb at first Primary master on VM

So i launch the VM and it's a success !

It's very well ! All is right ! :D
Ubuntu 8.10 Intrepid Ibex - VirtualBox 2.04 (Windows XP Home SP3)
Post Reply