I'm running Debian and need a way to format the entire hdd in order to not leave any trace on it because I want to donate it to a friend. So what will be the best way in order to format it? If I reinstall the OS it will not fully format it. I'm looking for a way to completely format it and make it like when you buy it from the shop, completely new and never stored a thing before.
Unless your "friend" is the NSA, tools that do lots of random or pattern overwriting (as DBAN which others are recommending does) are overkill -
dd if=/dev/zero of=[your disk... make sure you get it right] bs=10M will erase it so that it can't be recovered without taking the disk apart and scanning the platters with special hardware.
If you use
/dev/urandom instead as Gilles suggests, make sure to zero out the MBR afterward so that the partition table and boot code is clean to not confuse the BIOS or any partitioning tools:
dd if=/dev/zero of=[disk] bs=512 count=1
shred -vfz /dev/X
Beware that DBAN will erase every hard drive connected to the computer. If you have other hard drives that you plan to keep, make certain they're unplugged before booting DBAN.
This really isn't a "Linux and Unix" answer, but I would use the ATA Secure Erase command if it is available for your hardware, which is likely is. You can read about ATA Secure Erase here: https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase.
The following summarizes how to use the command on any system with the
hdparm utility (man page). The directions are from the article above. I am assuming the drive is at
/dev/X. You want to do this from a Live CD of some sort such that you aren't actually running off the disk you are trying to erase.
hdparm -I /dev/X
Make sure the device is not frozen by looking for "not frozen" in the command output. If the device is frozen, it is likely you will need to look in your BIOS to see if you can change it.
hdparm --user-master u --security-set-pass mypass /dev/XSet the drive password to "mypass" or something of your choosing. If you don't have a password set, the drive won't accept this command.
hdparm --user-master u --security-erase mypass /dev/XIssue the command.
The directions on the website linked above also have commands to ensure each step worked as desired and some helpful troubleshooting. This method is highly secure and relatively fast.
It's super secure albeit slow. So be ready for that.
You can use the
wipe command which can handle files, directories, partitions and complete hard disk drives. More information you will find in manpage
man wipe and here http://linux.die.net/man/1/wipe:
wipe -i /dev/X
Run a destructive
-w scan on the partition in question. This overwrites everything with various bit patterns several times.
Maybe you can install "disks" https://askubuntu.com/questions/249310/how-can-i-launch-disk-utility-after-installing-it , https://help.gnome.org/users/palimpsest/, it reads your partitions and you can use the gear to format completely if they are primary.