Cannot boot after vhd hard drive is resized in VirtualBox

22,054

Solution 1

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.

Solution 2

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/

Solution 3

Here they explain the problem (in spanish)

Summary:

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

Recommendation:

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.

Solution 4

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.

Share:
22,054

Related videos on Youtube

tugberk
Author by

tugberk

Updated on September 18, 2022

Comments

  • tugberk
    tugberk over 1 year

    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?

    • billc.cn
      billc.cn over 11 years
      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.
    • Aaron
      Aaron over 9 years
      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!
  • tugberk
    tugberk almost 12 years
    Well, that's a bummer. This means that I've just thrown away the 3 hours of work. Thanks for the info.
  • GSerg
    GSerg over 11 years
    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?
  • Daniel S
    Daniel S over 7 years
    update the answer
  • DavidPostill
    DavidPostill over 7 years
    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.