Ben Chuanlong Du's Blog

It is never too late to learn.

Format a Disk on Linux

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. Locate the right disk to operate on. A few commands might help you. For example, you can use the command ls /dev/sd* to list all hard drives and the command ls /dev/nvme* to list NVME (SSD) drives. Or you can simply use the command lsblk to list all block devices (which include all hard and solid-state disks).

  2. Create disk partition tables using the command fdisk.

    fdisk /dev/sdb
    fdisk /dev/nvme0n1
    
  3. Format partitions to the right format (ext4 recommended). For example, the following command formats the partition /dev/sdb3 as ext4.

    mkfs.ext4 /dev/sdb3
    mkfs.ext4 /dev/nvme0n1p1
    

References

Comments