In Windows 7, I set up another Windows 7 VM in VirtualBox. It worked great. Then, I needed to increase the vhd HD size. So, I used VBoxManage utility to do that with the following comment:

VBoxManage modifyhd "c:\VMs\Win7.vhd" --resize 30000

Then, I tried to run the VM again but it cannot be booted and gives me the following error:

FATAL: No bootable medium found! System halted.

Then, I tried to see what is going on inside the VHD and try to attach it inside Device Management and it says It cannot be attached because The file or directory is corrupted and unreadable.

Any idea what went wrong here and how can I save my VM inside that VHD file?

  • I just had exactly the same problem and I couldn't find any useful solution online so I started analysing the VHD by hand according to Microsoft's documentation. Currently it seems there's bug in modifyhd's implementation where it didn't adjust the offset to data blocks after it has expanded the block allocation table. I need to do some more expriments to verify this.
    – billc.cn
    Sep 21, 2012 at 22:43
  • On VirtualBox 4.3.10, I resized a .vhd file. It looks like not only did it not adjust the block allocation table pointers, but it expanded the block allocation table into the first block of data, overwriting my MBR and partition table.. Don't use VirtualBox to resize .vhd files!
    – Aaron
    Aug 29, 2014 at 19:50

7 Answers 7


Unfortunately the VirtualBox documentation for the VBoxManage --resize option is misleading. You cannot just increase the size of the disk image and have everything work properly. The disk partition information within the image has to be adjusted so that the guest operating system knows the layout of the "drive" the disk image is simulating. You accomplish this adjustment by downloading a bootable CD image that has a partition editor on it and booting the VM onto that CD. You then use the partition editor to adjust the disk image's partitions to use the added space.

There's a nice writeup of the procedure here; just skip to step 4.

  • Well, that's a bummer. This means that I've just thrown away the 3 hours of work. Thanks for the info.
    – tugberk
    May 9, 2012 at 17:49
  • 4
    I followed the nice writeup (after I resized my vhd and couldn't boot from it), and GParted didn't show any partitions on the harddrive, only 50 gigs of unallocated space. Does that mean modifyhd screwed up the drive beyond repair?
    – GSerg
    Feb 5, 2013 at 16:15

I had the same issue

  1. create new VHD with desired size
  2. Use clonhd to copy from old vhd to new vhd

Reference : http://tips.kaali.co.uk/2012/03/16/expand-or-increase-the-size-of-virtual-box-vdi-dis/


I had the same problem and I managed to retrieve the data using the GParted LiveCD

  1. Create new VHD to receive the copied data (create partitions and format)
  2. Download the GParted LiveCD and boot on VirtualBox
  3. Select Device -> Attempt Data Rescue
  4. Click OK and after the Scan click View (this will mount /tmp/gparted-roview-XXXXXX)
  5. On the terminal, mount the second VHD (sudo mount /dev/sdb1 /mnt)
  6. Copy the files (sudo cp -R /tmp/gparted-roview-XXXXXX/* /mnt

After that you can shutdown the Virtual Machine and mount the VHD on Windows Device Manager.


Here they explain the problem (in spanish)


a. "vboxmanage modifyhd (resize)" generates error in many systems (Windows NT5, 9x, Server and x86 versions). The result is a corrupt partition, very difficult to recover

b. You need to execute "vboxmanage modifyhd (resize)" (to resize the VDI) In the path that contains all the files and folders associated with the VDI. Look at the image

enter image description here

enter image description here


Replace "vboxmanage modifyhd" with "vboxmanage clonehd"

  1. Create a new virtual disk VDI (With the size you want to expand). Example: Old.vdi had 50gb. New.vdi create it with 100GB

    VBoxManage createhd --filename /path/New.vdi --size 100000

  2. Clone it with the following command:

    vboxmanage clonehd /path/Old.vdi /path/New.vdi --existing

Note: Both VDI should not be on the same path

  1. Run New.vdi and go to Windows Computer Management and Extend the disk space (assign the empty space). If you do not want to do it manually, you can use any free partitioning application, such as AOMEI Partition Assistant Standard, GParted and many others.
  • update the answer
    – user584517
    Nov 12, 2016 at 20:21

It's worth to note, that I got the exact same problem, which was due to that I issued the command modifyhd while the guest was running. The official documentation says nothing about, that you have to delete snapshots first and the that guest should have been stopped.

My plan was to resize the disk while the machine was running because I've got a dynamic volume which could also be increased on the fly. However, this was a bad idea as I rebooted the machine to get the full disk size I was left in the dark with a corrupt image, which I couldn't restore even not with testdisk. Testdisk finds the partitions but the filesystem is badly damaged and cannot be repaired.

So be advised:

  1. Merge all Snapshots into the Base Image
  2. Shut down the Guest OS

I've repeated the procedure on my machine with a backup image and the guest os being powered off, this works well.


I was able to recover an image that was broken by this bug. Unlike Edison the gparted live image did not find anything. Here's what I did:

  • First, since apparently VBox support for VHD is buggy and terrible, begin by converting the VHD to a VDI with VBoxManage clonehd foo.vhd --format vdi foo.vdi. When I skipped this step, I could recover files from the image but it would "break itself" again after a few reboots. I'm guessing the bug really screws up the VHD file in a way that later I/O "re-breaks" it... VBox doesn't seem to have these issues with VDI so I gave up on VHD.

  • Boot into WinPE, the Windows Preinstallation Environment. How to do this could be an article unto itself. If you are not familiar with this here's a shortcut: Boot from a Windows Setup DVD (Vista or higher) and hit shift-F10 once the GUI comes up, it will give you a command prompt.

  • Download testdisk, find a way to get it onto your WinPE image (or a simple USB stick would work), and run it from the WinPE environment. (Note: WinPE lacks WOW64, the 32-bit compatibility layer for 32-bit apps. Therefore my 64-bit WinPE setup needed the 64-bit testdisk binary.)

  • Testdisk found the partitions and restored them.

  • At this point the files were recovered but the bootloader failed for several issues. First I used diskpart to mark the partition as active (list disk, sel disk <disk number>, sel par 0, active). Got further, wouldn't boot. Went back into WinPE and deleted \boot, then ran bcdboot C:\windows /s C: to reinstall the bootloader.

  • At the end I ran chkdisk /R to be sure the image was ok. Took a few hours, didn't find any issues.


I had the same problem, GParted didn't recognize the partitions at all, and it was shown as unallocated space. At this point I understood that the data could have been lost.

Then I remembered using testdisk to look for lost partition on hard drives, so why not try it on virtual disks? and it worked.

  1. Boot from GParted, at the time of writing this reply, GParted had "testdisk" inside it. Just run the terminal, run "sudo testdisk /dev/sda" or whatever it shows up in your computer. Run "sudo fdisk -l" to show all disks.
  2. Analyze Partition Table, it will discover the partition immediately, since it's still in the first sectors. Write new partition, table, then proceed with GParted to continue the recovery, as instructed in this link: http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/
  3. Next time you wish to do this, make a copy of your VDISK first.
  4. I noticed in the below link that they create new VHD then clone with --existing: http://tips.kaali.co.uk/2012/03/16/expand-or-increase-the-size-of-virtual-box-vdi-dis/ I didn't try yet, but I recovered my disk with the above instructions.

Hopefully that helps someone.

  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.
    – DavidPostill
    Jan 25, 2017 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.