Formatting Disks on Linux

To identify the disk first type


sda is the first disk and sdb is the second. If you have more disk connected, it’ll be sdc, sdd and so on.

To identify the path we need to use for fdisk, we run

ls /dev/ | grep sd

We can see that in my case here we need to reference “sdb” which is /dev/sdb.

fdisk /dev/sdb

First we need to create a partiton table. for GPT, just use “g”. Then, use “n” for a new partition. You can change the values from default if you need to have a custom partition but by default it will fill the whole disk. Once done, use “w” to write the changes.

Now we have a newly formatted partition for use on our new disk.

Next we need a file system. The most common is ext4 so we’ll configure this for this example.

mkfs.ext4 /dev/sdb1

Leave a Reply

Your email address will not be published. Required fields are marked *