I'm about to terminate my relationship with my hosting provider of many years, but I'd like to securely wipe the box before I do. This is a dedicated server running Debian on a single EXT3 drive and although I have root access, I can't boot alternate media since it's headless in a rack somewhere.
I don't need multiple passes, but I would like to wipe free space if possible. Basically I'd like to walk away and make sure I don't leave any of my personal data behind. I'm worried that the box might crash before it finishes wiping/syncing the filesystem if I just run srm -R -s /
The CentOS installer (anaconda) that ships with the PXE images includes a VNC server, so you can alter your grub config to boot the CentOS installer, passing the answers to the pre-stage 2 installer questions on the grub line, reboot and then VNC to the installer.
Now, if my memory serves me correctly, from within that installer you should be able to drop to a shell, from which you can access and destroy the disk.
Copy the vmlinuz and initrd files from the PXE dir in the CentOS distro (http://mirror.centos.org/centos/5/os/i386/images/pxeboot/) to /boot and modify your grub config:
Incidentally, any decent hosting company should be prepared to destroy your disks for you.
Before you destroy the OS you could remove anything sensitive and zerofill (using dd if=/dev/zero of=justabigfile).
And I believe most systems will survive a dd to a running system long enough to overwrite the entire disk. There is no way back if it doesn't, of course.
My solution involves a multi step approach doing some of the above, but also involving a chroot in ram that should allow dd to finish completely clearing the disk.
First delete all of your sensitive data, leaving necessary files for running the operating system. Then do this (not in a script, do it one command at a time):
That should take care of it!
I have successfully gotten all the way through
rm -rf --no-preserve-root /
without the system crashing first, and without anything being left on the drive.You can just use
dd
to overwrite the whole partition/disk on a running server without any worries. We use it at work a lot (when customer doesn't want to pay for secure physical disk destroy).You actually wipe the data without mounted filesystem knowing it, so filesystem will begin to freak out as its metadata are being lost, then OS itself will begin to "collapse". However what is already in cache still works. So you can monitor the progress via remote console or KVM (didn't try it via ssh). System is kept running even after
dd
is finished, however no command will work and all daemons are probably already dead.I use these commands:
dd if=/dev/zero of=/dev/sda bs=1M &
and thenkill -HUP %1
to monitor the progress (dd will print out current speed and amount of data written). Setting block-size (bs
) is very important for achieving the HDD seq write speed withdd
.Each time
dd
was able to wipe the disk to its end and I was able to issue thekill
command (shell built-in) until the end. If you have software raid, you can wipe either themd
device itself, or each component device individually.The ATA protocol has a "secure erase" command, which, as its name indicates, should securely wipe the entire HDD.
See the Kernel wiki article for details, but mind the warnings at the top:
https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase
You could try to write random data on your disk like this :
Is safer than using /dev/zero because it write random data, but it's also A LOT slower..
Whatever you choose to do, get onto another provider and test it.
Get a similar instance on AWS (or gcloud or ...) and try it there, keeping the disk and then attaching it to another instance as additional storage and scanning it. dd if=sdb | hd
Just about all of your sensitive material should be in
It is the config files with embedded passwords that bother most people. If you know what they are, search the whole filesystem to root them out.
rm will delete files, but a hex editor will still read the disk. So zero afterwards. Have a look at shred. You should have a log of your config files and where they are for DR purposes right ? Don't forget crontab files if you have passwords in those, say.
The CentOS install, or any ramdisk solution is sound. The kernel will be in memory, you need dd and some bin content. But if you reboot in recovery mode you may not have networking or SSH and cut yourself off.
N.B. Kedare has a good idea, and if you are running from ram on your next reboot (ramdisk) this is possible, it is very hard to recover from /dev/zero writes to begin with so it does not really add value unless your life depends upon it ?