-4

I want the equivalent of this Windows command:

format d: /p:2 
0

2 Answers 2

5

The format command in Windows has at least three different uses.

  1. first creation of a filesystem structure on a block device that has no filesystem existing
  2. overwriting an already exiting filesystem with a new empty filesystem structure ("quick format"; equals deletion of all file and directory names from the filesystem, but the data still remains on the disk)
  3. overwriting an already existing filesystem with a new empty filesystem structure and overwriting the data area of the new filesystem with zeros ("full format"; equals deletion of all data on the disk)

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.

1
  • your answer is the best one @raj
    – user1628764
    Sep 14, 2022 at 17:12
4

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
  • sdaN is the partition to do this one; replace it by the device name you want to do this on. It WILL kill your data so do not do this on a system you still need.
  • --random=: Number of passes to use writing random data before wiping data.
  • It will require sudo.

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"

0

You must log in to answer this question.