Ubuntu Format Disk

Kevin FOO
2 min readSep 19, 2023

--

I don’t format disk very often but every time when I needed to format with command line I need to google for it. It is time I add this in my blog/medium for my own reference.

# To view all the disks attached
# I am formatting /dev/sdb
lsblk
# Add -f to see the file system type and the label of the disk
lsblk -f
# The above commands doesn't actually show that sdb is at /dev/sdb
# Use the fdisk to verify if needed
sudo fdisk --list
# Run the below command to format /dev/sdb with ext4 file system
sudo mkfs -t ext4 /dev/sdb

To format it as FAT32

sudo mkfs -t vfat /dev/sdb

To format it as NTFS

sudo mkfs -t ntfs /dev/sdb

Verify the disk

# label the disk as my_disk
sudo e2label /dev/sdb 'my_disk'

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet