Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was just wondering if I could run the following command on my mounted OS partition i.e. the one I booted from:

sudo dd if=/dev/zero of=/dev/sda bs=1M 

I can't really experiment with this because you only get to run it once.

share|improve this question

migrated from stackoverflow.com May 22 '12 at 23:01

This question came from our site for professional and enthusiast programmers.

    
I cant really experiment with this cause you only get to run it once. Get a virtual machine. –  Radek 'daknok' Slupik May 22 '12 at 20:00
    
I have to worry about DD'ing my hard drive quickly, a virtual machine is the least of my problems :P –  busbina May 22 '12 at 20:04
    
Maybe this is what you are looking for. –  Radek 'daknok' Slupik May 22 '12 at 20:06
    
If you want to ensure that data is indeed destroyed, you may want to use /dev/urandom, rather than /dev/zero. –  Renan May 22 '12 at 23:45
1  
@Renan Using random data won't make the data any less recoverable than using zeroes (case in point: the Great Zero Challenge remains unaccepted). Don't bother. –  Chris Down May 23 '12 at 0:19

3 Answers 3

up vote 3 down vote accepted

Yes, there's absolutely nothing stopping you from running that command.

However it is entirely possible that in the process of running it, the system will become unstable and you'll get a kernel panic. I can't think of anything that would cause that to happen, and I've done this without running into said issue, but it is theoretically possible (due to memory-mapped files).

Note though that as soon as the command completes, and you're dropped back to a shell, you won't be able to do a single thing.

Another possible cause of this failing would be if you have a watchdog running (if you don't know what a watchdog is, you probably don't have one). The watchdog is very likely to die, and when it does the system will reboot.

share|improve this answer

Of course you can't. Sooner or later you'll get a message saying Device is busy and you'll end up with an incomplete wipe of your disk. You're best off getting a Live CD/DVD and booting from it, and then executing that command.

But if you're already looking for best ways to erase your data without physically damaging the medium, you might want to look into the SECURE ERASE command set, supported by hard drives since 2004 or so.

share|improve this answer
3  
No reason to get a Device busy for dd. It should easily wipe the entire disk. Usually after the wipe, some commands still work if they were cached in memory. We use dd to erase disks of obsoleted servers quite often. –  Marki555 May 23 '12 at 6:32

Yes - that will work. once running the dd-command is a running process in memory.

I once migrated a running linux VM onto other hardware and forgot to switch the underlying harddisk (so I had running processes who have lost their storage completely) - it ran about 10 minutes before crashing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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