Saturday, September 05, 2020

Expand Your Virtualbox Virtual Hard Drives

This How To will walk you through expanding the virtual hard drive size of a guest Windows 10 virtual which is being hosted on an Ubuntu 20.04 machine running Virtualbox 6.1.

There are three sections to this guide.  

Section I is work that needs done from a Terminal Window inside your Linux Host System and from inside the Virtualbox 6.1 program.

Section II is work that needs done from inside you virtual Windows 10.

Section III is work done inside your virtual Windows 10 in an Admin Command Prompt but only needs done if you encounter certain problems in Section II. 

------------------------------------------------------------------------------------------------------------------

SECTION I
Work done in Linux and Virtualbox


1.  Make sure your virtual is shut off.

2. Locate your Windows 10 virtual image file (.vdi).  Mine is located in "/Home/username/VirtualBox VMs/Windows 10 Home/Windows 10 Home.vdi"

3. Make a backup copy of the .vdi file and put it in a safe place (this will take a little time since it is probably several gigs in size, mine was 60gb).

4. Open Virtualbox (not your virtual Windows 10, but Virtualbox itself).

5. Once in Virtualbox, Right Click on your Windows 10 virtual and select SETTINGS.

6. In settings, select STORAGE, then Right Click on your .vdi file (mines called "Windows 10 Home.vdi") and then click on the REMOVE ATTACHMENT.  

NOTE:  Don't worry this does not delete anything it just disconnects it from this virtual.  Think of it as taking the hard drive out of your computer, you can put it back in whenever you want, nothing is lost)

8.  With the .vdi file detached, close Virtualbox

9. Open a Terminal Window and navigate to the location where your .vdi file is located (Mine is in /Home/username/VirtualBox VMs/Windows 10 Home/Windows 10 Home.vdi) (from Step 2).

10 Once you are in the same folder as your .vdi file, type the following into your Terminal Window.

vboxmanage modifyhd "NameOfYourVDIfile.vdi" --resize 128000

NOTE: You will need to replace "NameOfYourVDIfile.vdi" with the actual name of your .vdi file. The 128000 at the end is the new size you want your virtual hard drive to become.  This number is in megabytes (mb) so in this case 128000 mb equals 128gbs.  This number has to be bigger than your original virtual hard drive size (you can't make it smaller this way) and has to be able to fit in your actual physical hard drive's free space (this is your physical computer's physical hard drive). 

11. Once you've made the changes needed to the above command, hit ENTER.  You will then see something that looks like this:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

12.  You can now close your Terminal Window, you have resized your virtual hard drive, now you have to reconnect it to your Virtual Windows 10.

13. Open Virtualbox, Right Click on your Windows 10 virtual and select SETTINGS.


14. Once Settings opens select STORAGE then Single Left Click on CONTROLLER:SATA, then Double Left Click on the little picture of a hard drive (circled in red in this slide)


15. Once you've clicked on the little hard disk icon you will be present with the option to pick the .vdi file you want to attach to your Windows 10 Virtual.  Pick your Windows 10's .vdi file that we just expanded.  Mine is called "Windows 10 Home.vdi" and shows up under NOT ATTACHED in the popup window.


16.  If you've done everything right so far you should now see your newly expanded virtual hard drive (.vdi file) reattached to your Windows 10 Virtual like in the slide below.




Congratulation you've expanded your virtual hard drive for your virtual Windows 10 and your Windows 10 virtual machine will now boot but you will not see any difference in the amount of space on your virtual hard drive.  Now we have to tell Windows 10 that it has more hard drive space and we have to expand it's virtual hard drive though Windows 10.

------------------------------------------------------------------------------------------------------------------

SECTION II
Working inside your Virtual


1. Start your Windows 10 Virtual.


2. Once logged in click on START then ADMINISTRATION TOOL then COMPUTER MANAGEMENT and select DISK MANAGEMENT.  You should see something like this slide:


NOTE:  You may see a 4th partition between your C: and the Unallocated block, named Windows Recovery Partition.  If you see this 4th partition (Windows Recovery Partition) you will need to skip to Section III labeled Remove Windows Recovery Partition below this section.  Once you complete all the steps in the Remove Windows Recovery Partition section return to this point and proceed with the remaining steps in this section.

3. Assuming that your partitions look like the slide in Step 2 (Just 3 partitions; System Reserved, C:, and unallocated).  If so, great.  Right Click on on the Block labeled "C:" (One with a blue line over it in the middle).  This will bring up a menu, select the EXTEND VOLUME option which will start a wizard. (if the Extend Volume option is grayed out then read the NOTE in Step 2 above)


4.  Once the wizard starts you can pretty much just accept the defaults until the wizard finishes.  Here is a walk thru of my wizard:




NOTE: Your partition size numbers will be different than mine base on how much you expanded your virtual hard drive in the first section of this how to.  Generally you just want to accept the defaults which will try to add all the additional space it can. 


5.  When you finish the wizard you now see that you only have two partitions, System Reserved and C:. Congratulation you are done and you can close COMPUTER MANAGEMENT.  Check your C: drive you should now have more room and can breath a little easier.

------------------------------------------------------------------------------------------------------------------

SECTION III
Removing a Windows Recovery Partition
ONLY DO THE STEPS IN THIS SECTION IF YOUR EXTEND PARTITION WAS GRAYED OUT IN SECTION II

If you encountered a 4th partition named Windows Recovery in Section II and it was between your C: and Unallocated partitions, you can not combine the two (C: and Unallocated) without removing the Windows Recovery Partition.  If the option to EXTEND VOLUME is grayed out on your C: partition, removing the Recovery Partition is the only way I know of to proceed. We will need to do this from an Admin DOS Command Prompt from within the virtual Windows 10.  Here's how:

1. From within the virtual Windows 10
 Right-click the Start Menu and select Command Prompt (Admin).

2. Type diskpart and press Enter.

3. Type list disk and press Enter.
 (A list of disks will be displayed.)

4. Type select disk # and press Enter.
 (Replace # with the number of the disk containing the recovery partition) 

5. Type list partition and press Enter.
 (A list of partitions will be displayed.) 

6. Type select partition # and press Enter.
 (Replace # with the number of the recovery partition

7. Type delete partition override and press Enter.

After the confirmation message, you can close the DOS Command Prompt and go back to Section II and finish those steps.