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

Sik-Ho Tsang

Jul 4, 2018


(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

lsblk


3. df

df

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Installing Fail2ban

  Installing Fail2ban Installing Fail2ban on Ubuntu Server 16.04 is simple. Run the following...

How to display sockets summary and all open network ports with ss command

How to display sockets summary with ss command # ss -s How to display all open network ports...

How to find a folder in Linux using the command line

  I am a new Linux user. How do I find files and folders in Linux using the bash command line?...

How to scan for viruses with ClamAV on Ubuntu

ClamAV There aren't many viruses made for Linux distributions and as such, most people who use...

How to setup a UFW firewall on Ubuntu 18.04 LTS server

How do I setup a firewall with UFW (uncomplicated firewall) on an Ubuntu Linux 18.04 LTS server...