Solved

Delete .VDI file, Free up hard drive

Posted on 2011-02-28
10
1,462 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:faithless1
  • 5
  • 5
10 Comments
 
LVL 35

Expert Comment

by:torimar
ID: 34999054
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: http://www.experts-exchange.com/OS/Linux/Q_26811233.html?cid=1135#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.
0
 

Author Comment

by:faithless1
ID: 34999767
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
0
 

Author Comment

by:faithless1
ID: 34999883
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
0
 
LVL 35

Expert Comment

by:torimar
ID: 35000171
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.
0
 
LVL 35

Expert Comment

by:torimar
ID: 35000267
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.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:faithless1
ID: 35007378
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
0
 
LVL 35

Accepted Solution

by:
torimar earned 500 total points
ID: 35009169
I know quite well what GParted is because I use it all the time. That is why I also know that it cannot be used to get rid of a .vdi file. It is able to manipulate/delete partitions inside that .vdi file, not the virtual disk itself. Hence why it was evidently a wrong solution to choose in the other thread.

Quote: >>"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."

If you delete a .vdi file, it will free up space on the filesystem where this file was located, yes.
This is best done by directly deleting the file on the host (as I said above and in the other thread). If that host is Windows, you may have to also empty the recycle bin.
If you are trying to delete the vdi file from inside the guest (which is very unusual), and you receive an error, or the space on the host is not freed up, then this may be caused by the fact that this is not the usual procedure. The usual procedure is to do it on the host, not via the guest. Even if you cannot shutdown the VM for some reason, you should be able to task-switch to the host OS in order to delete the file.
If that isn't possible, and you have to delete the vdi from inside the guest, there should be ways to verify whether the space has actually been freed up, by checking the free diskspace before and after the removal using either the Ubuntu filemanager or the 'df' console command: http://linux.about.com/od/commands/l/blcmdl1_df.htm


Quote: >> "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."

As much as I tried I do not understand what you mean.
Again: renaming the file was just a precaution, not a solution. It would help you to check whether the file was still required somehow. If everything would run well after renaming the file and restarting the VM, you would be safe to delete it. That last step was the solution.
Of course, you have to physically delete the .vdi file from where it is located on the host's filesystem (usually in ..\virtualbox\harddisks). It does not suffice to only 'remove' it from the VM by clicking the '-' (minus) inside the VB control panel.

Furthermore: you simply cannot delete a file that is in use, neither in Windows nor in Linux. So, of course, only unused VM files can be deleted. A mounted file also cannot be deleted, because it presently is in use. And a file that is presently unmounted (because the VM isn't running) but would be mounted/required by a VM should not be deleted because this will create problems with the VM. It needs to first be removed from the VM in the VB control panel, and can then be deleted - if no longer required by the VM.
0
 

Author Comment

by:faithless1
ID: 35014278
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
0
 
LVL 35

Expert Comment

by:torimar
ID: 35024638
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.
0
 

Author Comment

by:faithless1
ID: 35063138
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
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
David Varnum recently wrote up his impressions of PRTG, based on a presentation by my colleague Christian at Tech Field Day at VMworld in Barcelona. Thanks David, for your detailed and honest evaluation!
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now