I'm not aware of any methods for deleting a drive while an operating system runs from it (at least not in it's entirity), but cloning your OS to a ramdrive could be a potential work-around. Once booted into the ramdrive your host system drive can be low level formatted using dd.
Steps:
Step #1
In terminal type:
sudo mkdir /workingfolder
sudo -i
sudo rsync -a --delete --one-file-system / /workingfolder --exclude=/workingfolder
Step #2
In terminal type:
sudo apt-get update
sudo apt-get install squashfs-tools
sudo apt-get install live-boot
Step #3
In terminal type:
sudo mkdir /live
Step #4
In terminal type:
sudo mksquashfs /workingfolder /live/livefs.squashfs
Step #5
In terminal type:
gksu gedit /etc/default/grub
Change "GRUB_TIMEOUT=10" to read "GRUB_TIMEOUT=-1".
Step #6
In terminal type:
gksu gedit /etc/grub.d/40_custom
Add the following to the file and save it:
menuentry "Ramboot" {
set root='(hd0,1)'
linux /boot/vmlinuz-3.11.0-12-generic boot=live toram=livefs.squashfs
initrd /boot/initrd.img-3.11.0-12-generic
}
Keep in mind that the text specifying your kernel must match what you actuall have so you may need to browse your "/boot" folder to see what # you have. The numbers I've used are for Lubuntu 13.10.
Step #7
In terminal type:
sudo update-grub
Step #8
Open gparted, right click on your swap partition, and choose "swap off". Now delete the paritition.
Step #9
Reboot the computer and choose "Ramboot".
Step #10
In terminal type:
sudo -i
dd if=/dev/zero of=/dev/sda
It's important that you use "sudo -i" rather than "sudo dd" whenever working with dd to avoid interuptions. Also you should not have any mounted partitions on the drive being erased.
Step #11
Shutdown. Your hard drive is now erased.
Notes:
Note #1 = If your installation has several gigabytes of software installed you may need to uninstall some before proceeding.
Note #2 = If you have several gigabytes of data on the root partition (eg: in your home folder) you will need to delete it before beginning, or use the "-ef" flag when creating the squashfs. Eg: "mksquashfs /workingfolder /live/livefs.squashfs -ef /home/username/somethingtoexclude".
Note #3 = It will take a while to create the squashfs, and then a very long time to format the drive.
Note #4 = This is just a quick-n-dirty way of doing this. You should not use this approach for creating squashfs files you intend to ramboot for regular use. Normally you should create a squashfs file from another installation to ensure ALL files are copied.
Note #5 = I tested this on Ubuntu 12.04 - Desktop X86-64, but I didn't bother waiting for the hard drive to totally zero out.
Sources:
http://blog.sleeplessbeastie.eu/2012/05/02/ubuntu-boot-to-ram-couple-of-notes/
h#t#t#p#://askubuntu.com/questions/253096/low-level-format-of-hard-drive
http://postbin.djun.net/pages/article16/page.php
Additional Information:
While I don't know if it's possible an alternative to the above approach might be simply adding an entry for the initrd in grub, booting into it and running dd from there. However I don't know if this is possible, or if dd is installed in the initrd? However if it is this would be an equally affective method, and faster since you don't have to generate an image first.