How do you reduce the allocated storage size of a virtual machine?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
How do you reduce the allocated storage size of a virtual machine?
Hi all.
Does anyone know how to reduce the allocated storage size of a virtual machine? I think I overestimated the number of gigabytes I needed to allocate. Is there a way to take back unused storage space allocated to a virtual machine after the virtual machine has already been created without deleting the entire virtual machine and starting over?
The distro of Linux Mint that I'm using is Linux 18.3 Sylvia and the desktop environment is Cinnamon 3.6.6 and I'm running VirtualBox Graphical User Interface Version 5.1.32 r120294 (Qt5.5.1) by Oracle.
Thank you.
Does anyone know how to reduce the allocated storage size of a virtual machine? I think I overestimated the number of gigabytes I needed to allocate. Is there a way to take back unused storage space allocated to a virtual machine after the virtual machine has already been created without deleting the entire virtual machine and starting over?
The distro of Linux Mint that I'm using is Linux 18.3 Sylvia and the desktop environment is Cinnamon 3.6.6 and I'm running VirtualBox Graphical User Interface Version 5.1.32 r120294 (Qt5.5.1) by Oracle.
Thank you.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How do you reduce the allocated storage size of a virtual machine?
Reducing the size of a virtual hard drive is not possible.
- absque fenestris
- Level 12
- Posts: 4124
- Joined: Sat Nov 12, 2016 8:42 pm
- Location: Confoederatio Helvetica
Re: How do you reduce the allocated storage size of a virtual machine?
Pure curiosity: How many gigabytes have you assigned to Mint? By the way, you can dynamically or permanently allocate space.Does anyone know how to reduce the allocated storage size of a virtual machine?
Re: How do you reduce the allocated storage size of a virtual machine?
I'm not sure how to check how many gigabytes I have assigned to Mint, but my SSD is 500.1 gigabytes in total. I allocated 75 gigabytes across two virtual machines (way more than I needed apparently) and across both of them I've used 34 gigabytes. I have the virtual machines for running programs that don't work with Wine (which has been unreliable for me so far). Right now it says that I have 399.7 gigabytes free on my SSD.absque fenestris wrote: ⤴Fri Feb 16, 2018 7:19 pmPure curiosity: How many gigabytes have you assigned to Mint? By the way, you can dynamically or permanently allocate space.Does anyone know how to reduce the allocated storage size of a virtual machine?
So I want to say I have about 425 gigabytes assigned to Mint, but I don't know. Maybe there's a way to check using the terminal?
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
That's not correct. VBoxManage will do it, provided that the virtual disk is a .vdi, but it's not recommended for newcomers.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
Unfortunately that doesn't answer the most pressing question, which is, How much space are the two VMs using together on your linux host? Alternsatively, how big are the disk files themselves?mintyfreshuser wrote: ⤴Fri Feb 16, 2018 7:36 pm I'm not sure how to check how many gigabytes I have assigned to Mint, but my SSD is 500.1 gigabytes in total. I allocated 75 gigabytes across two virtual machines (way more than I needed apparently) and across both of them I've used 34 gigabytes. I have the virtual machines for running programs that don't work with Wine (which has been unreliable for me so far). Right now it says that I have 399.7 gigabytes free on my SSD.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: How do you reduce the allocated storage size of a virtual machine?
One VM disk file is 50 gibabytes big and the other one is 25 gigabytes big. I have 34 gigabytes of installed files across the two VMs.catweazel wrote: ⤴Fri Feb 16, 2018 7:50 pmUnfortunately that doesn't answer the most pressing question, which is, How much space are the two VMs using together on your linux host? Alternsatively, how big are the disk files themselves?mintyfreshuser wrote: ⤴Fri Feb 16, 2018 7:36 pm I'm not sure how to check how many gigabytes I have assigned to Mint, but my SSD is 500.1 gigabytes in total. I allocated 75 gigabytes across two virtual machines (way more than I needed apparently) and across both of them I've used 34 gigabytes. I have the virtual machines for running programs that don't work with Wine (which has been unreliable for me so far). Right now it says that I have 399.7 gigabytes free on my SSD.
- absque fenestris
- Level 12
- Posts: 4124
- Joined: Sat Nov 12, 2016 8:42 pm
- Location: Confoederatio Helvetica
Re: How do you reduce the allocated storage size of a virtual machine?
Funny: Which system do you use?
Me on Mac: Virtualbox asks me how big the virtual disk should be. I say 15 GB. Virtualbox asks me dynamically growing or fixed size? I have to decide that. Then the virtual hard disk is created... but I know exactly how big I have chosen the hard disk.
Me on Mac: Virtualbox asks me how big the virtual disk should be. I say 15 GB. Virtualbox asks me dynamically growing or fixed size? I have to decide that. Then the virtual hard disk is created... but I know exactly how big I have chosen the hard disk.
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
WARNINGmintyfreshuser wrote: ⤴Fri Feb 16, 2018 8:28 pm One VM disk file is 50 gibabytes big and the other one is 25 gigabytes big. I have 34 gigabytes of installed files across the two VMs.
The link below contains dangerous commands. If you don't understand the article, don't do it.
The fix requires your VM files to be .vdi
Next time you might consider setting the VM disks up as dynamically allocated.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: How do you reduce the allocated storage size of a virtual machine?
I have two virtual machines installed right now. The first one is Windows 10 (64-bit) which I allocated 50 gigabytes to. The other virtual machine is Windows XP Professional (32-bit) which I allocated 25 gigabytes to.absque fenestris wrote: ⤴Fri Feb 16, 2018 8:29 pm Funny: Which system do you use?
Me on Mac: Virtualbox asks me how big the virtual disk should be. I say 15 GB. Virtualbox asks me dynamically growing or fixed size? I have to decide that. Then the virtual hard disk is created... but I know exactly how big I have chosen the hard disk.
Both of them are set to grow dynamically.
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
Odd. That doesn't seem correct based on your description above.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: How do you reduce the allocated storage size of a virtual machine?
...the solution linked to / proposed above by catweasel will work just fine.
If you want a slightly more user friendly way (ie. without using vboxmanage), then:
1) Download sdelete onto your vm (32-bit or 64-bit, depending on what your vm is), and run sdelete -z C:.
Shutdown the vm afterwards (well, obviously...)
2) Get CompactVD from here, and select the vm image in question. Point & click really, not much more to explain there...
If you want a slightly more user friendly way (ie. without using vboxmanage), then:
1) Download sdelete onto your vm (32-bit or 64-bit, depending on what your vm is), and run sdelete -z C:.
Shutdown the vm afterwards (well, obviously...)
2) Get CompactVD from here, and select the vm image in question. Point & click really, not much more to explain there...
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: How do you reduce the allocated storage size of a virtual machine?
Enlighten us, how you do something, where the Oracle documentation says in chapter 8.23, that this is not possible:
This currently works only for VDI and VHD formats, and only for the dynamically allocated variants, and can only be used to expand (not shrink) the capacity.
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: How do you reduce the allocated storage size of a virtual machine?
I already provided the link and listed some of the limitations.
Edit: The quote refers to a feature of the VBox manager, which cannot be used to reduce the size of a disk. It does not say that disk cannot be so reduced.
Last edited by catweazel on Sat Feb 17, 2018 11:28 pm, edited 1 time in total.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: How do you reduce the allocated storage size of a virtual machine?
My notes from when I had to do it because my original was too small (mint 18.3 host, win7 guest):
Resizing a Virtual Disk
Resizing the virtual disk. Searched on-line and tried messing around in terminal, managed to screw it up so that VB wouldn’t boot windows and had to do a complete restore of Mint to get back to a working windows system. To resize the disk:
(a) In VB manager right click on the guest OS (Windows), from the menu select clone.
(b) Accept the defaults, give the clone a name like Windows7xx without spaces (easier for what you do in terminal below and you can change it later). VB will generate a clone which will then appear in the VB window. This takes some time.
(c) Shut down VB.
(d) Open a terminal and navigate to the new folder containing the VDI, e.g.
/home/andy/VirtualBox VMs/Windows71
(e) In the terminal enter, as an example:
VBoxManagemodifyhd Windows71.vdi --resize 30000
This will resize the image from whatever to 30GB.
(f) Re-start VB and run the guest OS, e.g. Windows 7.1. Goto control panel/admin computer management/storage/disk management and increase the size of C: to use the extra space. Unless this is done, windows will not see and use the additional space created. Note – while it may seem that you cannot change the size basically accept defaults and win will extend drive C:.
(g) Assume that the original guest OS image can now be deleted. Do this from VB manager (again right clicking on the guest OS that you want removed).
Resizing a Virtual Disk
Resizing the virtual disk. Searched on-line and tried messing around in terminal, managed to screw it up so that VB wouldn’t boot windows and had to do a complete restore of Mint to get back to a working windows system. To resize the disk:
(a) In VB manager right click on the guest OS (Windows), from the menu select clone.
(b) Accept the defaults, give the clone a name like Windows7xx without spaces (easier for what you do in terminal below and you can change it later). VB will generate a clone which will then appear in the VB window. This takes some time.
(c) Shut down VB.
(d) Open a terminal and navigate to the new folder containing the VDI, e.g.
/home/andy/VirtualBox VMs/Windows71
(e) In the terminal enter, as an example:
VBoxManagemodifyhd Windows71.vdi --resize 30000
This will resize the image from whatever to 30GB.
(f) Re-start VB and run the guest OS, e.g. Windows 7.1. Goto control panel/admin computer management/storage/disk management and increase the size of C: to use the extra space. Unless this is done, windows will not see and use the additional space created. Note – while it may seem that you cannot change the size basically accept defaults and win will extend drive C:.
(g) Assume that the original guest OS image can now be deleted. Do this from VB manager (again right clicking on the guest OS that you want removed).
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0