Link to home
Start Free TrialLog in
Avatar of faithless1
faithless1

asked on

Delete .VDI file, Free up hard drive

Hi,

I have two .VDI files, one of which I'm no longer using. How do I safely remove the one I'm no longer using to free up disk space on my laptop? I run Ubuntu on VB and can access windows files.

Would this command work to safely remove the partition that was created via Virtual Box for ubuntu?

rm -rf BMG.vdi

Avatar of torimar
torimar
Flag of Germany image

A .vdi file must be deleted on the host system, not inside the guest.
If Windows is your host where you run VB, and Ubuntu is run inside that VB, then you have to delete the .vdi file in Windows. In Ubuntu, by the way, you wouldn't even be able to see it.

If you want to make sure that nothing is affected by deleting the .vdi file, rename it first, start VB and Ubuntu for a test, if everything still works fine, close VB and remove/delete the .vdi file.

I already gave you this solution in your other thread: https://www.experts-exchange.com/questions/26811233/Ubuntu-Virtual-Box.html?cid=1135&anchorAnswerId=34859212#a34859212

The fact that you ask the same question again is the best proof for the fact that in the other thread you chose the wrong solution. I pointed this out to you, but you did not deem my questions worth an answer in more than two and a half weeks.

Choosing the wrong solution is not in the interest of E-E, and if you did so, it is not tragic because it can be corrected. Ignoring expert questions for clarification is a worse matter, and certainly impolite.
If you had a problem with understanding my solution in the other thread, simply asking (instead of closing choosing an obviously wrong solution) would have made me explain better and help you through the process.
Avatar of faithless1
faithless1

ASKER

Hello,

Thank you for the response.

I might not have been clear in both postings. I understand that the '.vdi' file has to be deleted on the host machine or windows as you specified. In this posting I specified that I can access all windows files through the gnome terminal and I'm looking for a simple solution to delete the .VDI file through gnome terminal. By 'I can access all windows files through the gnome terminal' I mean that all 'host' files are mounted to 'guest'.

I do appreciate all efforts/responses provided to questions, and if this is a matter of not giving enough attention to your efforts in the previous post - I apologize. However, the solution was being overcomplicated based on specifications and renaming .vdi to .vdy would free up space.

The reason I chose gparted because it seemed as the safest way since it would free up space on the drive vs renaming and deleting which did not appear as the safest way to remove the partition considering previously I deleted .VDI file but the space on the hard drive which was allocated to the partition did not free up.

Lastly, while this question might appear similar to my previous question, in reality it's not since I'm looking for a way to quickly remove .VDI files with "rm -rf BMG.vdi". Essentially, I'm looking for a solution where I can safely delete any .vdi that I create quickly through command prompt.

For instance, if I have created 15 partitions through VB by following the setup process and I need to remove 2 .VDI files so the question is whether i can I simply use "rm -rf BMG.vdi" to remove partitions.

Hope this clarifies some of your questions/concerns. Thanks again
Also, if in fact I would be able rename .vdi to .vdy and delete it which will free up 16GB of space, in that case I can case your solution would work but by simply deleting a partition that is of use would not solve the problem of freeing up space.
Thanks
If you have mounted the complete host filesystem as a network drive in Ubuntu (which is certainly unusual), and you can access the .vdi files that way, and the .vdi file is not in use by the present virtual machine, then you should be able to delete an unused .vdi file using this command:

sudo rm -i BMG.vdi

Do not use the -r switch, and use the -i switch for security reasons: it will prompt you before deleting.
My suggested solution in the other thread seemed "overcomplicated" for one single reason:

Since it was not at all clear what exactly you were after, and how your VMs were set up, I wanted to protect you from accidentally deleting a .vdi that was still in use and somehow required by your Ubuntu VM.
16 GB are too large for the recycle bin in most configurations, so simply deleteing a .vdi file would have been irrecoverable. Most askers here on E-E will not take necessary precautions: they will do exactly what experts tell them. I did not want to be made responsible if you deleted the wrong file.

I admit I still do not quite understand what you tried to explain to me above.

The question still stands: it is absolutely inconceivable that using GParted could help to get rid of a .vdi file. So did you use it? And did it do what you expected? If not, you chose a wrong solution. This must be corrected, because all closed threads on E-E are added to a knowledgebase of known working solutions.
this should clarify :
http://www.my-guides.net/en/content/view/122/26/
GParted is a program you can use to make changes to the partitions on your hard disk, such as deleting a partition, resizing a partition, or copying and partition.

Thanks for the previous response. Just to clarify: If I use this command, sudo rm -i BMG.vdi will it free up space? Deleting a .vdi file isn't really a problem, but deleting it in a way that it will free up partitioned space on the host is the main issue when dealing with a .vdi file.

Lastly, renaming the file to a different extension or simply deleting it without renaming an unused, unmounted .vdi drive is not a solution but would be if the .vdi file was 0KB.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of torimar
torimar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm definitely not the best at explaining but thanks for clarifying and providing all the details.

I just thought that because I did not delete the file from the recycle bin after renaming it to .vdy and deleting it from \virtualbox\harddisk (it's not used by VM and is not mounted), that this was the issue.

However, I just selected 'disk cleanup' and 'recycle bin' contents and they only amount to 3.7MB with the .vdy file. However, when I move the file to my Desktop, select properties, it is showing that the 'size' is 2GB but the 'size on disk' is 56KB. The combined totals in the recycle bin are much lower but shouldn't the total in the recycle bin be greater than 2GB? This should be my last questions. Thanks again
Sorry, I have been on baby-sitting duty yesterday.

So did it work and you actually managed to free up disk space as expected?
I'm a bit confused: wasn't it all about a 16 GB vdi file that you wanted to get rid of, not a 2 GB? This could, perhaps, be explained by the fact that there are 'static' and 'dynamic' virtual disks: you decide, on creating, of which type a disk should be. A static 16 GB vdi is always 16 GB large, no matter whether it contains data and how many. A 16 GB dynamic disk, however, will grow on demand, from just a couple of megabytes to 16 GB maximum, depending on the amount of data it actually holds.

But what really puzzles me is the discrepancy in size: a file with 'size' 2 GB should have a 'size on disk' of 2 GB +/- a couple of kilobytes. And it should not lose its size when moved to the recycle bin. I'm still not quite sure what to think of this.
Hey,

Sorry for the delay, been very busy. I think the problem had to do with compressed disk space, since at some point the entire C: drive was compressed so the actual size was larger than what was showing.

Thanks