How To Add New Disk in Ubuntu 20.04

In this article you will learn how to add new disk in Ubuntu 20.04, how to partition, format disk and mount new disk from command line.

Finding the New Hard Drive in Ubuntu

For this tutorial I attached to my Linux new 20Gb hard drive. To determine the path to the new hard drive run command:

$ sudo lshw -C disk -short

After execute lshw command you will see output like:

$ sudo lshw -C disk -short
H/W path       Device      Class      Description
/0/87/0.0.0    /dev/cdrom  disk       VMware IDE CDR10
/0/88/0.0.0    /dev/sda    disk       53GB Virtual disk
/0/88/0.2.0    /dev/sdb    disk       21GB Virtual disk

Where is /dev/sdb path to new installed disk.

Now we need partition new disk.

Ubuntu Disk Partition From Command Line

For partitioning we will use gdisk command (for the disks < 2TB can be used fdisk). Lets create new GPT partition on our new /dev/sdb disk.


$ sudo gdisk /dev/sdb


GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries in memory.

Command (? for help):

Output show its blank disk and we don’t have any partition on disk.

If we type “?” and enter, we will see all available options:

b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu

(If your disk is not blank and and have partitions on it you need delete with d command ans save changes with w).

Select “n” to add a new partition

and accept all defaults by pressing “enter”:

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-41943006, default = 41943006) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

finally press “w” then “y” write table to disk and exit:

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.

Ubuntu Format Disk ext4 from Command Line

Now we can format disk to ext4 file system using mkfs.ext4 command :

$ sudo mkfs.ext4 /dev/sdb

mke2fs 1.45.5 (07-Jan-2020)
Found a gpt partition table in /dev/sdb
Proceed anyway? (y,N) y
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: ea5ee8eb-178c-4ead-ad35-e0f5302e0b2d
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks):
Writing superblocks and filesystem accounting information: done

Our /dev/sdb disk now formatted as ext4 lets check:

$ lsblk -f

Mount Drive Ubuntu

To manually mount drive in Linux we need create mount:

$ sudo mkdir /mnt/disk2

and mount new disk to mount point /mnt/disk2

$ sudo mount /dev/sdb /mnt/disk2/

Auto Mount Drive Linux

For automatic mount disk in Ubuntu at boot you need edit /etc/fstab file. Ubuntu recommends use in fstab disk UUID instead of path.

To get /dev/sdb disk device UUID type:

$ sudo blkid | grep sdb

Example output:

/dev/sdb: UUID="205c9347-c533-43e2-a4a8-d92599604977" TYPE="ext4"

Open /etc/fstab with any text editor and add next line:

UUID=205c9347-c533-43e2-a4a8-d92599604977 /mnt/disk2 ext4 defaults 0 1

To apply new /etc/fstab settings run:

$ sudo mount -a

Or just reboot your Ubuntu server.

That’s It!

Now you can use new disk /mnt/disk2


In this article you just learn how to add new disk in Ubuntu 20.04, how to format hard drive to Linux est4 file system, how to configure automatic mount at boot.

Discuss article in ArsTech Forum


If you like what you are reading, please:

Buy me a coffeeBuy me a coffee


Start the discussion at