Partitioning, Formatting, and Mounting a Hard Drive in Linux Ubuntu 18.04

Sik-Ho Tsang
Jul 4, 2018 · 3 min read
(Not this kind of mounting. lol)

I have a brand new 4-TB harddisk to add to my computer recently. So I need to mount it in Linux. (Sik-Ho Tsang @ Medium)

To do this, I need to do the following:
A. Partitioning
B. Formatting
C. Mounting (including auto mount after reboot)
D. Checking whether the hard drive is mounted

A. Partitioning

  1. First, after connecting the harddisk to the computer by SATA and power cables, we can check the new 4-TB harddisk by:
sudo fdisk -l
/dev/sdb is the new harddisk

2. But we cannot mount it right now, if we mount it now, errors will come out. We need to partition it first:

sudo fdisk /dev/sdb

3. If we enter m for help, we can see the command list.

4. To check the partition table, enter p.

5. To partiton, enter n. I then just choose primary by entering p. And enter 1 for only one partition number.

6. Enter w to write the partition table to disk.

B. Formatting

  1. Format the newly partitioned harddisk:
sudo mkfs.ext4 /dev/sdb

C. Mounting (including auto mount after reboot)

  1. Usually drive is mounted in /mnt/. Create a new directory in /mnt/ first.
sudo mkdir /mnt/sdb

2. Then we can mount it by:

sudo mount /dev/sdb /mnt/sdb

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

nano /etc/fstab

4. Enter following at the end of file:

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

The first item is the path for the hard drive. The second one is the destination for the mounted drive, where we want to mount. The third one is the format type. The forth to sixth one I just kept as defaults, 0 and 0.

D. Checking whether the hard drive is mounted

There are 3 methods to check. Three of them can also find the mounted hard drive sdb.

  1. mount
mount | grep sdb

2. lsblk


3. df



New disk mount to Ubuntu (2016, Simplified Chinese)

How do I check where devices are mounted

What is the difference between ext3, ext4 from a generic users perspective

Sik-Ho Tsang

Written by

PhD, Researcher. I share what I've learnt and done. :) My LinkedIn:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade