How to prepare a new HDD on Linux in exFAT file system type (create partition, format it and mount disk permanently) – Full instruction

1. Firstly, find the mounted Hard Disk Drive (HDD)


Let’s assume, its a sdb then our HDD path will be: /dev/sdb

2. Now, let’s create a partition:

$ sudo fdisk /dev/sdb

will be displayed smth. like this:

Command (m for help):

By typing m you’ll see the all possible options:


   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

Type n to start creating a new partition

Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)

Then continue pressing Enter to create a primary partition allocating full disk space (by default).

And finally press w to create a new partition and exit from fdisk‘s interactive mode.

3. Format the disk

Get list of all disks / partitions:

lsblk -io KNAME,TYPE,SIZE,MODEL,SERIAL,UUID,FSTYPE | grep 'disk\|part'

Let’s assume, a new partition we’ve just created is sdb1 , then full path to it will be /dev/sdb1.

Before formatting the partition, we need mkfs.exfat utility, which is not presented by default:

$ sudo apt install exfat-utils

Now format it:

$ sudo mkfs.exfat -n MY_LABEL /dev/sdb1

or just simply without defining the label (if you prefer):

$ sudo mkfs.exfat /dev/sdb1

4. Mount a new partition

Before mounting the partition, we need to create a mount point, let’s assume it should be under /HDD2.

Therefore, let’s create a folder with that name first:

$ sudo mkdir /HDD2

Now mount the new partition to it:

$ sudo mount /dev/sdb1 /HDD2/

If you type df -h you’ll see all disk file systems and space usage info.

But there is a tiny problem – after system reboot, your partition will be gone and you’ll need to mount it again!

5. Mount a new partition permanently

We need mount our partition automatically – to do so, grab UUID of the partition & modify /etc/fstab file where is the list of all mounted partitions.

Grab partition’s UUID using the previous command:

$ sudo lsblk -io KNAME,TYPE,SIZE,UUID,FSTYPE | grep 'part'

Let’s assume the UUID is: 1234-ABCD

Now open the /etc/fstab file

$ sudo vim /etc/fstab

and put the next line at the end of the file:

UUID=1234-ABCD    /HDD2    exfat    defaults    0    2

Save the file and update system changes:

sudo mount -a

And that’s it. if you type df -h then you’ll see your new partition (disk) mounted which will be auto-mounted after system restart as well.

BTW: you can check your new exfat partition by using the next command:

$ sudo fsck.exfat /dev/sdb1

and repair it (if some errors presented) by typing this:

sudo fsck.exfat /dev/sdb1 -a


Leave a Reply

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