My Linux VirtualBox guest OS often runs out of space – I never learn that to build anything in Linux, you need about 10 times the amount of space that you think you need. Also, VirtualBox recommends very small default values, so it is easy to be caught out.
Anyway, here are the current steps to re-size a VirtualBox disk, where Linux is the guest OS and Windows is the host OS.
In this example I am using VirtualBox 4.2.6 (The approach is valid with more recent versions also). The host OS (the one that is running VirtualBox) is Windows 7 and the guest OS that I wish to re-size is Ubuntu. Please backup everything before continuing as something could always go wrong.
Step 1. (Optional) Move the VDI file in Windows
If you need to move the VDI file to another location/physical drive with more space, you can do the following.
- With VirtualBox shut down, using Windows Explorer move your vdi file (e.g., “c:\MyLinux.vdi“) to its new location (e.g., “d:\MyLinux.vdi“)
- Start Oracle VM VirtualBox Manager -> choose File-> “Virtual Media Manager”
- Under the “Hard drives” tab, choose your disk (e.g. “MyLinux.vdi“) and press the “Release” button at the top.
- Now with the disk selected press “Release” (this should remove the last location)
- Close “Virtual Media Manager”, choose your VirtualBox instance (e.g. MyLinux which should say “Powered Off” underneath) and press the “Settings” button at the top.
- Press”Storage” on the left-hand side, and under Controller remove the current drive by pressing the red minus. Then Press the + with the hard drive platters.
- It should ask “You are about to add a virtual hard disk to the controller IDE Controller”, pick “Choose existing disk” and browse to the location to which you moved your VDI image (e.g. “d:\MyLinux.vdi“). Press “OK”
- Check that your image boots before you go any further.
Step 2. Resize the VDI file
- Shut down VirtualBox again.
- Make a copy of the VDI file – just in case (“MyLinux.vdi” -> “MyLinuxCopy.vdi“)
- Go into the Windows command prompt (Start->type “cmd” into the box)
- cd to the location of the VDI file that you wish to resize, e.g., “d:\MyLinux.vdi“
- At the Windows command prompt, type:
D:\>VBoxmanage modifyhd MyLinux.vdi --resize 100000
this will re-size the drive to 100 GB. Pick a value that suits you. Note, your vdi file will not change in size at this point. The output should look like:
D:\>VBoxmanage modifyhd MyLinux.vdi --resize 100000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
D:\>
Unfortunately that was the easy part!
Step 3. Resize the Linux Partition
At this point you need to grow the Linux partition to take up the space of the newly resized vdi file:
- Go into “Oracle VM VirtualBox Manager”, choose your Linux image “MyLinux (Powered Off)”. Press “Settings” and under “Storage” when you select your disk you should see “Virtual Size: 97.66GB” for the 100GB that I set and “Actual Size: 18.52GB” if your previous disk was 20GB and now almost out of space!
- Unfortunately, if you boot this image at this point the space will not have been allocated to your Linux drive. A “df -k” will make that clear!
- You need to use GParted for this. Go to http://gparted.sourceforge.net/livecd.php and download a GParted Live on CD ISO file (i.e., GParted Live CD/USB/HD/PXE Bootable Image ISO File Use the latest version for your architecture – e.g., gparted-live-0.22.0-1-i586.iso). Save this ISO on your hard disk.
- In “VirtualBox” Create a new virtual machine, as in Figure 1, and call it “GParted” with Type: “Linux” and Version “Linux 3.8” or whatever version. Choose “Do not add a Hard Drive” and ignore the warning.
Figure 1: Creating the GParted Virtual Machine
- Pick your “GParted (Powered Off)” virtual machine and press “Settings”. Choose “Storage” and under “Controller: IDE Controller” add a new CD/DVD device. Browse to the location of your GParted ISO file and select it. Your first item under “Controller: IDE” should be “gparted-live-XXX”. If you have a second “Empty” disk you can remove it. Then add the disk that you wish to resize under “Controller: SATA Controller”. At this point it should look like Figure 2, where HomeOfficeUbuntu is the “MyLinux.vdi” discussed above.
Figure 2: Add the SATA Controller and Disk
- Press OK and start your GParted Virtual Machine and you should see it boot (very quickly). Choose Gparted Live (Default settings). Choose all the default settings and your language of choice. Press 0 to start X and you should end up with a virtual machine running that looks something like the output in Figure 3.
Figure 3: GParted Virtual Machine Running in VirtualBox
- You can see that there are 78.12GB unallocated and this is the space that we wish to allocate in my case to /dev/sda1 which is an ext4 filesystem and is currently 18.53GB in size.
- Now, you should have made a backup of your vdi at this point. If you haven’t go back and do that – so many things can go wrong here and you are on your own!
- If it is any partition other than /dev/sda1 you can right-click the partition you wish to resize and choose “Resize/Move” (as in Figure 4) – not in my case!
Figure 4: Resize/Move the Partition
- However, my problem is that the extended partition and my linux-swap are blocking me from changing the size of my /dev/sda1/. So, unfortunately I have to delete and re-create them again. So, select the linux-swap and press “Delete” and /dev/sda2 (or whatever your one is!) and press “Delete”. The press “Apply” as in Figure 5 below.
Figure 5: Delete Partitions
- After applying the changes choose the /dev/sda1 partition and choose resize as in Figure 6, allowing enough space (“free space following” of 1023) for a new swap partition. It should say “Grow /dev/sda1 from 18.53GiB to 96.66GiB” and it may take a short while (~1 min). Hopefully you should get a “All operations successfully completed” message, as in Figure 6.
Figure 6: Resizing the Partition
- Now, re-add your Linux Swap Space. Press on the unallocated space and right-click to “Created new Partition” -> choosing “Create as: Extended partition” as in Figure 7 below.
Figure 7: Output after changes are applied
- Press “+Add” and right-click the new “unallocated” to Create a new partition. Choose as “Create as: Logical Partition” and underneath “File System: linux-swap” as in Figure 8.
Figure 8: Creating the Swap Partition
- Now press “+Add” and then “Apply” in the main window. Hopefully all changes are successfully applied and now my output looks like Figure 9 below.
Figure 9: A successful partitioning
- You can now safely shut down this Live CD Virtual Machine.
- Finally, boot your original “MyLinux” Virtual Machine and all should be in order, so that when you do a “df -k” you get the output as in Figure 10 below.
Figure 10: A successful outcome
So, now the disk is only 21% utilised in my case and I am free to work away with my new found space!
Good luck with this… remember to back up your VDI in advance and be careful when you are working with GParted.
Thanke you so much, you are the best 😀
Hi Derek,
Gret book and very well thought out.
This method will not work for LVM partitions.Using Gparted and following the advice here (https://oracle-base.com/articles/vm/virtualbox-extend-disk-and-file-system) is successful with LVM partitions.
Best Regards
John
palaukanna
Thanks a Ton Derek. I had seen lot of other links but nothing simpler than this.
very clear and thorough. Thanks alot.
Very nice! Much appreciated!!!
Thank you. This explanation is coherent and traceable, especially easy to be followed.
Such a useful article for me.
You just saved my day!
Thanks a lot!!!
Thanks for posting this. This helped a lot.
Thank you!! Worked perfectly! Your screenshots were worth an extra 1,000 words!
Thank you dear sir! That worked perfectly!
Sorry but it went all wrong. What went wrong was
GParted where the error “Invalid partition table – recursive partion on / dev/sr0.”
regards
Nisse
Oh my god, I never comment on posts but I love you. I’m from Ireland by the way so super proud to see an Irish guy putting out this VERY useful piece of information. Thank you so much!
One tidbit that had me stuck before I even got to this part. If you need to resize a fixed-size VDI it won’t work. First you need to clone it to a variable size one with the following: VBoxManage clonehd [old-VDI] [new-VDI] –variant Standard
Thanks for the precise and clear guidance on this subject. My only question is how to run VboxManage in an 64bit host environment ?
Thank you very much
George C.
It’s got to be in your path, if it’s not you can call it directly from its location, like this :
C:\Progra~1\Oracle\virtualbox\vboxmanage modifyhd .\Ubuntu.vdi –resize 500000
Thanks a lot man..
Thank you!!
Thank you. It helped me a lot !!
The hard part (Step 3) must not be that hard:
http://linux.die.net/man/8/resize2fs
Hi Marc, Do you have that working? The problem is the Linux swap partition – how have you moved that? Derek.
Hi Derek,
You can not move partitions with resize2fs. So it is always a good idea to place the partitions that might grow in the end of the disks. Best Practice with VMWare and VBox is to create one virtual disk image per partition. Saves you a lot of trouble.
I never moved a swap partition. I delete them and recreate them where needed. I’m doing stuff like that for a living. I maintained a server with a 2TB data volume that we grew 100GB every 2 month and I just did it for the home volumes of some Ubuntu VBoxes.
Thanks
Marc
Hi Derek,
Thank u so much for this solution.
But i have another problem .i.e
VBoxmanage modifyhd centos.vdi –resize 1000000
by using this command i extended my centos.vdi size to 1TB, but i actually need only 100 GB
there is any way to reduce this size to 100 GB.
Please helpme to get out of this.
thanks
Hi Derek – Worked great. Thanks for your help. You definitely saved me today!
Thanks for the tutorial but I found out that the third step is overly complicated. Just mount the GParted Live CD on the same machine as the hard drive you want to resize. Then press F12 when starting a machine, press C and proceed. Worked perfectly for me 🙂
I am stuck in 3rd step. I tried to add a “New Virtual Machine” and it asked me to with 2 options , 1)Create new hard disk 2) Use existing hard disk and these two options are enabled by a checkbox with a tick saying “Start-up Disk”. If I uncheck it (where both the options will get disabled) and say next, it gives a warning “You did not attach a harddisk to the new virtual machine”. I ignored it as you suggested. I guess I followed your steps correctly till here. Now I added the GParted iso and then added the SATA controller pointing to my resized vdi file. And when I try to boot “GParted”, and I chose Gparted Live (Default settings), after this it just hangs there with a BLACK BLANK screen. I badly need to resize my partition, any suggestions would be of great help. I looked at the GParted website for tips to boot section, but nothing was relevant.
Thanks,
-Sandeep
Dear Derek
I have been looking for a clear guide on how to do this for a whole day, and most guides stop after the easy step #2.
I found your explanations clear and articulate, and you explained every necessary operation without assuming the reader is a big tech wiz, ground-up.
Thank you very much for taking the time to create this great step by step walk through to simplify this task.
Appreciatively yours
Amit
Dear Derek
Thank you, it worked withouth problems, even as newcomer in Unix
Anders
Thanks a lot, it worked
Great article, and it all worked right the first time I tried it, although it did not work for a second vm with multiple snapshots.
Greg A: If you have multiple snapshots you can just clone the last snapshot and resize the clone using the above instructions. Detailed instructions
* In the Virtual Box Manager UI, click the Snapshots button under your virtual machine
* Select the last one (ie. Current State)
* Right click and select Clone
* In the wizard that appears you will want to select Full Clone (on the second screen of the wizard)
* Once the machine is cloned you will see that it only has no snapshots, just Current State – follow the above instructions but using the .vdi of the clone
I can confirm that I carried out the blog post instructions against the original (non-clone) machine and it did not work – it booted but was at the original size. I then cloned this machine (which may have some messed up snapshot somewhere due to my failed attempt). I successfully carried out the blog post instructions against the clone, which I now use instead of the original.
Thanks Declan. Your advice worked. somehow it has a problem dealing with snapshots, so I guess I better use appliance backups if one needs to resize the vm partition.
Thanks, it worked perfect the first time
Thanks, it worked perfect the first time
Thanks, it worked perfect the first time
Thanks Derek..
It worked without any problems and it saved my day.
Excellent, works very well. very clear steps to let me follow and keep confident.
One of the very best (and very few) Linux howto’s that is simple, clear and works as advertised.
Any chance you could write Linux manuals for everything else too?!
Many thanks,
-Chris
Thank you for your tut. My partition is a LVM one, so I did everything instructed. My LVM volume shows up as expected, but my mounted filesystem shows the old size. If you have any recomendation, thanks in advance.
Thank you so much. You saved me a lot of time. Very detail and thorough.
In the 3. step 4.point you do not have to create another VBox machine.
From VirtualBox Manager “insert” GParted.iso into a CD/DVD drive of the machine you’re resizing (Settings-Storage-Add CD/DVD Device; either at “IDE Controller” or at “SCSI Controller”).
Then start your machine and press F12 at boot time to change boot device to CD/DVD.
GParted should be started now, do whatever you want to, exit from GParted and you’re done.
Just for Posterity: I tried this and it F***ed everything up. I’m running VirtualBox on windows 8.1 (host), simulating Centos7.
Thank you! I have been working on this for hours, and your site helped me figure it out in minutes!
Dear Derek
I tried the above steps but when start the VM there is a black window and nothing happened
Kindly advice
Derek,
Thank you for the very helpful and detailed how to. I ran into one thing that may happen to other people. When I restarted my virtual machine the swap was not on. The problem ended up being that my fstab file referenced the swap by its UUID which changed since we deleted and recreated the swap partition. I needed to find out the UUID of the new swap partition (ls -l /dev/disk/by-uuid), edit the /etc/fstab file to put in the updated UUID information and then reload the fstab file (mount -a). I also issued a swapon -a but I don’t know if that was actually necessary. After that the swap was reported as being active.
Thanks again.
Kuddos Derek 😀 Thank you
Thanks!
This approach help me when VBox didn’t start because of little space on the hard drive.
Brilliant. Not half as scary as I thought it was going to be. Ta.
Thank you so much for sharing this, I was going nuts as my guest os was not booting !
Incredibly helpful article, thanks a million! And from a fellow Irishman!
strange thing: i followed this guide clicked apply and it all looks good in GParted VM… my changes show up when i restarted GP VM… when i start my server VM its not recognizing the changes i made and shows the old allocation… is this even possible? what’s a likely cause?
…so i tried adding the ISO direct to the VM I i wish to change and boot it via VM… while partition changes appear in my GParted VM on subsequent re-starts they are not showing in the VM. Looks like some sort of cacheing mayhem.
Did you ever find a resolution to the VM not actually showing the increased size in the df -k? All of the steps in this tutorial seemed to work flawlessly, but it looks like I have the same problem you had…
I was able to fix the caching issue by removing the disk/vdi then re-adding it.
Wow!!! That’s it!!! Thank’s a lot!
Been putting this off for a while because it’s exactly the kind of thing I would really screw up, but I got it to work with no problem following this guide. It was so detailed and yet easy to follow…thank you so much for putting this together!
I had an 8GB virtual disk, started installing TeX Live, and boing, out of disk space. I knew there should be a way to do the resizing of a vdi, but couldn’t quite get it to work, until reading this blog post. Thanks for a straight forward explanation, it worked a treat.
Thanks. Worked perfectly.
Thank you so much, your tutorial is very thorough and it works.
You are really a good teacher.
Thank you very much
Great Article, I’d found a YouTube video which involved using the existing VM (with disk size issues) in combination with a Linux ISO, however that involved a much slower process. The use of a blank VM that just boots off of GParted ISO, is far more efficient! Thanks
Very good tutorial! Thank you
Awesome!! Thanks so much for this real neat explanation.
works like a charm. Thanks
Thanks for taking the time to post this. Worked like a charm!
Cheers Derek – Excellent write-up, really helped me resize my VM.
The moral of the story is, as you rightly point out, to make your initial VM hard drive as big as you can.
Hi, I’ve successfully ran the comment and the size changed in vm settings-> storage.
but there is no unallocated space shown on disk management???
I used administrator account. really need help
Thanks, I had to use the tool Logical Volume Management under System->Administration on Oracle Linux 5 to use the free space anyway. I guess i did not need the GParted step since my swap memory was at the beginning of the drive and not obstructing the growth.
GParted is a mandatory step as i found out the next time i had to increase the space.
I was like working to expand the virtual hard disk for more than a week and ended up doing nothing, until get to this page. Now my problem is solved. Thanks for sharing this valuable information.
This has to be one of the clearest and best guilds out there, I look at several sites and your is by the best. Thanks.
Brilliant … thanks alot
This tutorial is just great, step by step, clear and easy to understand. Especially the “trick” with a “virtual gparted” is extremely helpful: I am on linux, my vdi’s are on encrypted disks, so booting from a gparted-CD wouldn’t help – but this way it was just click-click-click… Thanks a lot!
Pretty good directions and best of all they worked. Thanks!
Struggled abit but I eventually got it right
running fedora 64x on my guest and
df -k still showed no change to the size
i ran these 2 commands as root that fixed the problem
lvextend -l +100%FREE /dev/mapper/fedora-root
resize2fs -p /dev/mapper/fedora-root
when I ‘df -k’ again it was corrected. I restarted to be sure aswell.
Thanks so much for your additional commands. It solved my same issue because the /dev/mapper/ubuntu1–vg-root not yet updated size after using GParted.
Very good instruction and it helped me a lot.
Thank you.
You sir, are the boss. Finally someone who knows how to do this properly. Thank you, much appreciated.
Thank you!! Thank you!! Thank you!!
Perfect steps!! clear description with plenty of diagrams. I can’t thank you enough..
You are right about the misleading VBox recommendation. I allocated only 8GB and I filled it within a few days..
Thnx 🙂 U saved my ass 🙂
Thanks you for this excellent article.
This is a well written, perfectly detailed guide. Thanks for posting it!
Very good article thanks. you just missed making the swapfile, changing it in the fstab and turning it on.
mkswap /dev/swapvolumehere
vi /etc/fstab and edit the swap volume/label
swapon -a
Thanks. It really helped
You are the man! Thanks a lot for such a helpful post
This really made my day 🙂 (nightly)
Thanks for the tutorial, it is great and easy to follow. But I’m having an issue, I’m running a ubuntu 12.04 vm on a windows guest, I followed the tutorial step by step and the vdi file it was resized, but when I run the df -k I’m seeing the old space (without resize changes). what I need to do to be able to use the new partition space?
This is the result of the df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 16G 15G 308M 99% /
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 396M 800K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 152K 2.0G 1% /run/shm
compartidos 298G 199G 100G 67% /media/sf_compartidos
/dev/sr0 57M 57M 0 100% /media/VBOXADDITIONS_4.2.12_84980
I resized the disk to 100GB.
Hi, you may need to go back to Step 3 again. It sounds like the changes didn’t commit.
Hi Derek,
I also had the same problem – all the steps worked properly but the new space was not visible. I did some more digging around, and it looks like some additional steps are necessary for systems using LVM..(actually, one of the comments to this thread gave a link to an excellent blog on this.. https://blog.jyore.com/2013/06/virtualbox-increase-size-of-rhelfedoracentosscientificos-guest-file-system/ )
But basically, it seems that if you are on Red Hat, you need to do what you describe above AND the extra steps from that link, and then it works just great..otherwise the changes don’t commit.
This worked really nicely for me, but If this is a common problem then maybe it might be worth adding a link to the extra steps at the end of your post? Also, I took the advice of mounting the disk on the main VM and booting to it rather than making a separate machine, and that worked very well for me too…
Thanks for all the help!! 🙂
Thanks Arwel, Derek.
The changes were commited, I mean the vdi files lenght is 100GB and if a open it with gparted, it shows the partition as 100GB. But Ubuntu does not recognize the new size.
I also tried to create a new partition and it is not recognized by Ubuntu.
Hi Goni, I have no idea what is going wrong in that case. Derek.
I have the same issue as Goni, but with Centos 6.6
Thanks Derek, for the clear and step-by-step tutorial. I think it’s my first time ever that I leave a comment about a tutorial. You just saved my day! My guest OS was not booting and until now I just didn’t pay much attention to virtual machines. The only difference I got to your explanation was that I had first to clone my fixed-size VDI in order to turn it to a variable size.
This is the best tutorial for VirtualBox resizing with GParted. Thank you.
This blog post explains how to use pvresize & resize2fs for RedHat like file systems, if gparted can’t help.
http://blog.jyore.com/?p=121
Thank you , it was so good get this class of help in you web site, in my case I had to use C:\Program Files\Oracle\VirtualBox>vboxmanage.exe modifyhd “c:\users\”user”\virtualbox vms\Directory\Hard Drive PC.vdi” –resize 20000 for the step 2
Thanks for this tutorial. Precisely put. The snapshots captured were of great helped. Saved a lot of time for me!
Thanks Derek for this amazing post. I join the queue of grateful people above 🙂
This is the best tutorial for VirtualBox resizing with GParted. Thank you. You are Great!!
Just the solution I needed. Thanks!
Derek, Thanks for a great howto, worked 1st time
This is super cool. Well explained Derek. Thanks a lot
Derek, thanks so much!
Worked like a charm… Thanks a bunch on this one ! 🙂
thank you very much
very good tutorial …
Thank you – worked perfectly, I was stumped on how to resize the partition until I found this.
Thanks a lot. Worked like a charm… simple and effective.
Bravooo
Easy to follow and everything works as stated.
Thank you so much very well guided. perfect for a beginner 🙂
Thanks! This helped a lot
Thanks a lot mate. That worked like a charm 🙂
Thanks a ton! 🙂
Hi Derek
After I had made the initial copy of my fixed VirtualBox vdi to a dynamic-sized disk, I felt bold, as I knew I had a backup.
So I simply installed the gparted directly in the new dynamic copy.
I stopped the swap, deleted it, grew the sda1 partion and recreated the swap.
It worked like a dream.
So at least today you can skip the gparted iso .
BTW – I am reading your book on the Beaglebone – very good. Thanks.
Thanks Klaus, I’ll have to give that a go. Kind regards, Derek.
I was unable to complete your instructions on Oracle Linux 6.5 because of LVM. However, I was successful once I did the following.
Start Linux VM in VirtualBox
Make sure you are set up with the latest yum repositories via the instructions here: http://public-yum.oracle.com
Execute the following in a terminal:
# yum install system-config-lvm
( I was root, so you may have to insert sudo at the beginning like “sudo yum install system-config-lvm” )
Answer ‘y’ when asked.
Wait for install to complete
Execute the following in a terminal to start system-config-lvm GUI:
# system-config-lvm &
( may need sudo again here )
Navigate Volume Groups > vg_xxxxxx > Logical View > lv_root
Click “Edit Properties”. The edit Logical Volume window pops up.
Click “Use remaining”
Click “OK”
File > Quit
Verify space was added
# df -h
Shutdown VM
Start the VM up again and verify space with df -h
Thanks John, Derek.
When I tried the instructions I got the blank screen like a few others. The solution was to enable EFI (Settings->System->Motherboard)
Your comment saved my day! thanks! as it was blank screen I was struggling it.
NOTE: The latest version of GParted did not work for me! It would never load fully in Virtual Box.
Instead, I used the link Derek posted in the blog (it is one version earlier than the latest), and it worked.
same here – Gparted 22.0-1 did the job, whereas 22.0.-2 hangs
Hello Derek, I posted a detailed, accurate description of the problem I am experiencing with this solution. It was ‘waiting for moderation’ and now it’s gone. What was the problem, have I been violating any rules? Perhaps you can email me a comment or answer.
Regards
Jan
Hi Jan, apologies I’m not always around at this time of year to “battle the spam” so there may be delays. Unfortunately I don’t know the answer to your question either, but hopefully someone passing through will. Kind regards, Derek.
Thanks for this!
I actually followed Klaus’s suggestion of using gparted directly inside the virtual Ubuntu, which worked great! The only issue is that I had to replace the UUID for the swap disk on the /etc/fstab in order to use again the swap part.
Thanks again, best regards,
Rafa.
Thank you very much,Derek. This article is great!
unfortunately, this doesn’t work here. i have a 32 GB dynamic vdi with a ntfs partition. I successfully used vboxmanage to extend it to 65535 and then a Gparted VM (22.0-1) to assign the new space to the partition. Gparted now shows the partition as 63.22 GiB. The Virtualbox UI shows the .vdi as 64 GB virtual size and 31,52 GB actual size. If I mount the vdi on my fedora host using QEMU-ndb, df -k only shows the old size of 32733180 1k-blocks. If I start the .vdi with virtualbox as a VM (Windows 10 installed), Windows also only knows about a physical 33 GB disk. Any thoughts?
Hi,
I am trying to do the same. But I am having the following error while starting the GParted:
modprobe:”can’t module crc32c_intel (kernel/arch/x86/crypto/crc32c-intel.ko): No such device
modprobe:module dm-raid45 not founf in modules.dep
missing ‘workdir’ ”
It ignores these erros and carry on for language setting, but the it gets stuck.
Please help me. I am new to Virtualbox.
Thanks.
Could you please tell what to do
Another saying thanks – the only issue i had was with Vbox …. needed to dumb down the CPU settings ( dual 6 core Xeons ) but once that was done, the actual instructions were spot on.
The grow operation is taking a lot of time, it’s been more than 15 min, but no success message.
It has worked.. Thanks a ton.
thank you very much sir.
Thanks a lot Derek!
Extremely useful post!
Hi, I created a video tutorial that shows step by step how to successfully resize a Fixed .vdi drive. Here is a summary of each step I walk you through.
01 Introduction – Yes you can re-size a fixed VDI drive
02 Review 6 Steps to re-size successfully
03 Release and remove (don’t delete!) the Fixed VDI Drive you want to re-size.
04 Use command line CMD (run as administrator) Navigate to VboxManage Directory.
05 Clone the drive with VBoxManage clonehd.
06 Resize the VDI Drive with modifyhd.
07 Start Virtualbox, add new cloned VDI drive and extend partition.
08 If your OS does not have a Partition tool what can you do?
http://apptutor.com/courses/how-to-virtualbox-video-training-course/lectures/413795
Thanks,
Mike
Extremely Useful and perfect document.
Thanks alot.
going to bookmark this…forever
I randomly have 2MB left of unallocated space that I don’t know what to do with it
Thank you derek..
its a Wonderfull article..
Worked for me. Used the VBoxmanage command, then booted up Ubuntu 15 and used gparted to delete swap, delete ext partition, resize root and then recreate swap. Then used blkid on swap to get new UUID to update /etc/fstab. Reboot as safety precaution.
Cheers!
JoeK is right. If you don’t update the /etc/fstab with the new UUID, boot time will be very slow. See http://askubuntu.com/questions/612600/15-04-very-slow-boot/614660#614660
fixed the slow boot for me 😀
Thanks Derek, Worked like charm, thanks for this post.
Thanks a lot for this step by step and clear instructions .It helped me a lot .
Thank you sir. Worked exactly as advertized. Ultra clear instructions.
Well done, many thanks.
Worked without a hitch. Ubuntu-64 VM on windows 7. Wonderfully clear instructions. Thanks!
Excellent instructions! It worked flawlessly (VirtualBox 5.0.8 on Windows 7, running openSUSE Linux )
Thank you for so clearly documenting this delicate procedure.
Thanks. Some of the pictures and nomenclature have changed with VB 5 and I certainly couldn’t get it to work with gparted-live-0.24.0-2-i586.iso, only with gparted-live-0.22.0-1-i586.iso. But I got there in the end.
I wish all tutorials were as good as yours.
One extra thing. It took unnervingly longer to boot my existing Lubuntu guest the first time. Maybe I should have expected this but I did worry.
Thank you so much, worked great!
It’s Jan 1, 2016, and this still works like a charm. You made my day, and sort of New Year’s gift :). I followed the instructions using Linux Mint 17.2 (Rafaela) as the guest OS running on Windows 7 host. Many thanks dude!
Thank you for this amazing guide! Appreciate it!!
My host is windows 7 and running debian 32-bit in VB!
Wow a perfect guide, thanks a lot for your time
I followed all the steps but got a FATAL error saying that “could not read from the boot medium! System Halted.
Any suggestions ?
Just what I was looking for. Thanks!
Thanks a bunch Derek. Excellent post!!!
William
hi
could it work for .iso file also .i Have a ubuntu-15.10-desktop-amd64.iso file and i want to run in oracle vmware while installing it give not enough space as u said to increase the size for .vdi image is there any way to increase the size of .iso image
Thanks
Thank you so much, Derek, this “how-to” was fan-freaking-tastic, total lifesaver!!
Super instructions! I used gparted-live-0.25.0-3-amd64 on Ubuntu 14.04 LTS with VB5, and was having an issue getting the GUI to load. Enabling EFI in the VBM got it going, Thanks!
Great post! I would like to add one more thing.
To delete swap partition you need to first click “SwapOff” otherwise you cannot delete the swap partition.
Also, you may use http://www.slitaz.org/en/ instead of GParted ISO (if bandwidtth matters.. 🙂 )
Thanks for such a descriptive post.
Excellent post, thank you.
As @Allan mentioned, one may need to enable EFI (as I had). Some more details are at http://unix.stackexchange.com/a/208279/64753
I copied the swap partiction (copy/paste) at the end of the unallocated space but all in all it was more complicated: I needed, after rebooting Linux, to modify /etc/fstab with the new swap. best is to use “blkid” to find out the new UUID of the partition.
Thanks again!
please help… i am running ubuntu 14.04 host OS and i want to resize a Windows VM.
please how do i go about it?
Thank you soooo so much!!!
This is a great article, it’s scary to do this process without assurance that it will work.
The step-by-step images were very important to make the process easier!
I did not realize I had an LVM, so when I ran df -k in my machine and still saw the old values, I did the process all over again… and still the same thing.
For those who see something like “/dev/mapper/ubuntu–vg-root”, you are running an LVM and many comments here point to other articles explaining this part better.
I followed https://blog.vbonhomme.fr/extend-a-lvm-partition-after-increasing-its-virtual-disk-on-virtualbox/ and it worked great!
Thanks a lot 🙂
Thank you, Derek.
Brilliant-A clear, concise and helpful guide!
(The only difficulty I had was due to my not having enabled EFI in VirtualBox->System->Motherboard, which I found to be necessary in order to get GParted to run-up)
Thanks again
Great post. Saved my life. Thank you
Thanks a lot, it helped me so much to resize a disk used for an oracle VM !
Excellent Post.
Great tutorial, thanks, it helped a lot!
When I tried the instructions I got the blank screen like a few others. The solution was to enable EFI (Settings->System->Motherboard). I suggest to write it in the tutorial.
Very helpful tutorial – many thanks. If your Linux is using LVM, after you have done all the above you have to tell LVM to make use of the extra space. On Fedora 20, the instructions in the ticked answer in the following link did the job for nme.
http://serverfault.com/questions/424678/how-to-resize-root-lvm-partition-in-fedora-without-livecd-or-rebooting
Thank you very much ! You saved me a lot of time. It is very important to use older gparted-live-0.22.0-1-amd64.iso version. Do not use the last version.
Thanks for this post – it’s a life saver!
I tried expanding Ubuntu 14.04 on my Win 10 host. Firstly, VBoxManage didn’t work, so I followed this link to add it to path:
https://www.build-business-websites.co.uk/add-vboxmanage-to-path/
The summary of this one is to run the following commands as is as a quick fix (remember Win cmd needs the quotation marks):
cd “C:\Program Files\Oracle\VirtualBox”
set PATH=%PATH%;”C:\Program Files\Oracle\VirtualBox”
This let me expand my vdi in Win.
However, when I tried to run gparted, the GUI wouldn’t show up right after boot, when 0 is entered as the option to automatically start. If X-server doesn’t start, don’t worry. The manual way is preferable, since you know your laptop’s screen resolution.
So if gparted doesn’t show a screen like in Fig 3, just press 2 at the boot prompt to go to command line and type:
sudo Forcevideo
That would ask you for resolution (default is 2- 1024×768 but choose differently if your laptop has a different resolution).
Device driver name for the VGA is vesa (default option). Finally press y for yes (this explanation is given in the boot screen after you enter default choices and language). This should start the GUI.
All went through and my Ubuntu VM showed just 20 GB like it initially was. Special thanks to Declan’s comment, I realized that mine had many snapshots. So cloning only the current state and then expanding this vdi (without any extra snapshots) worked like a charm. Finally got rid of the original and using this one. Works great but there seems to be no workaround for a vdi with many snapshots except to clone it, expand that and move on!!
Thanks Derek!
A few notes from my experience:
1. My virtual machine referenced an existing disk that was of fixed size. I cloned this virtual machine to a dynamically-sized machine. Then I was able to resize this clone and deleted the original.
2. The newer versions of gparted did not work on my virtualbox. I used gparted-live-0.22.0-1-i586.iso and all worked fine.
Many thanks! Like others, I had to navigate to C:\Program Files\Oracle to find vboxmanage.exe first using CMD, and then point it at my VHD. Gparted worked like a dream with just the standard right click > Resize. VirtualBox still complained the VHD was inaccessible, but it booted fine and showed the extra space available!
Cheers sir!
Thank you very much for your detailed instructions sir.
I used the latest (14 aug 2016) gparted iso: gparted-live-0.26.1-5-i686.iso
In case the gparted machine produces an error on boot: increase the memory of it’s machine to 8gb.
Thanks for this detailed tutorial, it appeared I had to walk through exact the same steps as you described 🙂 Worked like a charm!
How to merge an primary partition with unallocated extended partition without data loss of primary partition ? In my case I want to extend /dev/sda1 which is ubuntu’s root primary partition. As being root partition it wont be possible to restore backed up partition on newly created free partition so I want to extend my /dev/sda1 without data loss
Worked great! Thanks
It helped me a lot. Thanks!!!
Nice post. Very thorough.
Thanks! worked like a charm 🙂
wow can’t believe this worked and i didn’t break anything
you are a saver !! Thanks 🙂
Thank you very much, really useful. It worked like magic!
Thanks very much. Worked perfectly, and I had almost given up on how to do this. I didn’t get the option to have the linux-swap as a logical partition (greyed out), so just created it as a physical partition, and watched nervously as the Ubuntu booted up… … … bingo! Thanks again for this.
total linux noob here.
Amazing tutorial, thanks so much!
Thanks a lot for this tutorial. I try to increase an encrypted Ubuntu partition but it seems that an encrypted partition cannot be resized.
I started GParted.
dev/sda1 is the partition of the Windows 7 host system.
dev/sda2 (File system extended) seems to be the Ubuntu partition. It has the following sub-partitions: 1. dev/sda5 with a red exclamation mark (Filesystem crypt-LUKS) with cannot be resized, only deleted or formatted. 2. unallocated (small).
Then there is the unallocated partition with the increased size.
Can you tell me how I can allocate the space to the encrypted partition?
Thanks a lot!
Thank you very much… that’s awesome 🙂
So cleanly described that there was absolutely no hitch or confusion or need to google again for anything else. Worked like a charm. Cant thank you enough
This is awesome. Helped me out of a spot!
Thanks!
Thanks a lot!!!! Very straight forward even though every other website and forum makes it seem a lot more complicated!
This just helped me tons, thank you!
Thank you so much. Easy to follow and worked first time.
Still works like a charm. Great tutorial. Thank you!
Thank you! Still helpful after all these years.
Thanks a lot!
Great article!
Thanks a lot!!
Great Tutorial!
Hi, thanks for posting this!
May I make one silly suggestion? You scared me with ‘Unfortunately that was the easy part!’ — I wasted some time googling to see if there was a simpler way. Then came back here and did it, and the rest of it wasn’t hard at all LOL
Thanks again!
Thang Zhou Vely Much Mister Sir Lord!
Helped a lot 🙂
Thank you for the tutorial.
The process worked for me with two minor differences.
1. In order to resize the .vdi file I had to enter the UUID value of the .vdi file. The web page http://amapplease.blogspot.com.au/2011/10/resizing-existing-hdd-image-in.html is where I found this information.
2. After resizing the .vdi file I had to create a new UUID value as the UUID of the .vdi file was not allowing me to attach to the GParted entry in the VirtualBox Manager, thinking there was UUID already present for the .vdi file. The web page http://www.bradleyschacht.com/virtualbox-cannot-register-the-hard-drive-because-a-hard-drive-with-uuid-already-exists/ was where I found this information. After doing these 2 tasks in Win10, the resize of the .vdi using GParted was OK and the resized disk is working.
On reflection, perhaps my step 2 may be able to be done before my step 1 and then the full path to the .vdi file to resize used in place of step 1.
Thanks again.
Thanks a lot Dr. Molloy. This truly is an amazing article that saves a lot of time when it comes to expanding a drive running out of space. Mistake I did was to create a virtual drive with 8 GB for Ubuntu 16.04 and I had only 200 MB for other installations with a default linux-swap space of 2 GB.
Perfect! Good simple instrctions, thank you so much! 🙂
Boss!! you rock….thanks ..
this wil come handy for some too http://askubuntu.com/questions/539924/why-cant-i-resize-a-dynamic-vdi-with-modifyhd-command
Awesome job man ! Really really helpful.
I do have a small issue, after I followed the instruction, the size is increased and working fine. But the VM load-time is almost double. It used to start really quickly, but it’s taking alot of time now. Can you please help me out here.
Thank you !
This article is great! If you delete the swap space, if it occurs between the primary partition and the added partition, and then add it back at the end, you will see an increase in boot time, or you will have to use recovery mode to boot. That is because the UUID of the swap space has changed. You can find the new UUID number of the new swap space by getting its properties when you are in GParted. Then you can recover your short boot time by changing to the new UUID number of the new swap space in /etc/fstab, after you finally boot up again. This link explains how to edit fstab:
http://askubuntu.com/questions/711016/slow-boot-a-start-job-is-running-for-dev-disk-by
The terminal command that was used to edit fstab is:
sudo -H gedit /etc/fstab
If you don’t have gedit, you can install it, or use some other text editor that you have available.
I was thinking that is a pitty because does not function for me. I have followed all the instructions. And all is right, but when I check the file system with df -k appears the old storage size.
I have read all the comments. Some of them refer to problems if you have a LVM. I do not have a LVM. Other problems about new version of gparted. I have downloaded an old version and the problem persist. Gparted says is done. Oracle VM says that the size is right but inside the system only appears the old size.
But the last attempt it works. I clone my current vdi from the VM administrator and then start gparted over the new clone vdi. and surprise. The storage was the old. After resize the sda1 and create the new swap ( the same steps that before) start the new clone and the size now is the resized size.
Great article and great comments!!!
Much obliged!
Sorrry, but this did not work for me. Although I followed off of the steps and the partition table looks just like I want it after I received it and added the swap space back, when I boot into Ubuntu that OS does not recognize that the disk has been resized.
I checked the time stamp on the file before and after and the timestamp does not change. The last time I used the disk before trying to resize it was about 11:15 AM and after I resize it and create the new partition table, it still has the same timestamp as if the changes are not actually written to the file
Alternative Method to Gparted: Log into the VDI and when windows starts up login. Go to My Computer and Manage. Locate your disk and select extend disk. your Done 🙂
Thank you so much working fine with me.
Only one word, Awesome…
Thankyou, Your instructions are by far the clearest and most direct spend half a day looking for a solution to my problem and you hit it nail on!
Great Article! Nice feature of Gparted Live boot and all.. Sad that on local Linux system i could not get the VDI mounted and resized 🙁
Thanks ! Worked like a charm. You saved my day!
Great article, thanks!
Great article! Thanks for the info.
Thank you so much!
Gparted accepts resizing the root partition in many situations (tested with Ubuntu 16.04) – no need for the 2nd part.
Very helpful article. I used this article as a reference to expand the disk size for a Ubuntu VM. Please also mention that we need to “de-activate” the partition before resizing it. Else the resize option does not seem to work.
Very clear instructions. Thanks man !
Thank you! An actual writing. Helped me a lot.
Worked fine but with later versions of Linux and Gparted was able to turn swap off the partition when running the live version, then delete it build new partitions add the partition to the disc and then create a swap disc. all worked fine.. i just rebooted and all was well.. Thanks for the assistance..
Worked fine.
Just two additions.
1. If you have a ‘fixed’ VDI to start with, you have to clone it to make a ‘dynamic’ VDI
The following error is the indicator (the error might pop up due to other reasons as well)
>>>
0%…
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage.exe: error: Resize medium operation for this format is not implemented yet!
<<<
2. GParted steps can also work inside your guest OS (I tried it in Ubuntu guest). Need not download the GParted ISO and create a new VM.
Great article, very clear and well written. Thank you so much, this helped me a lot!
Hello:
If you have problems resizing your partition with GParted:
– https://superuser.com/questions/917988/gparted-cannot-resize-extended-or-lvm-partition
Fantastic!! Thanks for the fantastically written tutorial. Considering a lot could’ve gone wrong, it went super smoothly. Thanks.
It seems “modifyhd” has been superseded by “modifymedium” in the late version of VirtualBox (5.1).
Excellent Job!
This tutorial really saves me.
Derek, Really appreciate your effort.
Thanks
Thanks for the detailed write-up. Still relevant and helpful after all these years.
This is going to my bookmarks bar for sure.. Thanks a lot man!
Thank you so much.
Thanks a lot. This worked for me only that I had to repeat the GParted process in my original Virtual Machine to make it work.
It works. Thanks a lot!
Excellent write-up! 10 minutes all it took to increase my Oracle virtual space. Thank you thank you thank you!
I followed this step by step process and got the result. Thanks a lot!!
@derekmolloy thanks. @kb thanks for the on updating /etc/fstab with the new UUID to fix the slow boot:
http://askubuntu.com/questions/612600/15-04-very-slow-boot/614660#614660
After that my Ubuntu Software Updater failed because GRUB UUID was different that the boot.
Updating from the command line worked and gave the option to fix the GRUB UUID. See
https://askubuntu.com/questions/196768/how-to-install-updates-via-command-line#196777
Thankyou so much ! Helped me a lot , i had the same settings as shown in the screen shots ..perfect writeup
Thank You 🙂
What if the .vdi file contains an image of a Linux installer under a Linux host? Can I proceed with resizing the .vdi filesize on the Windows CMD?
Hi Dr. Molley,
That is wonderful solution that you have posted that help me for Guest Linux OS.
However, I would appreciate if you could throw some light on the following:
1. My Host is a Windows 10 Pro ( on a laptop with 16 G RAM & 1 TB HDD)
2. I had created a Virtual Box with Windows 2003 Server (32 Bit) to run Interbase 5.6 database and check on very old datafiles.
This Vbox I had created with HDD space of 20GB. While extracting the data from interbase where some tables have more than 4 million records, I am running out of hdd space in the Vbox. How to do I resize this for Window Guest OS?
You reply is much appreciated. Thanks in advance.
Regards
Ramana
Great tutorial, I had almost exactly the same setup. I thought the swap having a different partition (/dev/sda5 instead of /dev/sda2) would wreak havok, but the VM was able to use /dev/sda5 as the swap partition without any modification on my part.
Thanks, this worked great.
Thanks a tonne! It helped a lot…
You saved me hours.
Thank you.
You saved my day! A lot of thanks!
Great job, btw remember to deactivate primary partition
Really really good instructions, you saved a lot thanks!
Awesome, you saved my day! this is most common problem in test environment on any day and now I know what needs to be done. Thank you.
F:\Virtuals\Ubuntu LFD>VBoxmanage modifyhd Ubuntu LFD.vdi –resize 25000
‘VBoxmanage’ is not recognized as an internal or external command,
operable program or batch file.
Well done.
thanks,
you can easily resize disk on windows after resize vdi file, by disk management -> extend volume.
Perfect! Someone buy this man a pint of the black stoof!
Almost got me there but on Oracle 64 bit linux I had to finish up with these two commands
sudo lvextend -l +4857 /dev/ol/root
sudo xfs_growfs /dev/ol/root
Hi Derek, Thank you for the great job.
Worked like a charm! Great job documenting this.
Thaks you ! You very hleped me.
Thank you for this tutorial. It was very helpful for me after I created a very useful virtual machine with just too little space.
Great tutorial, thank you!
Very Good. Tks!
Thanks a lot for this guide.
Very useful and clearly explained, step by step. I wasn’t able to launch the GParted virtual machine with the latest version (0.30; some kind of problem with the kernel), but the older ones worked fine. I tried first with 0.21 and it stated ok, but it failed to resize sda/dev1 and asked for a newer e2fsck version. GParted 0.26.1-5 has an updated e2fsck and worked fine!
Thanks a lot
Great walk through! Thank you so much for taking the time to write this up. I’m sure it’s helped a lot of people like me.
You saved my day, thank you! I read a lot of articles but yours was the only one to solve my problem.
Thanks so much for the great illustration and detailed step-by-step procedure! I would also like to let you know that you might supplement your note with one extra step, to manually revise the /etc/fstab file the UUID of the swap partition, otherwise, the resized guest will boot very slowly. This has been torturing me till I ran across the thread https://askubuntu.com/questions/639559/very-slow-boot-with-ubuntu-15-04
thanks for this detailed guide, but it didn’t worked because of snapshots: https://dirkstrauss.com/resizing-virtualbox-disks/
and it is not necessary to create a 2nd VM, you could just mount the gparted live iso into cdrom of first VM and boot from it.
Your solution just saved a lot of my time.
Thank you so much for the great article with clear instructions!
All the best,
Recep
Great tutorial, thanks for sharing!
Thanks a bunch sir! Why does using optical drive (with gparted ISO in it) NOT work in existing VM (having SATA HD to be resized)?
This is a great step-by-step guid. Worked perfect for me. Many thanks.
Thanks…amazing
Thank you so much for this Derek! Worked a treat on my Arch Linux host.
I was quite pleased to find this article. I read through it twice and then decided to take a different approach to solve my space issues. I went into Settings -> Storage and added another fixed VDI file as a second hard disk. Then I booted up the OS image, started up gparted and prepped the disk for use. It’s not as involved as resizing, but if you just need some additional storage space, then this might be another option to consider.
You are the Man. Thanks.
In the same VBox, attach original ubuntu iso and re-start.
On the first screen, press F12 to open boot menu and choose boot from CD.
After it boot, choose Try Unbuntu,
search GParted to run it.
You can resize the VDI space there.
After you done, shut down.
Thanks, a great guide. I just failed to resixe the vdi since it was fixed in size. Got the error message “medium operation for this format is not implemented yet”, and had to resort to the “CloneVDI Tool ” for resizing, after that I could continue with the gparted-live-step.
Very well explained..Thanks
I managed to resize my partition so thanks very much for this. Of course I managed to use GParted to wreck the drive the first time so making a backup copy is a step not to be skipped.
Excellent instructions! It took me several tries until I figured out to use the vdi file at the path it shows when you hover over the vdi in the details screen, which in my case was a snapshot one. Changing the “base” one did nothing.
Thank you!
Appreciate your help–very well done!
Thank you that was very helpful.
Excellent Work Derek !!! Thanks for posting Very Good article.
Thank you!
Hi,
Am stuck at Step 3, 5th pointer trying to add the vdi file to controller. When i click on choose a disk, it doesn’t recognize the vdi file on my machine. I also took a back up of the file in a different location, even that is not recognizable. Any help is appreciated. TIA.
Muchas gracias por el aporte. Funcionó a la perfección.
Very useful, thanks!
Just adding to the many thank-you responses you’ve already received on this article. Everything worked exactly as you described. It’s one of the best presentations for a fairly complicated process i’ve ever seen. Thanks!
Thank you so much. With all these positive comments I felt confident that this was a good plan. And it didn’t disappoint! For once I didn’t have to ask for help from others at work.
It worked! Thank you so much! You are the best.
Thanks for this great article, Derek. I just finished a straightforward resizing of my main partition (/dev/sda2), simply adding all the unallocated space to it. df -h reported the same size as when I started. Is there something else that must be done to update df results?
Thanks again.
Steve
This does not seem to work well if your copy of Windows 10 running as the guest OS is registered and legal. It breaks the registration and renders windows inactive. There seems to be no easy way out of such mess either since your snapshots are also rendered useless. Please correct me if I’m wrong. At least for me – the above was my experience.
for windows you do not need to go through the process. open disk management and extend your desire partition
Thank you Derek really helped me today with a Windows 2016 Server VM (I fell into that trap of accepting the VirtualBox default disk size).
And as an added bonus came across your book recomendations an awesome find especially the BeagleBone and electronics books thank you for this!
Superb!! you are the boss of all bosses!!!!!
Outstanding walk through… worked seamlessly without an issue… Thank you for writing up the process…
Great write-up!
Thanks for the tutorial! It saved me alot of time! 😀
Really great stuff Derek. I was about to jump out the nearest window in frustration until I read this!! Thanks so much 🙂
Really great stuff Derek. I was about to jump out the nearest window in frustration until I read this!! Thanks so much 🙂
Thank you very much for your help! It worked perfectly. I would just add that you may want to write down the size of swap partition, so you don’t add more than necessary space.
This works like a charm. I have had to periodically increase the size of my VirtualBox guest OS and every time I come back to this page and go through the steps you have outlined. The one additional step that I’ve had to do, is update /etc/fstab with the UUID of the swap.
Thanks a ton!
Found this straight away just when I needed it, lucky me. Thank you for taking the trouble to document this properly 😉
i am new to Linux Environment , this saved a lot of time. thanks 🙂
One final step on my Centos7 VM:
# vgdisplay centos (Verify if you can see your new available space as “Free PE/Size”)
If so, extend it like this:
lvextend -L +99G /dev/mapper/centos-root (replace 99 with your number)
xfs_growfs /dev/mapper/centos-root
Reference: https://www.linuxtechi.com/extend-volume-group-size/
Very Useful. Thanks
The method works for my case. Oracle VirtualBox 5.2.12. Virtual OS : Ubuntu 14.04. Enlarge Ubuntu (virtual) hard disk from 20 GB to 30 GB. Host PC : Windows 7. Thanks for sharing the posting.
Awesome!! Thanks so much man I love you!
You can now trivially resize a VDI in the VirtualBox UI:
> Global Tools
> Virtual Media Manager
> Select the VDI you want to resize, type in a new size at the bottom, and click “Apply”
I’m not sure when this functionality was added (I’m using version 5.2.18), but seeing as this page is still the top Google result for “virtualbox increase disk size” I figured that posting it here might save some people some time.
Hmmm, seems that doesn’t actually work…the VDI resizes but the Linux install doesn’t actually recognize the increase in size.
Thanks alots!! This helped me alot but still Gparted could also be the easy too. I opened Ubuntu in VM box after resizing it. I installed Gpart from Ubuntu Software and just expanded the space there
thank you very much, very clear instruction. Worked for me.
Thanks for the post, that worked well. Maybe remove the direct link to the gparted ISO file – I used the linked version and came across a problem when resizing the disk (some e2fsck feature unsupported by the linked gparted version). You explicitly mention to get the latest version but that wasn’t sufficient to overcome my lazyness.
Thank you Derek, it worked! (I had .vhd but it’s the same)
Thanks much as these instructions were VERY helpful. But I found that now in 2018 I could simplify two of the process. I have Windows 10 with VirtualBox 5.2.18 installed and ran out of space updating my Ubuntu 16.x VM to 18.x.
First, the command line to resize didn’t work for me. Instead I opened VirtualBox Manager, clicked on Global Tools in the upper right, selected my .vdi disk, then used the slider to resize (or enter the new size in the text box) and then clicked Apply.
Second, I found an easier way instead of downloading a gparted iso and creating a new GParted vm. I just started my Ubuntu VM, opened a New Terminal, ran “sudo apt install gparted”, installed it, ran “sudo gparted” and then followed the rest of your detailed instructions.
Thank you very much for this post!
Vbox can now grow the disk in the manager, but you still need gparted to seal the deal.
Thanks again!
This is an awesome page. Well written. It worked like a charm.
Thanks a lot! Keep writing such informative pages.
Really informative. Thanks a lot. I was having trouble trying to resize.
For those using .vmdk disks (and get the error “Resize hard disk operation for this format is not implemented yet!”), this post helped me: https://stackoverflow.com/questions/11659005/how-to-resize-a-virtualbox-vmdk-file
Summary:
VBoxManage clonehd “source.vmdk” “cloned.vdi” –format vdi
VBoxManage modifyhd “cloned.vdi” –resize 51200
VBoxManage clonehd “cloned.vdi” “resized.vmdk” –format vmdk
This was a lifesaver and worked perfectly. Thank you so much!
You saved me !
Thanks a lot, it was very helpful.
This is a great advice. Thanks man.
U r Awesome man… Worked like a charm….. Superb documentation….
. I went into Settings -> Storage and added another fixed VDI file as a second hard disk. Then I booted up the OS image, started up gparted and prepped the disk for use, but unable to solve.
Great article! Thanks 🙂
For someone have snapshot, try to enlarge all the snapshot disks, follow https://www.kunxi.org/blog/2014/06/resize-disk-in-virtualbox-with-snapshots, it works for me.
I think that one of the biggest things you have to include is ergonomics and efficiency. One often feeds into the other when it comes to office comforts, i have found. Thanks for these tips. I really liked the tip about positioning desks in front of windows.
Computer Support Dallas
My only detrimental comment: GParted brings up a display that is the size of a postage stamp, and even after resizing to 1024 x 768, the display is still so small that I struggled to make it work.
But as others have pointed out – it did work perfectly.
One other note: the version of VBoxmanage that I have uses “modifymedium disk” instead of “modifyhd” but that was easy enough to arbitrate
Just performed this in Virtualbox 6 and it worked like a charm. A few of the Gparted and Vbox menus have changed a bit over the years but it’s easy enough to figure out. Thanks for the tutorial.
I attempted this tutorial using Oracle VirtualBox 5.2.18 with an Ubuntu 16.04 Virtual Box on a Windows 10 host operating system, extending the storage capacity from 10 GB to 60 GB.
Before the tutorial
Actual Size: 9.70 GB
Virtual Size: 59.57 GB
After the tutorial
Actual Size: 9.70 GB
Virtual Size: 59.57 GB
No changes occurred and the disk is still full. This is both keeping the disk in the virtualbox, and removing the disk from the virtualbox before the procedure and then adding it back to the virtualbox after the procedure.
GParted indicated that the extended and linux-swap partitions were similar sizes, 1024 MiB and 1023 MiB and it indicated all changes were successfully applied, though nothing appeared to happen. There was no unallocated partition left, though at each step my screen appeared the same as the images in the tutorial. What could be missing here?
Still works for me. Host OS: Windows 10, Guest: Ubuntu 16.04, VirtualBox Version 5.2.18 r124319 (Qt5.6.2).
Perfect manual!
Hi Derek, Thanks a lot for simple and working tutorial 🙂
You just saved me at least 3 days of work!!! Thank you Derek!
Even 6 years later this was the only guide I could find on the subject and it worked flawlessly 😉 Many thanks <3
thank you. It all worked until the last step. Could not increase sda1 or fix disk from within gparted.
error: sda1 contains errors. Fix disk. Try updated e2fsck. Disk in use. any clue?
Helped a lot! Thank you XD
Thanks 😀
Idolo!
Thanks a lot!
This was great article and very helpful – i also find easier and more secure way for expanding unallocated part of partition.
After this part: VBoxmanager modifyhd xxxx.vdi –resize 100000
just boot again VM and go to tools and find “disk” tool under
you will see graphically that additional space is available but you need to do one more thing.
Click on settings button “additional partition options” and go to “resize” > than use your mouse to pull line to the end of the disk and that is it! 🙂
hope this helps to speed this process a lot
Great article! Thank you!
Many thanks! You save me.
Thank you so much! Worked like a charm 🙂
Thanks a lot. Just works
thank u
thanks it worked. the solution is well explained!
Hi Derek!
I have a super important deadline tonight and this article really saved my life. It is super easy to follow even for beginners like me. Thanks a lot!
I just had it stuck at the next screen when it should show the login prompt – it just showed a solid wine coloured screen (with a subtle Ubuntu at the bottom).
I was using a virtual machine (VirtualBox) and the fix was to change the Display setting from VMSVGA to VBoxSVGA. Phew!
Worked perfectly for me. Thank you!
Never got to Figure 3; the machine just boots. There’s no option to “Choose Gparted Live (Default settings)”. Grr…
It finally worked. I had to go through setting up the GParted VM over and over. The original disk was almost full, which might explain this. Thanks!
Very cool! Working!
Still helpful!!!
If you have a vmdk Image file instead of vdi you have to clone image to right format first.
VBoxManage clonemedium "source.vmdk" "cloned.vdi" --format vdi
VBoxManage modifymedium "cloned.vdi" --resize 51200
VBoxManage clonemedium "cloned.vdi" "resized.vmdk" --format vmdk
Taken from here: https://stackoverflow.com/questions/11659005/how-to-resize-a-virtualbox-vmdk-file
Hi.
Thank you. But for Ubuntu You can do from live cd https://technology.amis.nl/2017/01/30/ubuntu-vm-virtualbox-increase-size-disk-make-smaller-exports-distribution/#prettyPhoto
Years later and still the best guide on the web. Kudos!
Booyah… you Rock Dude… thank you so much…
Thanks for your good article and working fine in Oracle VM disk.
Great guide, thanks so much for posting! 2 Feedback points:
* your suggested procedure ends up generating different UUIDs for /dev/sda2 and /dev/sda5. This means that an invalid UUID will still be referenced from /etc/fstab. I had to manually edit fstab to fix this (else, booting would always take an additional 90s trying to connect to the invalid UUID)
* this doesn’t work if you have snapshots of your VM. Easiest is to delete the snapshot (merge its state diff back into the main vdi) before starting your guide. It’s probably possible to manage without deleting it, either by only resizing the snapshot, or resizing both snapshot and original vdi? Might be worth giving that a shot and adding it to the article.
Thanks again, great read!
Thanks! Went flawlessly
Thanks a lot. Correct and concise
For those who are looking at this article in 2019, about the optionnal step 1, virtual box has implemented a function that automatically move your VM to another path :
With your VM selected press alt-M alt-M and select the new path.
gZen0n
Well, we are now in 2020 x)
Well, after looking at the entire article, this no longer accurate with new version of Virtual box.
This just worked, and this is 6 1/2 years after the instructions were published. Absolutely amazing!
I realize this is an older article, but I *think* you may have forgot one step at the end.
I found that on Ubuntu, after booting up my machine, the output of swapon was empty. https://askubuntu.com/questions/1205856/swapon-show-is-empty
I had to edit /etc/fstab to point to the new partition.
Thanks a lot
Thanks so much!
Thank you so much. Worked like a charm!
Little note for Step 2:
You need to either add C:\Program Files\Oracle\VirtualBox to your PATH variable or execute command with full path to VBoxmanage, e. g. “C:\Program Files\Oracle\VirtualBox\VBoxmanage” modifyhd Debian.vdi –resize 20000
Very well explained, thank you. Please don’t remove these instructions – they’re still in use!
Thank you so much, you saved me !!
Thank you so much! Everything works for me perfectly. The instructions were clear and complete! Images were really helpful
Recommend adding, after:
After applying the changes choose the /dev/sda1 partition and choose resize as in Figure 6, allowing enough space (“free space following” of 1023) for a new swap partition. It should say “Grow /dev/sda1 from 18.53GiB to 96.66GiB”
the sentence
Hit the check icon for apply (near the top)
…because I had to figure why it wasn’t applying it till I did! 🙂
Thanks for doing this!
Never mind, please retract comment.
“select the linux-swap and press “Delete”
Very confusing! This term wasn’t used in the text up to this point. It also doesn’t appear in any of the GUIs. It’s risky to guess what it’s referring to because deleting is permanent.
Thank you. very usefull to rapidly enlarge the linux partition of virtualbox lubuntu system
This is a very nice guide and it does help me a lots.
Thank you very much!
Thanks .It worked like a charm !!
Cheers
Thanks a Lot, it works
To finish the job one needs to put in the /etc/fstab the new UUID of the swap partition (obtained when the swap was recreated) to avoid 90 seconds wait during the boot with the message “A start job is running for /dev/disk…”.
See https://blog.paranoidpenguin.net/2020/01/a-start-job-is-running-for-dev-disk-by-uuid/ for details.
Also I wonder why this would not work directly from the guest system after the install of gparted ?
Thank you for this article. I have been searching for this solution for about four weeks and this is the first one that has succeeded, even If I had to modify a few steps.
The first change was that I could do the first step using VMWare manager.
The second step did not work completely, but after reading some of the comments, I saw that I could use GParted, directly in the VM. and this has solved my problem.
Thank you. Even after 7 years it is still valid.
Thank you for making the world a saner place 🙂