I want the equivalent of this Windows command:
format d: /p:2
The format
command in Windows has at least three different uses.
For cases 1) and 2) in Linux you use the same command:
mkfs -t <filesystem-type> <device>
where of course you have to substitute appropriate parameters for <filesystem-type>
and <device>
. For example
mkfs -t ext4 /dev/sda1
will create ext4 type filesystem (typical Linux filesystem) on first partition of the first hard drive.
For case 3), I recommend to first overwrite the whole device/partition with zeros using the dd
command like in example below, and then use the command above to create new filesystem. To overwrite the partition with zeros, use:
dd if=/dev/zero of=/dev/sda1 bs=1M
and then use the mkfs
command above.
Zerofilling with 2 or more passes (/p:2
) a partition or disk if it is an SSD is enough. All SSDs have a limited number of write cycles so overwriting them multiple times is overkill. 1 write is more than enough. If you want to discard an ssd also drive a nail through it. A HDD does not suffer from it that much.
In Linux we have zerofill
zerofill /dev/sdaN --random=2
--random=
: Number of passes to use writing random data before wiping data.The better option for an SSD that is the boot drive would be to do this from your motherboard's UEFI BIOS. It is called something like "secure erase feature"