Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does anyone has such experience that you accidentally delete the used disk image when virtual machine is running?

I would expect that the virtual machine will fail immediate, but, surprisingly, it still running perfectly. I have tried to execute many I/O commands and even create very large files by "dd" which are totally more larger then the vm's memory size. But it is still live.

Can anyone explain why?

Server info: ubuntu 12.04 with KVM and libvirt installed from default repo. VM's disk image is qcow2 format.

share|improve this question

closed as unclear what you're asking by Jenny D, Ward, kce, mdpc, Scott Pack Jul 8 '13 at 18:01

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I am not sure how to make the question more clearly. After I got the answer I know it is nothing about virtual machine, but the linux file system. Maybe some other guy who do not familiar in file system may have similar question as this. –  user1817188 Jul 9 '13 at 1:39

2 Answers 2

up vote 7 down vote accepted

Deleting a file does not actually delete the file, it reduces the number of names pointing to an inode. If both the number of names and the number of open file descriptors to the file reach 0, the data gets deleted.

So if you delete a file that's still open by some application, that application can still happily use that file. Only when the last file descriptor gets closed, the file gets deleted (and then you'll see the used space is reclaimed again).

share|improve this answer
    
Thanks for the quick response. –  user1817188 Jul 8 '13 at 10:14

When you delete a file that has an open file descriptor, it's not actually deleted until the file descriptor is closed. You can probably find that file using lsof | grep deleted command.

Try this if you want to undelete the file: http://www.serverwatch.com/tutorials/article.php/3822816/Recovering-Deleted-Files-With-lsof.htm

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.