Increase Win7 VDI file Size

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
elchap1n
Posts: 21
Joined: 29. Jan 2013, 22:50

Increase Win7 VDI file Size

Post by elchap1n »

Has anyone successfully resized the win7 vdi file successfully using these steps:

1) Find out where the VDI files are
$ VBoxManage list hdds

2) backup current disk by cloning it
$ sudo sudo VboxManage clonehd /Users/Win7//Win7.vdi /Volumes/Data/VBOX/backups/Win7-clone.vdi

3) Once the backup completes, resize the VDI file
$ VBoxManage modifyhd <path to your vdi> --resize <new size in megabytes>
Example:
$ sudo VBoxManage modifyhd /Users/Win7//Win7.vdi --resize 40960
Where resize value is new size in megabytes

4) restart virtual box
after resizing, VBox and the OS should know the new size

5) Let your OS know the new logical size of the drive
Let the OS know the new size
-- use computer management/disk management to extend the disk

Any suggestions?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Increase Win7 VDI file Size

Post by Perryg »

Why do you need to use sudo?
elchap1n
Posts: 21
Joined: 29. Jan 2013, 22:50

Re: Increase Win7 VDI file Size

Post by elchap1n »

Thinking I may need to run with privileges. However, i can try without sudo. But as far as the procedure goes, does it seem is the correct way to extend the win7 VDI disk?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Increase Win7 VDI file Size

Post by Perryg »

Does it not work for you? From the looks of it I would think it should, unless the virtual drive is fixed or you have snapshots.
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: Increase Win7 VDI file Size

Post by mpack »

Yes, it's correct except that if you want to make a backup of a VDI file then the best method is the most obvious one, i.e. copy the file using the host. Cloning (clonehd) means to copy and also change the internal UUIDs, hence is only needed if you intend to mount both the original and "backup" VDI at the same time, which you don't. This way, if there is some problem after the resize you can simply copy the VDI back, and you are precisely back where you started, no harm done. If the UUIDs are different then recovery isn't as easy.

ps. You made no mention of snapshots. Hopefully that means you aren't using them. However for others reading this: a reminder that you can't resize a drive in this way if you are using snaphots.
elchap1n
Posts: 21
Joined: 29. Jan 2013, 22:50

Re: Increase Win7 VDI file Size

Post by elchap1n »

Ok, I have updated my procedure - since I am not going to be mounting the VDIs at the same time, is this more appropriate?

1) Find out where the VDI files are
$ VBoxManage list hdds

2) backup current disk by cloning it or using host
$ cp /Users/Win7/Win7.vdi /Users/Win7/Win7.vdi_copy

3) Once the backup completes, resize the VDI file
$ VBoxManage modifyhd <path to your vdi> --resize <new size in megabytes>
Example:
$ VBoxManage modifyhd /Users/Win7/Win7.vdi --resize 40960
Where resize value is new size in megabytes

4) restart virtual box
after resizing, VBox and the OS should know the new size

5) Let your OS know the new logical size of the drive
Let the OS know the new size
-- use computer management/disk management to extend the disk


Thanks you so much!
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: Increase Win7 VDI file Size

Post by mpack »

Yes, that will work.

I'm not sure it's possible to guarantee a procedure correct for all scenarios. Where possible IMHO it's best to backup the entire VM folder, which ensures that snapshots etc will not be harmed (in the process of discovering that you can't resize such a VM anyway!). However sometimes the user has stored the main VDI file outside the VM folder, in which case your procedure deals with that scenario better.
elchap1n
Posts: 21
Joined: 29. Jan 2013, 22:50

Re: Increase Win7 VDI file Size

Post by elchap1n »

Perfect, and yes i understand that it may not resolve all scenarios, but I wanted to try to get as close as possible. In case the resizing does not work, I should be able to mount the copy instead of the original, correct?

In case something happens with the original (i.e. the resizing corrrupts it), will this work:

# rename the original to old
$ mv /Users/Win7/Win7.vdi /Users/Win7/Win7.vdi_old
# rename the copy to original
$ cp /Users/Win7/Win7.vdi_copy /Users/Win7/Win7.vdi
# start VBox

Or is there something else I would need to do inside VBox?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Increase Win7 VDI file Size

Post by Perryg »

I would also suggest *not* saving the backup file in the same folder as the original. I have seen this cause issues in the past.
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: Increase Win7 VDI file Size

Post by mpack »

Yes, replacing the original with the backup, whether by renaming or copying, will be enough to fully restore the VM to the "before" state. Provided of course that the VM is fully shut down first - you wouldn't want to replace the VDI when the VM is merely suspended (I'm assuming the host OS will prevent you replacing it while the VM is still running!).
elchap1n
Posts: 21
Joined: 29. Jan 2013, 22:50

Re: Increase Win7 VDI file Size

Post by elchap1n »

Ok, got the final steps:

###############################################################

0) Power off windows VM

1) Find out where the VDI files are
$ VBoxManage list hdds

2) backup current disk by cloning it or using host
$ cp /Users/Win7/Win7.vdi /Users/TEMP/Win7.vdi_copy

3) Once the backup completes, resize the VDI file
$ VBoxManage modifyhd <path to your vdi> --resize <new size in megabytes>
Example:
$ VBoxManage modifyhd /Users/Win7/Win7.vdi --resize 40960
Where resize value is new size in megabytes

4) restart virtual box
after resizing, VBox and the OS should know the new size

5) Let your OS know the new logical size of the drive
Let the OS know the new size
-- use computer management/disk management to extend the disk

###############################################################

If the resizing fails:

# rename or move the original to other location
$ mv /Users/Win7/Win7.vdi /Users/TEMP/Win7.vdi_old

# move/copy original copied to Win7 location
$ cp/mv /Users/TEMP/Win7.vdi_copy /Users/Win7/Win7.vdi

# rename the copy to original
$ cp /Users/Win7/Win7.vdi_copy /Users/Win7/Win7.vdi

# start VBox

###############################################################

To detach the failed disk:

1) ensure VBox is powered off
2) select VM
3) Click on settings
4) Go to storage Tab
5) Under the data controller, highlight VDI file, Remove

###############################################################

To attach the copied disk:
1) 1) ensure VBox is powered off
2) select VM
3) Click on settings
4) Go to storage Tab
5) Under the data controller, click + to add, find the disk and add it

###############################################################
Post Reply