rm -rf /
… does not work. At least not today on a Debian/Sid system. Looks like there are some things, not even root is allowed to do:
root@sid:~# rm -rf /
rm: cannot remove root directory ‘/'
If you’re curious what happens when you wipe your disk on a running system:
root@sid:~# cd /
root@sid:/# rm -rf *
does the trick.
Update: That’s with plain rm not safe-rm.
Update 2: I looked through the code of rm.c to find that / is protected by default — as a simple rm --help also shows:
$ rm --help
Usage: rm [OPTION]… FILE…
Remove (unlink) the FILE(s).
[...]
–no-preserve-root do not treat `/’ specially
–preserve-root do not remove `/’ (default)
Tags: debian
November 10th, 2008 at 11:50 am
you have instaled safe-rm, don’t you?
November 10th, 2008 at 12:03 pm
No, no la hagas tio. Siempre hay motivo para vivir…
November 10th, 2008 at 2:17 pm
Solaris managed to get rm -rf / prohibited as POSIX compliance, under the euphemism “pre-determined heuristic“.
November 10th, 2008 at 2:21 pm
It is the correct behaviour.
Compare “rm -rf /tmp/” and “rm -rf /tmp/*”. The first one will remove also the directory, the second one no.
Now think about removing “/” (will it last only ” “?). The root directory is special in the kernel: it is the root of the file tree. Allowing the root removal, the root must become a NULL pointer, thus requiring a lot of additional checks, which is not worth in POSIX like environment (Note: posix permit not allowing to remove some systems directory and files).
November 10th, 2008 at 2:43 pm
man rm:
–no-preserve-root
do not treat ‘/’ specially
–preserve-root
do not remove ‘/’ (default)
January 8th, 2009 at 2:29 pm
this preserve option seems to me just a fucking stupid idea