Formatting USB drives via command line takes only few steps and its easy.

Plug in your USB drive to the computer and run these following steps to format them.


1. View the mounted drives on system

mount

You should get output something like this:

/dev/sda6 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
/dev/sdb1 on /media/pj/Cruzer type vfat
(rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,
flush,uhelper=udisks2)

The command will list all currently mounted drives on system.


2. Unmount the USB drive that needs to be formatted

sudo umount /dev/sdb1

The ‘/dev/sdb1’ is the media drive where USB drive was mounted, see step 1. It can be different from you.


3. Format the drive
To FAT filesystem.

sudo mkdosfs -n 'MyDrive' -I /dev/sdb1

To FAT32 filesystem

sudo mkdosfs -n 'MyDrive' -I -F 32 /dev/sdb1

To Ext4 filesystem

sudo mkfs.ext4 -n 'Label' -I /dev/sdb1

mkdosfs : creates an MS-DOS file system under Linux
mkfs : build a Linux filesystem
n : Volume name
I : This switch will force mkdosfs to work properly
For more information on mkdosfs, use man mkdosfs.
Similarly, for more information on mkfs, use man mkfs.

Leave a comment

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.