What happens if I attempt to delete Ubuntu itself while logged in?

What would happen if I delete the / directory while logged as root into Ubuntu?

Would I get some sort of error to the effect of Error: unable to self-destruct? Or would I actually be able to delete the directory?


I did try this out on a live USB for answering a question on Quora some time ago (there's another great answer there by Eric Bowersox).

First attempt on an installed system where I was confident nothing would happen:

# cd /
# rm -rf /
rm: it is dangerous to operate recursively on `/'
rm: use --no-preserve-root to override this failsafe
# rm -rf .
rm: cannot remove directory: `.'
#

So, I tried it on a live USB (quoting from my original post):

Eric Bowersox inspired me to try it out on a live USB (without persistence). Like he said, a huge number of errors about files currently being used, plus another huge set of errors about the read-only file system being used ended up with parts of the GUI vanishing in stages: first the icons in the Unity launcher, then the icon for the HUD, then icons in the system tray. When it all ended (remarkably quickly), only the terminal could focused, clicking anywhere else didn't work. I could open anything else, not even the preferences of the terminal. Menus of the localization and the clock applets opened, but didn't work.

Switching to the other ttys worked once (I didn't get around to trying any commands), but once I switched back to the GUI, nothing worked.

Here's how it looked then: enter image description here

Nothing worked at this point. Except for the power button and the Magic SysRq keys.


Deleting the shared libraries or rm itself shouldn't cause any problems, since both would have been loaded into memory when rm started.


So I did it in a running Ubuntu 14.10 VM inside Virtualbox. I did not bother to install it myself but downloaded one directly from osboxes.org

Running sudo rm -rf --no-preserve-root / in a terminal caused this:

  • Some buttons began to disappear in the launcher
  • Then the launcher was gone
  • And finally all the desktop with the terminal running disappeared
  • Left with a total blue screen (sic)bsod

That was only the visible part. I didn't let it run very long and shut down the machine.

So rm was not completely succesfull because there was some files lying around still: /bin, /run, some part of /lib, and /var

But no /boot and no kernel left so it was no bootable again even though the modules were still there.

Edit: Doing it from a console (Ctrl-Alt-F1 or Right-Ctrl F1 in vbox) is much more sucessfull though less spectacular.

It spits out errors about /sys file it can't delete , the same in /proc. But there is nothing left after it completes. Only some devices under /dev and some files in /run.