rm -rf / on a virtual machine?

1

So, this is probably a stupid question, but I'm genuinely interested. Would it be safe to recursively delete everything on a virtual machine from a command line, just for fun? I'd assume so, given that it has no connection to an actual hard disk, but maybe if some of the devices attached to the virtual machine were connected...

Simply put, would it be safe to run? Just to add to my theoretical knowledge.

Addison Crump

Posted 2015-07-21T23:07:43.167

Reputation: 170

With the most current backup it should be OK to try, and you may even have a chance to test your BACKUP strategy for real. – arch-abit – 2015-07-22T01:44:12.780

I have no idea what you mean by that. Could you please explain? – Addison Crump – 2015-07-22T01:45:32.703

Create some files, back them up, create a disaster and see if they are destroyed in the process. If they do rejoice, and try to restore them. A very worthy exercise, this is neither stupid-foolish or a waste of time. – arch-abit – 2015-07-22T01:51:25.400

That wasn't exactly my question - I was wondering if it was safe to do this exercise, and I assumed that it was, but didn't want to screw anything up on my real hard drive. That is something I'd like to know how to do, though. I'll try that, if it is. – Addison Crump – 2015-07-22T01:55:51.687

My point is this - if I have a standard, VirtualBox virtual disk with no attachment to the main hard drive, would there be any side effects to running rm -rf /. – Addison Crump – 2015-07-22T02:04:08.660

Yes, you would need to re-install the virtual Linux instance, but all else is perfectly safe. You cannot delete anything but the content of the DVI file. – arch-abit – 2015-07-22T02:08:45.507

I thought so, but was worried for the sake of being worried, to be honest. Go ahead and post it as an answer so I can close it, if you want. – Addison Crump – 2015-07-22T02:11:01.957

Answers

2

All shares are protected by the host shares them let that be real or virtual, and nothing happens to them as long as the host protects them. You cannot remove a shared resource just by removing a client by disconnecting it or by destroying it, so yes, rm away.

arch-abit

Posted 2015-07-21T23:07:43.167

Reputation: 455

Interesting thing - Yosemite doesn't appear to let you delete some of the core files anyways, even in sudo or su. Go figure. Still is unbootable though. – Addison Crump – 2015-07-22T02:19:37.317

OSX is designed to be that way, and I personally respect that. There are plenty of other OS to tinker with, OSX has no weight and makes no difference in that fact. – arch-abit – 2015-07-22T02:25:32.190