Re-sizing a VirtualBox Virtual Disk Image File

Update 17th April 2009: This post has been updated to include the latest suggestions posted to the comments, including using the gparted Live CD instead of the Gentoo Linux System Rescue CD.

In my previous post I extolled the virtues of Sun’s desktop virtualisation software, VirtualBox. One thing niggled me though – I couldn’t easily expand a Virtual Disk Image (VDI) and was regularly reaching the space limits of the modest 20Gb disks I was creating; I needed an easy way of expanding disks before I could use it as my main virtualisation platform and felt comfortable in recommending it to my readers.

Given that there is very little information out there on how to perform this task – apart from a single obscure forum post – here is my attempt to walk you through the process of expanding a virtual disk image. This guide assumes that you are trying to expand a disk configured with Windows, however the procedure should be pretty much the same for a Linux/OpenSolaris etc. based disk.

Getting Started

  • Ensure that the Virtual Machine that uses the disk you want to re-size is shutdown.
  • Remove any snapshots you may have – VirtualBox can go a bit wonky when re-sizing a VDI with snapshots attached (thank to Darren for pointing this one out).
  • Take a backup of your VDI that you want to resize (by copying and pasting the .vdi file in Windows Explorer) – if we mess our resize up we can recover back to this backup.
  • While the VDI file is copying, download the latest stable release of the gparted Live CD ISO from Sourceforge (approx 95Mb).
  • While the ISO is downloading, create a new empty Virtual Disk in the VirtualBox console that is the size of the larger disk you need.
  • Attach the new disk to your virtual machine that needs its disk expanding as the slave disk.
  • Once the System Rescue CD download has completed, mount the ISO on the virtual machine CD drive.

Starting the Disk Image Utility

  • Boot the virtual machine from the mounted ISO – you may need to reconfigure your VM to ensure that you boot from the CD-ROM drive before the HDD, so change the VM settings as shown below or hit F12 at boot and change there (given that VirtualBox is currently under development, the screenshot below will always be out of date, but I’m sure you get the idea ;-):

virtualboxbootorder

  • During the boot process the gparted Live CD will prompt you to select the correct keymap – if you are using a QWERTY keyboard, simple select the ‘Don’t Touch Kepmap’ option; next, you will be prompted for the language settings to be used – select the appropriate language code, in my case ’02’ for British English; finally, you will be prompted for the X-Windows mode – select ‘0’ to automagically start gparted in an X-Windows session.
  • Once gparted starts, you will be presented with a graphical representation of your disks – left-click the left-to-right bar named /dev/sda1 (your primary hard disk that is to be expanded) and then click on the Copy icon.
  • Select the drop-down-box to the right of the tool-bar and select the second (currently empty) disk – /dev/sdb (possibly /dev/hdb in your environment), the graphical representation of your disks will change to show you the second slave disk which is currently empty. Click on the Paste icon.
  • gparted will will prompt you that all data on the new partition will be erased and if you’re happy, subsequently prompt you on how the disk should be formatted. For a Windows environment, select MSDOS (this will give you an NTFS partition, trust me!).
  • gparted will finally present you with a slider dialog indicating the desired size of the new disk. Drag the slider to the right to select the maximum size of the new partition on this new disk (I’d just drag it so the partition consumes the whole disk), as shown in the screenshot below:

selectsizeofnewpartitiongparted

  • Click the Apply icon, you’ll be presented with something along the lines of the screenshot below as the contents of the source disk are copied to the new, larger, disk:

  • Once the copy has completed (approx. 35 mins to create a 30Gb disk from an original 20Gb disk), you will need to mark the new disk as bootable (if this is to be a bootable partition – if not, simply skip the next step).
  • To mark the partition as bootable, right-click the graphical representation of the new disk and left-click Manage Flags. In the dialog that appears, select Boot and click Ok to close. gparted will apply the necessary flag and re-scan your disks.
  • Close gparted and click the Exit icon to shutdown the system.

Completing the Re-Sizing

  • Once the virtual machine has powered off, re-configure the hard disks to use the newly created/copied disk as the primary and remove the old primary disk from the system; finally, unmount the System Rescue ISO from the CD-ROM.
  • Power on your new VM and you should be presented with the the usual Windows boot sequence; if you are just presented with a black screen with a flashing cursor at the top left-hand corner of the screen, there isn’t a boot sector on the disk, so restart gparted and add the boot flag as directed above.
  • Hopefully, your virtual machine will start without issue. Windows may perform a check of the disk during boot. Once logged-in, open Windows Explorer and confirm that the newly created drive is the new larger size.

The procedure described above has been tested on Windows Server 2003 and works without issue (although the first time around I forgot to apply the boot flags…), so it should work seamlessly on Windows XP, Vista and Windows Server 2008.

I appreciate that this procedure does involve running a flavour of Linux to acheive the desired results, however its very straightforward and shouldn’t be off putting to a Linux novice.

Reblog this post [with Zemanta]

106 comments

  1. Tomas Restrepo

    Nice post, Nick! VBox is a pretty nice virtualization platform (I use it for linux guests, but been a bit reluctant to move my existing vpc images over to it).

    BTW, if the guest OS is vista or WinServer2k8, you should be able to resize the partition using Disk Manager directly from the OS without having to go through the system rescue cd.

  2. Nick Heppleston

    Tomas,
    Thanks for the pointer, I’ll try Disk Manager later today on a 2008 Server. One question though: how can Disk Manager increase the size of a partition if the virtual disk is already at its size limit?

  3. Briefe Schreiben

    Hey! Your Post “ng a VirtualBox Virtual Disk Image File at Nick Heppleston’s BizTalk Blog” is very interesting for me. Unfortunately my written English is not so good so I write in German: Dir, meinem liebsten, geh

  4. Jules

    Clear, concise instructions — many thanks.

    Can these same steps be used to copy a fixed-size disk to a dynamically expanding one? I can’t see any reason why not, but after trying it, I get a “A disk read error occurred” error when I try to boot from the new disk…

  5. Nick Heppleston

    Jules,
    I don’t know whether a dynamically expanding disk needs some ‘special’ configuration within the disk itself, so maybe it isn’t possible…. Out of interest, are you sure that you marked the partition as bootable before you tried to use it?

    Nick.

  6. Pingback: When Windows Won’t Load | Job Searching Blog
  7. Chris

    Let me add a bit to the end of the process – I did this with an XP image, and though everything appears to work fine, I did see one issue. During the boot process, Chkdsk ran, didn’t find anything and booting continued. Once XP got to the login screen, VirtualBox reported a fatal error and was “stuck”. VB locked up good at that point so I killed it and restarted. 2nd time was the charm. The VM came right up, and once logged in, the Add Hardware process picked up the new disk.

  8. sonofjon

    Pretty good instructions! Took me less than 15 minutes in total to increase my Windows XP from 4GB to 8GB. Everything runs fine. Very cool. Thanks! PS. I use dynamically expanded storage format.

  9. Myke

    Worked like a charm for me too. (increased Windows XP from 7GB to 22GB). Thanks a lot for this!

  10. Mike Rooney

    Thanks, very awesome tutorial, this worked for me! However I’d recommend using the gparted live cd instead, which is what I used. It is 95 megs instead of 230, and automatically boots into a graphical environment after choosing the keyboard, so it shouldn’t be as off-putting as you aren’t ever manually typing things into a terminal. Additionally there is a shut-down icon on the desktop so you don’t have to manually halt it either. By the way this worked fine on a dynamic image (.vdi) file. Thanks again!

  11. Antoine Leclair

    Thanks for the tutorial. Worked great for my Vista 32-bits guest under Ubuntu 8.10 64 bits.

    I had to mount Vista .iso to repair the installation after resizing (something about the booting). Anyway, worked great, withouth hacking anything.

  12. Elvis

    Imagine, I ran out of virtual disk space after migrating iTunes and all my music to my virtual Windows machine.
    Gotta love open source software! Let’s all pray that Sun can remain that way.

    – Kubuntu 8.10, Vbox 2.2

    Elvis

  13. Nick Heppleston

    I have updated this post to include all comments so far – many thanks to those who have commented. Nick.

  14. Andrew Barnes

    Brilliant guide – did EXACTLY what I needed it to – thank you very much!

  15. Pingback: Resizing a VirtualBox HDD « 0×0000
  16. Pingback: VirtualBox Snapshots « Nathan Fast
  17. UncleBoxy

    @Nick Heppleston

    Great post man. I was definitely skeptical about having to download GParted and use it, but it actually turned out to be a great learning experience. I’m not really new to Unix or Linux, but I’m not expert at it either. The GUI and your instructions on using it were spot on and very helpful.

    @Antoine Leclair

    Thanks for the advice for Vista. By following your additional instructions, I was able to get a Vista 64 bit guest running on a Vista 64 bit host.

    This may alarm some people, so I think it’s worth a mention: CHKDSK ran when Windows started up the 1st time, and after that it (of course) booted fine.

    Good stuff. Thanks

  18. Pingback: Ender Özcan (enderozcan) 's status on Thursday, 16-Jul-09 20:59:47 UTC - Identi.ca
  19. Bart

    Followed the guide successfully for a Windows 7 install. The only additional step needed was to repair the Windows 7 install before it was able to boot.

  20. Alex

    Hi Nick,

    have tried it today.
    unfortunately I had the same problem than Jules and got a “A disk read error occurred” error.
    I have tried it with an dynamically expanding one and a fixed one.
    Both of them create the same error message.

  21. Rob W

    This was great! Thank you so much. I was not paying enough attention on my initial install. How annoying that clonevsi doesn’t accommodate this.
    After following these instructions my experience was a little different:

    * upon boot into Vista after making a larger partition and otherwise following these instructions, I got an error from windows about winload.exe not being found.

    * I booted with my vista disk, hit repair and let it reboot and do something to the disk and it’s all good now.

    Thanks for this tutorial

  22. Dave

    Thanks so much. I’m a relative novice with Linux and I followed this with no problem. Worked perfectly with a XP dynamic machine.

    Well done!

  23. Dinesh

    One more happy camper, thanks to your instructions. Of all the options I’ve seen to accomplish the task, this was the simplest, the most straightforward. Thanks much.

  24. Tim Toombs

    Nick,
    Thanks! These instructions worked like a charm. I had the same problem with the Vista-32 reboot as Rob W. and Antoine, but the Windows “Repair” was quick and painless.
    Host: Ubuntu 9.04 – 64bit
    Client: Vista-32 Ultimate

  25. mehdi

    I used the procedure for Server 2008 and it FAILED:

    Although I made the disk as “boot” as instruction, but it failed to start normally. I tried to repair it from by windows installation CD and it didn’t also work out! May be it is better to make a whole backup when from OS running , not just simply copy the image of system (VDI) which doesn’t help at this stage.

  26. Great post!

    Thanks a lot!

    Worked perfectly with ubuntu 9.10 64 bit as host, virtualbox 3.0.12 and winxp sp3 as guest.
    The instructions are very easy to follow.

  27. Rob

    First off, thanks for the great information!

    For anyone that stumbles on this post, I wanted to share my experiences with a Win2008 x64 guest on a 64 bit win7 host:

    You will need to repair the 2008’s boot sector, its just not very intuitive to find the fixboot command anymore. follow these steps:

    Boot using the installation media
    Select repair
    Select the partition and click ok
    Choose the command line option
    At the command prompt type c:
    Type bootrec.exe /fixboot
    Type exit and reboot the machine.

    It may take a bit for the machine to start, and scandisk will run, but you will successfully be up and running.

  28. Paul

    Have tried this with Windows Server R2 guest on Windows 7 host with no success, including Rob’s suggestion for using the repair option. When Gparted runs it shows TWp partitions in the existing single 20GB vdi drive. the /dev/hda1 is quite small and the main disk (showing as 20GB) is dev/hda2. I copied the hda2,set its boot flag and then applied Rob’s Server 2008 x64 trick to do a repair from installation media for bootfix. IT applied this and said successful but then on reboot get the “BOOTMGR” is missing. My guess is that this is the small partition (/dev/hda1)that I did not copy. I cannot see how within Getparted that I can clone a disk to be both partitions or copy them sequentially as it looks as the second will over right the first.

    Any suggestions to copy both partitions – wonder about using a disk cloning tool from within Server 2008R2

  29. Paul - follow up

    re: server 2008R2. I have now got both partition on the new larger drive (using Gparted) and have marked the first one -it is 100MD only- as boot i.e. it mirrors the stup of original.Have run the bootfix trick as per Server 2008 but still will not boot. Get an error message saying it is missing a Driver and asking to reboot from installation media and do a repair but not sure what else I should repair. Any suggestions – not familiar with the repair command line.

  30. Pingback: Resizing a VirtualBox VDI image / hard disk « HyperPac´s site
  31. Pingback: Increase virtual hard disk size under VirtualBox 3.1 « Thoughts on Life
  32. Scott

    EXCELLENT! Thanks so much! I couldn’t find anything about resizing a VDI before I found this. I just assumed it would be an option right within the Virtual Media Manager… yikes, NOT.

  33. simi

    thanks mate, this worked for me like a charm. running vbox on ubuntu karmic, needed to enlarge my winxp drive a little.

  34. David Souther

    If all you need to do is increase the size of a virtual box disk image, I have found this to be slightly more effective.

    1) Create a new expanding disk image of the appropriate maximum size
    2) Attach this as the slave image
    3) Mount a Ubuntu (or whatever) live disk
    4) Boot into the live disk
    5) run “dd if=/dev/sda of=/dev/sdb” (double check the correct /dev/sd’s, they should be right but this could kill your disks very quickly if you have if and of backwards).
    6) Power off the vm, remove the small disk from the machine, set the large disk as master
    7) Boot the machine.

  35. justin

    Instructions work great running a win xp on virtual box on an iMac. One thing I had to do to get the image to boot into gparted iso was to remove the guest editions mounted iso file (the gparted iso came up as a second cd drive). Otherwise perfect!

  36. Ryan C

    Nick,

    This post was excellent. I was linked here from http://www.ubuntuforums.org, and was happy they knew of this gem. I just followed the steps one by one (some parts are outdated with the current version of VirtualBox), but all in all, it worked beautifully. I just rebooted, and was now finally able to finish the XP updates on my virtual install.

  37. IPityTheWise

    Excellent HOWTO!!!!!!

    I forgot to expand the gui of my copied vdi. So I initially had the VDI + 40 Gigs of unallocated space. I went back in, expanded the GUI and voila!!!! Instant resized drive.

    Lesson: READ THE ENTIRE POST FIRST. Don’t skim through it. If you brick your drive(s), you will have wished you had.

    AGain, Great HOWTO…thanks a million!

  38. Ion Freeman

    I’m having the same issue as Paul. I open gparted on a Windows 7 image to see three partitions,
    unallocated 1.00 MiB
    /dev/hda1 System Reserved 100.00 MiB boot
    /dev/hda2 9.90 GiB

    I feel like I could live without ‘unallocated,’ but I don’t seem to be able to copy both of the others at once, and I’ll take Paul’s word for it that copying them sequentially won’t work. How do I proceed?

  39. Ion Freeman

    Actually, they didn’t really turn out to be issues at all. I copied over hda1 then hda2 — they didn’t overlap.
    Shutting down gparted took far longer than I had expected, with many message list

  40. Gnana

    Beautiful! Thank you. Just one addition, when started for the first time windows does a disk scan….

  41. Paul

    Excellent post, Nick. Just an FYI, I’m running openSolaris as the host with multiple Windows VMs and this works fine with that configuration as well.

  42. Nick Heppleston

    Paul,

    Many thanks for the feedback on the OpenSolaris host.

    Cheers, Nick.

  43. Boyan Boychev

    Hi all,

    If your root partition is lvm type and you are using LVM try this out:
    ——————————————————————————————————————————————–
    Use LiveCD with dd and fdisk utilities:
    —————————————-
    1) dd if=/dev/hda of=/dev/hdb # /dev/hda – old disk with smaller size, /dev/hdb – new disk with bigger size
    2) fdisk -u /dev/hdb
    3) Steps from 2) to 6) (incl.) described here – http://www.linuxquestions.org/questions/fedora-35/lvm-partition-resizing-666683/#post3281556
    4) Shutdown the Virtual machine and remove the old disk and the LiveCD from the virtual CDROM

    After the shutdown, boot the system normally (only with the new disk and without the LiveCD):
    ———————————————————————————————
    5) pvdisplay -v # Checks the PV name (e.g. /dev/hda2)
    6) pvresize –verbose /dev/hda2
    7) vgdisplay -v # Checks the Free PE (e.g. 384)
    8) lvextend -l+384 /dev/VolGroup00/LogVol00
    9) resize2fs /dev/VolGroup00/LogVol00
    10) Наздраве!
    ——————————————————————————————————————————————–

    Tested with VM:
    CentOS release 5.4 (Final)
    kernel-2.6.18-164.11.1.el5
    lvm2-2.02.46-8.el5_4.2

    Don’t do that on production systems but better create a new partition with fdisk and a new PV, extend the existing VG and LV after that (see http://www.linuxquestions.org/questions/fedora-35/lvm-partition-resizing-666683/#post3281556).

    Be sure that you have a backup!!!

    Best Regards,

    Boyan Boychev
    Bulgaria

  44. Jul

    Hi All,
    I’ve tested on 2008 R2, and I’ve also encountered with the “BOOTMGR is missing error”. Just wanted to share how i resolve the issue and the image is working perfectly fine for me. The following steps from http://www.binarywar.com/ resolves my issue:-

    1. Put in the 2008 R2 installation cd
    2. In the System Recovery Options dialog box, click Command Prompt
    3. Type Bootrec /RebuildBcd, and then press ENTER.
    4. If the Bootrec.exe tool runs successfully, it presents you with an installation path of a Windows directory. To add the entry to the BCD store, type Yes. A
    5. Next, I booted the server from a Windows 7 ISO and ran the Startup Repair option.
    6. After running the startup repair, on the first boot, do let the check disk run. After which, you are able to logon to your Windows 2008 R2 server as per normal with your storage size enlarge.

    Hope this helps for those with 2008 R2. :)

  45. Pingback: [Gentoo] Virtualbox increase HD size
  46. George Mauer

    I got this working on my Windows 7 Ultimate 64 bit box. I did the following
    1) Copy the small boot partition (I gave it 200 MiB) Paste to the new disk
    2) Copy the system partition, paste to the new disk (I was going from 20 to 50 GB so I just gave it the rest of the vdi)
    3) Apply
    4) Manage Flags on the small partition – set boot flag
    5) Power off
    6) Remove old vdi from the machine, set the new one to Primary Master
    7) Here’s the catch – when I booted up windows detected that something was wrong. I had to dig out my windows CD and boot.
    8) I then selected repair system – this took only a few minutes.
    9) Now everything worked fine.

  47. Pingback: Re-sizing a VirtualBox Windows Virtual Disk Image File « Places of Interest to Ray
  48. Pingback: Chris’s Digital Detritus » Re-sizing a VirtualBox Windows Virtual Disk Image File
  49. Pingback: resized virtualbox windowsXP guest OS partition (primary drive) « eneutrino's ubuntu experience
  50. Alis

    Hello Nick,
    I just followed the instructions for the second time and it worked perfect.
    Many thanks!!

  51. Paul

    Thanks a lot! I noticed it is important to boot virtualbox *without* the original disk attached in VirtualBox. I booted the original disk with the copy disk attached and the guest Windows (at least XP did) saw two disks with the same GUIDs. It then assigned a new drive letter to the copy disk, leaving me with an effectively non-bootable copy disk because during boot, all references to C: will no longer be valid.

  52. teztas00

    Not working for me with WinXP SP2, tried a lot of times. Always getting ‘A disk read error occured, press ctrl+alt+del to restart’. Sad.

  53. teztas00

    Hmmm as mentioned before, resizing from 3GB to 4GB not worked. As a last try I changed from 3GB to 3.5GB and it worked! Host machne disk free space before creating additional virtual disk (4GB in first case and 3.5GB in second) was 4.7GB. Maybe it is related somehow…

  54. Ele

    Hello all,

    Things went wrong in my case. Do not know what’s wrong?

    I test this with my winxp pro OS running on the latest virtualbox 3.2.14.
    I follow the instructions but got a few confusions and it ends up with some problems.

    Step1. I backup the xp.vid file, which I think it better copy entire file folder to keep the original settings in the virtualbox for this virtual disk.

    Step2. create a new file, xp2, which is with larger disk size. Now I have two virtual system: xp_original, xp2.
    Step3. Here is my first question: where to mount the gparted-livecd.iso? xp_origninal or xp2?
    I tried xp_original.
    Step4. copy, paste, resize the partition, and set bootflag.
    Step5. turn off the gparted-livecd and release xp.xvi in xp_original file.
    Step6. start xp_original –> the system asks for disk scanning. done.
    restart xp_original and the system is halted in the windows flag theme.

    I tried to set xp.vid back to the xp_original, and the system can start up and run into the windows.
    However the system is completely clean system without my settings with shared folders and installed program files.

    What is going on exactly?
    I am thinking to dig out my windows XP CD and try to repair the system.

    Any comments and help are appreciated.

  55. Nick Heppleston

    Ele,

    You need to attach your new (larger) disk to your xp_original virtual machine; then mount the gparted ISO (again to xp_original) and boot the machine. Do your gparted copy from the original disk to the new disk. Shut down the xp_original vm and remove your original VDI and gparted ISO, so the vm only contains the newly copied disk.

    Boot!

  56. Alex

    to all having issues copying win7 partitions, I was trying to copy small 100mb partition then big partition but at the end I’ve got unreadable boot partition because gpart couldn’t make it 100mb so here is the fastest way to do it:
    1 create new big disk
    2 inside windows make disk image of system drives
    3 attach new disk and switch new unformatted disk to be primary and old disk to be secondary
    4 boot with setup cd and choose repair and select repair from backup image, this will create exact copy of old drive on new drive so you will get empty space at the end since this drive is bigger then the old drive
    5 boot with gpart live cd and resize second partition to fill all empty space you’ve got
    6 reboot, windows gonna run chkdsk and you’ll be able to login after that
    entire process takes about 4 times less time then trying to copy it with gpart alone

  57. Darren

    Brilliant article. Simple process and easy to follow. I just resized a virtual disk for my VirtualBox WinXP image from 10GB to 20GB, and it took me about 5 minutes using this guide!

  58. Darren

    P.S. Might be useful to add to the article… Before you delete your original VDI file, it’s worth getting rid of any snapshots associated with that vdi. Otherwise, VirtualBox gets in a bit of muddle and refuses to remove references to the original VDI.

  59. Kyle Skrinak

    Thanks for the instructions. I used this as a reference for my Mac-based VB installation. One variance that matter was when creating the ntfs clone in gparted. Your illustration shows “Round to Cylinder” However, the version of gparted I used let me choose between “Cylinder” “MiB” and one other choice. I first chose “MiB” and that rendered a useless partition.

    Using the “Round to” and then choosing “Cylinder” matters.

  60. Falk

    Does not work for me. System: Ubuntu-10.04 (64bit), Windows: XP-SP3
    Fixed-Size => Dynamic-Size

    => “A disk read error occurred”

  61. Pingback: Oracle’s Pre-built Virtual Machine for SOA Suite 11g « AMIS Technology blog
  62. David McClelland

    Thank you for this article, and indeed for the helpful comments and contributions from others.

    With the help of this I’ve successfully resized my Windows 7 x64 system drive from 20GB to 200GB (on an OSX 10.6.5 host). I did need to insert the install disk to perform a repair, but it was as trivial as selecting ‘repair’ and rebooting.

    It’s a shame that Sun/Oracle/Virtual Box development team don’t build a process in to package to allow a little more dynamicity of disk volumes: until they do, this page has been the most helpful by far.

    Warm Regards,

    ____________
    David Mc
    London, UK

  63. Pingback: Resize a VirtualBox image « 0ddn1x: tricks with *nix
  64. Miel

    Thanks for the post. Although I’m a noob, i did succesfully went through all the steps except the ‘Completing re-sizing’

    I am puzzled by whether I should delete the whole old Xp or the newly created one (I’m running windows xp in the virtualbox). I deleted the original hard diks (.vdi file). But now i still have two XP’s. One is the old one now extended with the bigger hard disk. And one is the new one, made to serve as slave. Both are working and have the big size. Does it matter which one I remove? Just to be sure I don’t mess up now it’s almost done.

  65. Jason P Sage

    I had this same issue. My Fix in Win32XPSP3 was:

    1: Boot Up VM
    2: Control Panel->Administrative Tools->Computer Management
    3: Double Click the Drive
    4: Click Convert

    you’re drive is not fixed size anymore :)

    –Jason

  66. Bibendum59

    Great write-up! I followed your instructions and was able to increase the size of my virtual disk from 10GB to 30GB. The current version of gparted was slightly different from your description, but it was easy enough to figure out. Thanks so much!

  67. Nikolaii

    Hey, thank you sharing this post, this has helped me resize my virtual HDD without any flaws! By the way, I think there is a new option (VBoxManage modifyhd –resize) in the Virtualbox CLI tools which permit to resize the virtual disk directly. But as of version 3.2.8_OSE (under Ubuntu Maverick), this option is not available. So again thank you for this nice howto!

    Nicolas

  68. Dan Aunspach

    I write many step-by-step tutorials and read even more. Your guide on expanding a VirtualBox VDI is simply excellent! Even though gparted has changed a little bit since you wrote the guide, you still provided ample information that it was easy for the reader to remain on track and complete the task of resizing the drive. I am sure I will use this guide often in the future and appreciate your taking the time to figure it out an post it.

  69. Pingback: Delicious Bookmarks for June 6th from 00:49 to 11:56 « Lâmôlabs
  70. Jovica Milenovic

    Resizing problem under WIN2008 R2

    I found a solution in the gparted forums:

    This problem is similar to the problem described in the FAQ where resizing your Vista boot partition renders your OS unbootable. In this case the Vista install media can be used to repair the problem.

    I found that resizing a a Windows 2008 Server boot partition produces the same result. Booting off of the install media does not give you a menu that allows you to fix the problem however. What you get is a menu to bring up a command prompt or run memory diagnostics.

    To fix the problem you need to select the command prompt option. From there change into the X:sourcesrecovery directory. There you will find a program called StartRep.exe. Run this program and your boot partition will be fixed and life will be good again. big_smile

    http://gparted-forum.surf4.info/viewtopic.php?id=13530

  71. Emil

    Hi,
    My few cents regarding Windows 2008 R2 guest machine – just a while ago I’ve expanded boot drive from 40 to 120 GB.
    GParted operaton failed, because Windows has partitioned the drive in two chunks, one 100 MB , second 40Gb less 100MB. Copying both chunks with GParted methid failed, possibly by my mistake related to boot flags on wrong chunk…

    Anyway:
    My (very hard-core) solution was to use “dd if=/dev/sda of=/dev/sdb bs=512″ to duplicate the disk sector-by-sector instead of using GParted. Windows machine booted like charm, the only thing remaining was to extend volume using Windows Storage Manager (from Server manager console). Takes a bit longer than GParted, but worked for me.

    Aside note is – few months ago I converted real machine to virtual one and discovered, that Windows Vista (and probably Windows 2008 too) does store crucial boot information… outside of the areas described by partition table information. No comments about, I would not believe, but have seen it by my own eyes. Proven. No tools were able to migrate real machine to virtual one. The only successful tool was…. “dd”. First, performed sector-by-sector copy, than later, used anything else to convert image to VHD/VDI/whatever. Went excellent.
    I’ve lost a week trying numerous tools, before I discovered, that there is information outside of the partitions defined….

    Anyway – thanks for posting. Your instruction is very good and does work excellent with Windows 2003 server quest. I just expanded another machine using your instruction. Just failed on 2008 R2 and had to go with “dd”.
    Kind regards
    Emil

  72. Richie Rich

    I have win 7 64 and go the missing bootmgr message. To fix, I just ran the repair in win 7 boot disk twice. Worked a treat. No need to copy the second smaller partition.

  73. Ender

    I have a Windows 7 x64 system. I followed all the instructions. After restarting the system Windows refused to boot saying something like: “Hardware changed”. I shut the VM down, mounted an existing Windows ISO image and restarted the VM. Then I went to “Repair installation”. Windows installation program searched for existing installations, said that I had boot problems and offered to fix them automatically. I confirmed and after a couple of minutes it fixed the installation, restarted the VM and started chkdsk. Everything works now.

    Thank you very much, Nick!

    Advice:

    1. Do a backup before the start. You can export appliance (requires less space but more time) or copy the whole VM.
    2. Delete snapshots if you have them.
    3. If you are paranoid do a backup again. Just in case.
    2. Make sure that you have enough time.
    For example in my case (AMD Phenom 9850 x4, RAM 8G, x2 7200rpm HDDs so my copy operations are faster than usual, VM size: 30Gb -> 80Gb):
    – Export appliance: 20 min.
    – Delete snapshots: 1 hour. I had four snapshots and it took from 15 to 20 minutes to delete each of them. 4 * 15 = 60 min
    – Do a backup again: 10-20 min. I am paranoid. This time I copied the whole VM and it took 10 min.
    – gparted operations ~30..40 min
    – Windows restore and chkdsk activity: ~15 min
    Total: 2h 15m to 2h 35m.

  74. UV

    Hey guys,

    I had the same problem with win2008 r2 on win7. I tried Rob’s idea and it didn’t work initially, but only because it wasn’t set as my primary partition.
    in order for it to work u need to right click your new image file inside the settings>storage and choose SATA port 0. Then load your windows setup again, choose repair and either use the command line with bootrec /fixboot or let it automatically fix it for you.

  75. CA

    Ran across this and thought I would add my 2 cents.

    I think someone else mentioned this but figured I would state it again. I am running Mac OS X (not by choice) and set up a Windows 7 Home Premium virtual os. Of course I stupidly took the default 20 GB dynamic disk option. After installing some of my development stuff, I was basically out of space.

    So these were the steps I did to resize the partion.

    1) Shutdown the virtual Windows OS.
    2) In terminal, ran “VboxManage modifyhd –resize 80000 nameofimage.vdi”
    3) Startup the virtual Windows OS again.
    4) Administrative Tools -> Computer Management -> Storage -> Disk Management
    5) Disk 0 showed the 100 MB partition, 20 GB NTFS C:, and 60 GB unallocated.
    6) Right click the “C:” partition (either up in the list or the graphical representation) and select “Extend Volume”.
    7) It came up with 1 or 2 screens that I did not make any changes on and just clicked through them (sorry didn’t think it would work so didn’t keep track of their names and such).
    8) Partition now extended to 80 GB (in just a few seconds).

    I didn’t need to run any other utilities except VboxManage. Also this was from a default partitioning of a Win 7 install. I hadn’t converted the partition to a dynamic disk or anything else.

    Hope this helps.

  76. Vadim

    Thanks Nick! The most concise and friendly solution description I could find on the net. Worked for me!

  77. Pingback: [ubuntu] Virtualbox & GParted | Coders & Admins
  78. Pingback: How to increase the size of a VirtualBox Disk Image - Just just easy answers

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>