Format and mount USB in Linux

You have a USB and don't know how to format and mount it in Linux. This article will guide you to do that.

Suppose you have a completely new 4TB hard drive recently and want to add it to your computer. You need to mount it in Linux. To do this, you need to take the following steps:

  1. A. Partitioning the hard drive in Linux
  2. B. Format USB in Linux
  3. C. Mount USB in Linux (including auto mount after reboot)
  4. D. Check if the hard drive is mounted

A. Partitioning the hard drive in Linux

Step 1 : First, after connecting the hard drive to the computer with a SATA cable and power cable, you can test the new 4TB hard drive with the command:

 sudo fdisk -l 

Picture 1 of Format and mount USB in Linux

Step 2 : But you cannot mount it now, if you mount it immediately, an error will appear. You need to partition it first:

 sudo fdisk /dev/sdb 

Picture 2 of Format and mount USB in Linux

Step 3 : If you enter m for help, you can see the command list.

Picture 3 of Format and mount USB in Linux

Picture 4 of Format and mount USB in Linux

Step 4 : To check the partition table, enter p .

Picture 5 of Format and mount USB in Linux

Step 5 : To partition, enter n . For example then simply select the primary partition by entering p and entering 1 for only some partitions.

Picture 6 of Format and mount USB in Linux

Step 6 : Enter w to write the partition table to the drive.

Picture 7 of Format and mount USB in Linux

B. Format USB in Linux

The USB format in Ubuntu with the Terminal command is much easier than in Windows. But some Ubuntu users are not familiar with Terminal commands. This tutorial will help Ubuntu users (Linux) take simple steps to format USB.

Picture 8 of Format and mount USB in Linux

Step 1 : Insert the USB and determine the volume

Insert the USB into the system and determine the correct USB drive. This is a step you need to take care of, because you can format the drive incorrectly if your drive is not correctly identified.

 $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 28G 24G 2.3G 92% / udev 1.4G 12K 1.4G 1% /dev tmpfs 277M 1.2M 276M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1.4G 34M 1.4G 3% /run/shm /dev/sdc1 14.8G 1.4G 13.4G 10% /media/tecadmin 

Now, the example has determined the drive / dev / sdc1 is a 16GB USB attached.

Step 2 : Format USB in Linux

Whenever you mount USB in Ubuntu, it will automatically mount to the system. You cannot format any drive on mounted Linux systems. So first unmount the USB drive / dev / sdc1 on the system.

 sudo umount /dev/sdc1 

Now, use one of the following commands on the file system you want. To format USB, most users prefer VFAT and NTFS file systems because they can be easily used on Windows operating systems.

  1. Format with vFat file system:
 sudo mkfs.vfat /dev/sdc1 
  1. Format with NTFS file system:
 sudo mkfs.ntfs /dev/sdc1 
  1. Format with EXT4 file system:
 sudo mkfs.ext4 /dev/sdc1 

Similarly, you can format the USB flash drive with any required file system.

C. Mount USB in Linux (including auto mount after reboot)

Step 1 : Normally, the hard drive is mounted in / mnt /. Create a new folder in / mnt / first.

 sudo mkdir /mnt/sdb 

Step 2 : After that, you can mount it with the command:

 sudo mount /dev/sdb /mnt/sdb 

Picture 9 of Format and mount USB in Linux

Step 3 : But you need to mount it every time you reboot. To automatically mount after every reboot, we will use nano to modify the / etc / fstab file:

 nano /etc/fstab 

Step 4 : Enter the following command at the end of the file:

 /dev/sdb /mnt/sdb ext4 defaults 0 0 

Picture 10 of Format and mount USB in Linux

The first item is the path for the hard drive. The second is the destination of the mounted drive (where you want to mount the drive). The third is the format. The fourth to sixth items remain the same by default of 0 and 0 .

D. Check if the hard drive is mounted

There are 3 methods to test. All three methods can find the sdb mounted hard drive.

1. mount

 mount | grep sdb 

2. lsblk

 lsblk 

Picture 11 of Format and mount USB in Linux

3. df

 df 

Picture 12 of Format and mount USB in Linux

Hope you are succesful.

Update 05 July 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile