I'm using VirtualBox 6.1.40 r154048 on Windows 10.
I have a VM running TrueNAS Core which I use to test things for my home NAS. I've created multiple small VDI images of various nominal sizes, all as dynamically allocated files. After writing data in TrueNAS, the .vdi file sizes are obviously changed proportionately. Since there's no data in the drives that I need to keep, I want to recover the physical disk space by reducing the virtual disk files back to their original, newly-created file size (e.g. 2MB instead of 500).
In the past I've deleted and recreated the drives, but I'm hoping there's a quicker way to do it. I've tried making copies of the files after creation and then overwriting the changed versions, but VBox won't allow that. Is there a way to do this, or am I going to have to create new drives each time?
Thanks in advance.
Is it possible to reset a .vdi drive?
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Is it possible to reset a .vdi drive?
If you're looking for a one-for-one replacement, as in a new "A.vdi" for a used "A.vdi" then Virtualbox will allow this. You only have to make sure the VM is completely shut down, and you can't use snapshots.
Make a new A.vdi in its 2MB size. When you have the .vdi set up the way the way you want it to be upon reset, shut down the VM, then make a backup copy of A.vdi, either as "A-copy.vdi" or some such in the original folder, or move the copy of A.vdi to a different folder.
After A.vdi has been used and you're ready to reset it, shut down the VM and copy the backed-up A.vdi back over the original. Make sure the restored copy has the same original name.
Make a new A.vdi in its 2MB size. When you have the .vdi set up the way the way you want it to be upon reset, shut down the VM, then make a backup copy of A.vdi, either as "A-copy.vdi" or some such in the original folder, or move the copy of A.vdi to a different folder.
After A.vdi has been used and you're ready to reset it, shut down the VM and copy the backed-up A.vdi back over the original. Make sure the restored copy has the same original name.