81

I'm trying to figure out how to change the size of a VDI file. I'm new to VirtualBox, and I got a lot to learn. But I think I got the hang of the basics. I have already installed Windows 7 as my first guest. The host is also Windows 7. I wasn't sure how much disk space to allocate, so I went for a VDI size of 40 GB and fixed size for increased performance. But I have changed my mind now, and I want to add another 10 GB. I've been clicking around the program and reading the Help menu contents, but it's not helping. It explains disk controllers, SAS, SATA, SCSI, yada, yada, but not what I'm looking for.

I searched the world wide web for answers, the VirtualBox forum says you're supposed to use Gparted if you want the easiest method (some mod posted a sticky). Some users discuss using dd command. But that's all Linux stuff. Also, there are plenty of questions here at SU that deal with increasing and decreasing VDI file sizes, but they are all about using Linux as host and Windows as guest.

I found this nice blog post on how to do it with the modifyhd command of VBoxManage. This guy is also doing it on Linux as host OS. He even wanted the same size (50 GB) for his VDI file as I did for mine, what a coincidence. So I thought I would give it a try anyway, either make it or break it. What can possibly go wrong?... eh? Well this is the ugly surprise I got.

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "%userprofile%\virtua
lbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab.vdi" --resize 51200
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage.exe: error: Resize hard disk operation for this format is not impleme
nted yet!

C:\Program Files\Oracle\VirtualBox>

a

Say what now?!... can't resize virtual hard disks of the VDI format? You don't say? Not supporting your own format? Now how about that...

Is there really no simple way to change the size of a VDI file, preferably with a few clicks inside VirtualBox? Anything in progress?

3

9 Answers 9

141

Summary:

  • VBoxManage.exe modifyhd --resize can increase (but not decrease) the logical size of disk image (the size seen by the guest OS).
  • VBoxManage.exe modifyhd inputfile.vdi --compact can decrease the physical disk image size (the size of the image file on disk as seen by the host OS). This however does not change the logical disk size. Note that this only works if free space has been zero'ed in the guest OS first.
  • modifyhd only works only with the dynamic format variant ("dynamically allocated image").
  • modifyhd only works with VDI and VHD image formats.
  • If you are using snapshots you will have to clone the latest snapshot VDI from "Snapshots" subfolder.

For details see section 8.23. VBoxManage modifyhd in the manual.


The reason why decreasing the logical disk size of a VDI has not been implemented yet is to prevent data corruption which could occur and you would have unbootable VMs as a result of it. Therefore, when the --resize option is used, the new disk size must be greater than the current size. It is not allowed to be less than or equal to the current size. In other words a 40 GB disk can only be resized to 41 GB or greater than that, it cannot be resized to 40 GB (that's just dumb) or 39 GB or less than that.

Old versions of VirtualBox created VDI files as "fixed" format varient. The new default setting is now to create "dynamic" format variants when new VDI (virtual disk image) files are created. (I'm guessing this is the case since the introduction of dynamic format variant, whichever version that was introduced in.)

So what the error message "operation for this format is not implemented yet" means is that your VDI file uses the "fixed" format variant. To get around this problem you will have to clone your VDI file using the clonehd command. To view what format variant your VDI file is in at the moment, you can use the showhdinfo command.

Working Example

Show VDI information about the current disk.

Input command: vboxmanage.exe showhdinfo path\inputfile.vdi

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo "%userprofile%\virt
ualbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab.vdi"
UUID:           132e9af1-0428-49f4-bc45-4d84680e17f5
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       C:\Users\Name\VirtualBox VMs\sg2_win7_x64_lab\sg2_win7_x64_lab.
vdi
Storage format: VDI
Format variant: fixed default
Capacity:       40960 MBytes
Size on disk:   40962 MBytes
In use by VMs:  sg2_win7_x64_lab (UUID: dcd106b3-7ed6-4f19-ad94-820ab4dc10d3)

C:\Program Files\Oracle\VirtualBox>

See where it says "fixed default"? That's why it spits out the error above when you try to resize it.

Clone the old VDI file to a new VDI file.

Input command: vboxmanage.exe clonehd path\inputfile.vdi path\outputfile.vdi

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd "%userprofile%\virtual
box vms\sg2_win7_x64_lab\sg2_win7_x64_lab.vdi" "%userprofile%\virtualbox vms\sg2
_win7_x64_lab\sg2_win7_x64_lab_clone.vdi"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 34dafa68-3093-4946-926a-8237ea263
e5c

C:\Program Files\Oracle\VirtualBox>

Voilà! The old file has now been cloned to a new file. Since the default setting in new versions of VirtualBox is to use "dynamic" format variant, you don't have to define that explicitly. Although, if you are working with an older version of VirtualBox, then you might want to set the option to "dynamic" (if at all available) to ensure better compatibility and/or flexibility with future versions of VirtualBox.

Show VDI information about the cloned disk.

Input command: vboxmanage.exe showhdinfo path\inputfile_clone.vdi

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo "%userprofile%\virt
ualbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab_clone.vdi"
UUID:           34dafa68-3093-4946-926a-8237ea263e5c
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       C:\Users\Name\virtualbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab_
clone.vdi
Storage format: VDI
Format variant: dynamic default
Capacity:       40960 MBytes
Size on disk:   7806 MBytes

C:\Program Files\Oracle\VirtualBox>

See how it now says "dynamic default"? How nice!

(On the side note! The reason it says 7806 MB as physical size here is because I had used the --compact option on the original VDI file in an attempt to enforce conversion to dynamic format variant. Just something I read on the VirtualBox forum, it supposedly would have worked with older versions, so I thought I might as well give that a try. It didn't work.)

Resizing the cloned disk.

Input command: vboxmanage.exe modifyhd path\inputfile.vdi --resize 51200

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "%userprofile%\virtua
lbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab_clone.vdi" --resize 51200
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

C:\Program Files\Oracle\VirtualBox>

Success! No format bullshitting no more. Just remember to resize the new, cloned disk, and not the original one. Keep in mind that the size is expressed in MB. I believe you can use e.g. 51200 as well as 50G (or possibly "GB"). There is also the option --resizebyte which can be used to express the size in bytes.

Show VDI information about the resized clone disk.

Input command: vboxmanage.exe showhdinfo path\inputfile_clone.vdi

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo "%userprofile%\virt
ualbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab_clone.vdi"
UUID:           34dafa68-3093-4946-926a-8237ea263e5c
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       C:\Users\Name\virtualbox vms\sg2_win7_x64_lab\sg2_win7_x64_lab_
clone.vdi
Storage format: VDI
Format variant: dynamic default
Capacity:       51200 MBytes
Size on disk:   7806 MBytes

C:\Program Files\Oracle\VirtualBox>

That's it! From here what you have to do is add this cloned drive as your new VDI for the VM. You do that inside VirtualBox. I won't go into that. If you have been able to read and understand this so far then you probably don't need no further guiding. You can either delete the old "fixed" file, or leave it as a backup. Make sure you test the new VDI file before you delete the original source file.

Note! You will not immediately see the new size of the cloned disk. You have to boot the VM with it, and then you have to use your partition management tool to expand your partition to fill the virtual disk (or create more partitions). For Windows, just run diskmgmt.msc and you'll be able to expand the partition in there.

Screenshots

a b c d e f g

Reference

6
  • 1
    superuser.com/review/suggested-edits/227029 (I tried.)
    – thirtydot
    May 6, 2014 at 23:21
  • Good eye! I have corrected the modifyhd parameter. Thank you for bringing this to my attention.
    – Samir
    Aug 3, 2014 at 9:03
  • 2
    A really well written answer! IMHO this should get a lot of votes. Nov 10, 2014 at 9:25
  • +1: It's people like you and the knowledge that you freely share, that makes the StackExchange ecosystem such a fantastic resource! Apr 10, 2015 at 10:26
  • 1
    If you have issues because you are using snapshots, have a look at virtualbox.org/ticket/9103. Basically, you need to apply the modifymedium / modifyhd operation on the snapshot file itself.
    – Jules
    Nov 16, 2016 at 17:25
15

Here's a fairly simple process that worked for me to resize a VirtualBox (v. 4.3.16) fixed size disk to a 60GB dynamic disk on my Mac (OS X 10.9.4) with Linux (Ubuntu 14.04) running as the guest OS:

In Terminal on the Mac, CD into the directory with the VDI file and type the following:

VBoxManage showhdinfo mydisk.vdi  
VBoxManage clonehd mydisk.vdi mydiskClone.vdi  
VBoxManage modifyhd mydiskClone.vdi --resize 61440  
VBoxManage showhdinfo mydiskClone.vdi

In VirtualBox application storage section, add mydiskClone.vdi as a second HD, then start the VM normally.

In the shell on the guest OS, type:

sudo fdisk /dev/sdb
- delete all partitions
- create new partition on full disk

Reboot the guest. When it comes back up, go to the shell again and type:

sudo resize2fs /dev/sdb1

Shutdown the guest OS.

In VirtualBox application storage section again, set mydiskClone.vdi to be the boot disk. Then start guest OS and verify new disk size using properties of "Computer" in the file browser.

2
  • 1
    This answer does not make sense. You first create one large partition on /dev/sdb, then resize it, but you do not create a filesystem on it first. Did you maybe forget the step of copying over the original partition?
    – sleske
    May 12, 2015 at 8:44
  • Thank you dear.It worked Apr 2, 2020 at 20:17
6

Cloning is actually a better solution and there is an easier way to do it.

From the File menu, select Virtual Media Manager, then click Copy. The source will be your original fixed size vdi hard disk and your destination will be something new of your choosing (includes the option of a new).

1
  • This is part of the answer from sammyg.
    – Efren
    Feb 5, 2016 at 0:19
5

OK, so I made it happen without cloning.

I had a 100GB VDI file (fixed format) with Ubuntu on it. Working fine. I wanted to free up some space in the host by shrinking the VM.

Steps:

  1. Cleanup

Deleted unwanted files. 45GB free. I only need 30GB to be freed.

  1. Fix the guest OS

I only have one partition, so cannot do anything from inside guest Ubuntu. Mounted Ubuntu Live in the VM and booted from it.

Used gparted to shrink the partition to 70GB. Created a new partition in the unused space in ext4.

  1. Wipe the free space

The free space in a the new partition (30GB).

Followed this guide : Shrink virtual hard drive on Ubuntu as Guest and Host OS using zerofree

My new partition was /dev/sda3.

$ sudo apt-get install zerofree
$ sudo init 1

...

# mkdir /tmp3
# mount -o ro -t ext4 /dev/sda3 /tmp3
# zerofree -v /dev/sda3
  1. Compact the VDI

    VBoxManage modifyhd "ubuntu.vdi" compact

It took a while, but it worked!

9
  • 1
    Are you certain this worked? According to the VirtualBox manual, --compact only works for dynamically allocated images, not for fixed size ones.
    – sleske
    May 12, 2015 at 8:50
  • 1
    @ ATOzTOA : If the disk image file grows, then it is not a "fixed format" image, but a "dynamically allocated" image, which is what you wrote in your answer.
    – sleske
    May 12, 2015 at 20:47
  • 3
    No, that's a dynamically allocated image. To quote the manual: "If you create a fixed-size image, an image file will be created on your host system which has roughly the same size as the virtual disk's capacity. " virtualbox.org/manual/ch05.html#vdidetails
    – sleske
    May 13, 2015 at 19:49
  • 1
    " A fixed-size image means it cannot grow beyond the specified size." NO. "Fixed-size" means that the size is fixed, so always the same. Read the docs.
    – sleske
    May 14, 2015 at 20:08
  • 1
    If anyone is reading this and isn't sure who's right. @sleske is correct. Fixed size images are exactly as they say. Fixed to the size specified when creating the image. In benchmarks this provides much greater performance over dynamically-allocated images, so anyone using VBox for HD intensive tasks should probably consider this format despite its limitations.
    – Jack
    Jul 19, 2016 at 15:27
3

Kind of late to the party here but I will add my 2 cents. First I will say that this is a convoluted process that will drive most casual users nuts trying to figure out. Why Oracle did not include this in the VBox GUI is a mystery.

Step 1: Use the windows command line (VBoxmanage) to increase the drive size. A tip here is to use the vdi drive's ID instead of endlessly trying to enter the file location and getting error messages.

Step 2: You then need to expand your primary partition to make use of the new space. Download the gparted iso and create a new virtual machine in VBox using it as the IDE source. Then use the existing VDI drive as the sata disk. Do not create a virtual drive for this machine. Boot up the new machine and you will have the gparted Gui running. This may take a couple of reboots to get itself sorted out.

Once gparted is running you will see the partitions of your vdi drive that you want to resize. IMPORTANT: You are going to have to delete the extended partition and swap file space to be able to increase the size of the primary partition so do not allocate all of the new space for the PP. Once you do this then you will have to designate the remaining space for the new extended partition and create a new swap file space within that. I found this to be far easier then futzing around with the command line.

Not a piece of cake but it is doable... it took me about half a day of researching the web to figure this out. Running win8.1 / Ubuntu on VBox

Willie

2

Here's how I resized/enlarged/expanded a fixed VDI image (my process to shrink them is in another answer):

  1. Use VirtualBox to create a new disk of the desired size (size MUST be at least the same as the original). Do this by opening the VirtualBox Settings for the guest VM, navigate to Storage, click the HDD Controller (ex. "SATA"), and then click the "+" to add a hard disk. Then configure the new disk as desired.
  2. Download the gparted live ISO and configure the guest VM to boot from it (again, Storage settings).
  3. Backup your guest VM's current storage.
  4. Boot the guest VM (should boot into gparted live environment). From inside the gparted environment:
    1. Use the gparted application to verify that your existing disk is "/dev/sda", and that your new (larger) disk is "/dev/sdb" (top-right drop down).
    2. Close the gparted application.
    3. Open a terminal with root privs (right click on the desktop -> Terminals -> terminal with root privileges).
    4. Type the following command: dd if=/dev/sda of=/dev/sdb status=progress bs=128M and wait for it to complete. This will copy the original disk to the new disk byte-for-byte, including MBR etc. (Note: This may take a while to complete depending on the sizes of the original disk, speed of disk on host, etc). (Note: if your guest VM has > 1GB RAM allocated to it, you can change the 'bs' param to be "bs=256M" which might speed up the copy a bit).
    5. Re-open the gparted application
    6. Select the new (larger) drive (should be /dev/sdb) from the top-right drop-down.
    7. Expand the partition(s) as desired. To expand a partition which is not at the end, you might have to move partitions which are after the one(s) you want to expand. Depending on the specifics of your partitioning scheme you may need to do this in multiple steps like growing the last partition to the end and then shrinking it by moving everything to the end. In my case, my final partition was the linux-swap so I simply deleted it, expanded my primary partition as desired, and then re-created the swap partition at the end (being careful to replicate its original partitioning scheme).
    8. Apply changes.
    9. At this point you should have a new fixed-size disk with all of the original content, and more space than the original. You can mount the new disk in the gparted live env and verify.
    10. Shutdown the guest VM (gparted live) and remove the ISO from the VM drive.
  5. Go to the VBox Settings for the guest VM, navigate to Storage, and remove the original disk from the list (right-click and select "Remove Attachment"). This should leave your newly created disk for the VM. Note: This step is simply removing the disk from the guest VM's configuration--your original guest VM disk (ie. the small one) is still available on the host machine.
  6. Boot the VM and enjoy!
  7. (Once everything is confirmed working as expected, you can delete the original VM disk.)

While the above has worked great for me multiple times, it seems a few more steps are needed if LVM is used. (NOTE: If LVM is used, you can simply add a new disk of the desired size and then add that disk to the volume group.) With CentOS 6.6 where LVM is used, I had to increase the space within LVM too. So after booting the new disk created above, I did something along these lines (various parts of this will vary based on names of your setup):

  1. Get info about LVM setup:

    # pvs
      PV         VG          Fmt  Attr PSize  PFree
      /dev/sda2  vg_rhel6bm1 lvm2 a--  31.51g    0 
    # vgs
      VG          #PV #LV #SN Attr   VSize  VFree
      vg_rhel6bm1   1   2   0 wz--n- 31.51g    0 
    # lvs
      LV      VG          Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_root vg_rhel6bm1 -wi-ao---- 28.31g
      lv_swap vg_rhel6bm1 -wi-ao----  3.20g
    
  2. Extend physical volume (PV) (volume group (VG) will automatically reflect the same increase):

    # pvresize /dev/sda2
      Physical volume "/dev/sda2" changed
      1 physical volume(s) resized / 0 physical volume(s) not resized
    # pvs
      PV         VG          Fmt  Attr PSize  PFree
      /dev/sda2  vg_rhel6bm1 lvm2 a--  39.51g 8.00g
    # vgs
      VG          #PV #LV #SN Attr   VSize  VFree
      vg_rhel6bm1   1   2   0 wz--n- 39.51g 8.00g
    
  3. Extend logical volume (LV):

    # lvextend /dev/vg_rhel6bm1/lv_root /dev/sda2
      Size of logical volume vg_rhel6bm1/lv_root changed from 28.31 GiB (7247 extents) to 36.31 GiB (9295 extents).
      Logical volume lv_root successfully resized
    # lvs
      LV      VG          Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_root vg_rhel6bm1 -wi-ao---- 36.31g
      lv_swap vg_rhel6bm1 -wi-ao----  3.20g
    
  4. Extend file system:

    Before:

    # df -h
      Filesystem            Size  Used Avail Use% Mounted on
      /dev/mapper/vg_rhel6bm1-lv_root
                             28G   24G  3.1G  89% /
      tmpfs                 939M  232K  939M   1% /dev/shm
      /dev/sda1             477M   85M  368M  19% /boot
    

    Command:

    # resize2fs /dev/mapper/vg_rhel6bm1-lv_root
      resize2fs 1.41.12 (17-May-2010)
      Filesystem at /dev/mapper/vg_rhel6bm1-lv_root is mounted on /; on-line resizing required
      old desc_blocks = 2, new_desc_blocks = 3
      Performing an on-line resize of /dev/mapper/vg_rhel6bm1-lv_root to 9518080 (4k) blocks.
      The filesystem on /dev/mapper/vg_rhel6bm1-lv_root is now 9518080 blocks long.
    

    After:

    # df -h
      Filesystem            Size  Used Avail Use% Mounted on
      /dev/mapper/vg_rhel6bm1-lv_root
                             36G   24G   11G  69% /
      tmpfs                 939M  232K  939M   1% /dev/shm
      /dev/sda1             477M   85M  368M  19% /boot
    
1
2

Here's how I resized/shrank/reduced a fixed VDI image (my process to expand it is in another answer in this same topic):

First a short background on why I needed this (as there are many scenarios to shrink a VDI, some of which may not be feasible with this approach): Years ago I created a fixed VDI for a Windows Server guest and sized it at 600GB. I don't recall why I chose this size but as of today I've only consumed 100GB in that guest and I want to reclaim most of the remaining space. So in my case, I want to preserve all of the data in the guest and I simply want to free up unused space in the guest.

(The following steps are mostly from my memory of having done this over the past 2 hours, so apologies if I miss something here.)

  1. Determine how large you want the new size to be. Naturally you'll probably want to leave the guest with some extra space beyond what it's currently consuming. The size must be at least the same as the data in the source/original disk, rounded to the nearest GB.
  2. Use VirtualBox to create a new fixed-size disk with the size as determined in the previous step. Do this by opening the VirtualBox Settings for the guest VM, navigate to Storage, click the HDD Controller (ex. "SATA"), and then click the "+" to add a hard disk. Then configure the new disk as desired.
  3. Download the gparted live ISO and configure the guest VM to boot from it (again, Storage settings).
  4. Backup your guest VM's current storage.
  5. Boot the guest VM (should boot into gparted live environment). From inside the gparted environment:

    1. Use the gparted application to determine which disk is the "original" and which is the "new" one. The original will have at least one partition, while the new one will be completely blank. (Usually the "original" is the first disk which is assigned /dev/sda, and the "new" disk is the second disk which is assigned /dev/sdb.)
    2. Use the gparted application to shrink the original/source partition(s) to your desired size(s). Remember to click the "Apply" button after you've slated all the operations. (This might take a bit to complete depending on your partition size(s) and disk speed.)
    3. Use the gparted application to create a partition table on the new disk (Device -> Create Partition Table..., leave the type as MSDOS).
    4. Use the gparted application to create identical partitions on the new disk. (To help make sure they were the same, I pulled up the detailed information for each partition on the original disk by using the Partition->Information... menu option and saved a screenshot of it to use when I created the same partition(s) on the new/destination disk.) Be sure to:
      • Create each destination partition the same size as the (newly adjusted) original.
      • Set any flags on the partitions to match (might need to be done after the partition is created).
      • Set any label on the partitions to match.
      • (NOTE: The UUID will get set automatically when the data is copied over.)
    5. Click the "Apply" button to commit all changes.
    6. Note down which disk is the "original" and which is "new", and note down the numbers of the corresponding partitions (ex. /dev/sda1 -> /dev/sdb1, /dev/sda2 -> /dev/sdb2, ...)
    7. Close the gparted application.
    8. Open a terminal with root privs (right click on the desktop -> Terminals -> terminal with root privileges).
    9. Assuming your "original" disk is /dev/sda and "new" is /dev/sdb (if not, adjust the following command appropriately), then we're going to copy each partition, one at a time. For each partition noted down from the step above, enter the following command in the terminal:

      # dd if=/dev/sda1 of=/dev/sdb1 status=progress bs=128M
      

      and wait for it to complete. This will copy partition 1 from the original disk to partition 1 on the new disk byte-for-byte.
      Repeat the command for each remaining partition:

      # dd if=/dev/sda2 of=/dev/sdb2 status=progress bs=128M
      # dd if=/dev/sda3 of=/dev/sdb3 status=progress bs=128M
      # ...
      

      Notes:

      • This may take a while to complete depending on the sizes of the partitions, speed of disk on host, etc).
      • If your guest VM has > 1GB RAM allocated to it, you can change the 'bs' param to be "bs=256M" which might speed up the copy a bit.
    10. At this point you should have a new fixed-size disk with all of the original content, and a smaller VDI file than the original. You can mount the new disk in the gparted live env and verify the data is all there.
    11. Shutdown the guest VM (gparted live) and remove the gparted ISO from the VM drive.
  6. Go to the VBox Settings for the guest VM, navigate to Storage, and remove the original disk from the list (right-click and select "Remove Attachment"). This should leave your newly created disk for the VM. Note: This step is simply removing the disk from the guest VM's configuration--your original guest VM disk (ie. the large VDI) is still available on the host machine.
  7. The last step I had to do for my Windows guest was to set/fix the MBR and/or BCD. (I don't know if any of this is required for a Linux guest as I haven't done it yet.) If I simply booted from my new VDI I got a Windows Boot Mgr error screen with this content (unfortunately I didn't grab a screenshot before I fixed the issue):

    windows failed to start
    status 0xc000000e
    information A required device isn't connected or can't be accessed.
    
  8. Obtain a ISO of a Windows install or repair (ideally one that matches your OS version) and configure the guest VM to boot from it (again, Storage settings).

  9. Start the guest VM and choose to boot from the CD/DVD.

    1. Since each version of the Windows install/repair is different, I can't give precise steps here for everyone. But the idea is to choose the "Repair" option and find your way to a command prompt. In my case of Windows Server 2012 I had to: (a) Choose my language/locale; (b) Choose "Repair your computer" in the bottom left corner; (c) Choose "Troubleshoot"; (d) Choose "Command Prompt".
    2. Once you're at a command prompt run the following commands (thanks to http://loverofcode.blogspot.com/2013/11/fixed-0xc000000e-boot-error.html for the info!):

      > bootrec /fixmbr
      > bootrec /fixboot
      > bootrec /rebuildBcd
      

      This last command should locate your Windows install and prompt to add it to the BCD. Answer 'Y'.

    3. Exit the command prompt and then Turn off the guest VM.
  10. Go to the VBox Settings for the guest VM, navigate to Storage, and remove the Windows Install/Repair ISO from the CD/DVD drive.
  11. Boot the VM and enjoy!
  12. (Once everything is confirmed working as expected, you can delete the original VM disk.)
0

I provide an answer extended to any hosted operating system running on any host operating system. This answer assumes you want to increase the size (to extend).

Note: As pointed out by djule5 (see the comment just after the question), modifyhd is now known as modifymedium (but remains backward compatible). Here I use modifymedium.

1. Quit your running VM

Yes this answer is for a VDI file already used by a VirtualBox VM.

2. Open a terminal on your host to resize the disk image

The command line VBoxManage does not want to resize a disk image using the VDI filename.

$ ls -s1 *.vdi
10260316160 my_disk_image.vdi

$ vboxmanage modifymedium my_disk_image.vdi --resizebyte 16260316160                                                                      VBoxManage: error: Cannot register the hard disk '/home/user/vm/my_disk_image.vdi' {181540c7-b791-4b2f-8e01-5feaff04a6eb} because a hard disk '/home/user/vm/my_disk_image.vdi' with UUID {181540c7-b791-4b2f-8e01-5feaff04a6eb} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file VBoxManageDisk.cpp

Therefore identify the UUID of your disk image.

$ ls -s1 *.vdi
10260316160 my_disk_image.vdi

$ vboxmanage list hdds
UUID:           181540c7-b791-4b2f-8e01-5feaff04a6eb
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       /home/user/vm/my_disk_image.vdi
Storage format: VDI
Capacity:       10240 MBytes
Encryption:     disabled

Extend the disk image size.

$ vboxmanage modifymedium 181540c7-b791-4b2f-8e01-5feaff04a6eb --resizebyte 16260316160
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

3. Use a partitioning tool to extend the logical partition

Run your hosted VM. Then use a partitioning tool.

Some tools for a hosted GNU/Linux :

If the hosted system uses Windows :

4. Check the partition free space

The size of your VDI file (on your host system) may not have changed because your VM has not yet used the extra amount of space. Have fun.

-1

This would work for me and should specify the total amount of the Hard Disk Capacity. Not the space what we need to increase...

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "D:\Virtual Machine\VirtualBox VMs\Windows 7 (FileZilla Server)\Windows 7 (FileZilla Server).vdi" --resize 15360

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .