Adding an Extra Hard Disk to Your Ubuntu Machine: A Step-by-Step Guide
In this article, we will walk you through the process of adding an extra hard disk to your Ubuntu machine. We will cover the key concepts related to this topic, including partitioning, formatting, and mounting the new disk. By the end of this guide, you will have a clear understanding of how to add and configure an additional hard drive in Ubuntu.
1. Identifying the New Disk
The first step in adding an extra hard disk to your Ubuntu machine is to identify the new disk. You can do this by running the lsblk command in the terminal. This command will display a list of all the block devices currently connected to your machine, including the new disk.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 48M 1 loop /snap/canonical-livepatch/95
loop1 7:1 0 89.1M 1 loop /snap/core/9066
loop2 7:2 0 34.3M 1 loop /snap/gnome-calculator/406
loop3 7:3 0 43.2M 1 loop /snap/gtk-common-themes/1506
loop4 7:4 0 34.3M 1 loop /snap/gnome-calculator/460
loop5 7:5 0 2.3M 1 loop /snap/canonical-livepatch/98
loop6 7:6 0 44.4M 1 loop /snap/gnome-3-28-1804/110
loop7 7:7 0 14.5M 1 loop /snap/gnome-characters/296
loop8 7:8 0 4.3M 1 loop /snap/canonical-livepatch/93
loop9 7:9 0 31.1M 1 loop /snap/gnome-3-28-1804/145
loop10 7:10 0 31.1M 1 loop /snap/gnome-3-28-1804/142
loop11 7:11 0 31.1M 1 loop /snap/gnome-3-28-1804/140
loop12 7:12 0 31.1M 1 loop /snap/gnome-3-28-1804/139
loop13 7:13 0 31.1M 1 loop /snap/gnome-3-28-1804/138
loop14 7:14 0 31.1M 1 loop /snap/gnome-3-28-1804/137
loop15 7:15 0 31.1M 1 loop /snap/gnome-3-28-1804/136
loop16 7:16 0 31.1M 1 loop /snap/gnome-3-28-1804/135
loop17 7:17 0 31.1M 1 loop /snap/gnome-3-28-1804/134
loop18 7:18 0 31.1M 1 loop /snap/gnome-3-28-1804/133
loop19 7:19 0 31.1M 1 loop /snap/gnome-3-28-1804/132
loop20 7:20 0 31.1M 1 loop /snap/gnome-3-28-1804/131
loop21 7:21 0 31.1M 1 loop /snap/gnome-3-28-1804/130
loop22 7:22 0 31.1M 1 loop /snap/gnome-3-28-1804/129
loop23 7:23 0 31.1M 1 loop /snap/gnome-3-28-1804/128
loop24 7:24 0 31.1M 1 loop /snap/gnome-3-28-1804/127
loop25 7:25 0 31.1M 1 loop /snap/gnome-3-28-1804/126
loop26 7:26
In the output above, you can see that the new disk is named /dev/sdb and has a size of 3.7G. This is the disk that we will be adding to our Ubuntu machine.
2. Partitioning the New Disk
The next step in adding an extra hard disk to your Ubuntu machine is to partition the new disk. This can be done using the fdisk command. In the terminal, run the following command to partition the new disk:
$ sudo fdisk /dev/sdb
This will open the fdisk utility for the new disk. To create a new partition, enter the following commands:
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-7814037, default 2048):
Last sector, +sectors or +size{K,M,G} (2048-7814037, default 7814037): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB.
This will create a new primary partition with a size of 1G. To save the changes and exit the fdisk utility, enter the following command:
Command (m for help): w
This will write the changes to the new disk and exit the fdisk utility.
3. Formatting the New Partition
The next step in adding an extra hard disk to your Ubuntu machine is to format the new partition. This can be done using the mkfs command. In the terminal, run the following command to format the new partition:
$ sudo mkfs.ext4 /dev/sdb1
This will format the new partition as an ext4 filesystem.
4. Mounting the New Partition
The final step in adding an extra hard disk to your Ubuntu machine is to mount the new partition. This can be done by creating a new directory in the /mnt directory and mounting the new partition to that directory. In the terminal, run the following commands:
$ sudo mkdir /mnt/newdisk
$ sudo mount /dev/sdb1 /mnt/newdisk
This will mount the new partition to the /mnt/newdisk directory.
5. Verifying the New Partition
To verify that the new partition has been added to your Ubuntu machine, run the df command in the terminal. This will display a list of all the mounted filesystems on your machine, including the new partition:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 1634316 0 1634316 0% /dev
tmpfs 327680 932 326748 1% /run
/dev/sda1 3959783 1295156 2664627 33% /
tmpfs 1638400 0 1638400 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 1638400 0 1638400 0% /sys/fs/cgroup
/dev/loop0 49280 49280 0 100% /snap/canonical-livepatch/95
/dev/loop1 89152 89152 0 100% /snap/core/9066
/dev/loop2 34304 34304 0 100% /snap/gnome-calculator/406
/dev/loop3 43200 43200 0 100% /snap/gtk-common-themes/1506
/dev/loop4 34304 34304 0 100% /snap/gnome-calculator/460
/dev/loop5 2304 2304 0 100% /snap/canonical-livepatch/98
/dev/loop6 44416 44416 0 100% /snap/gnome-3-28-1804/110
/dev/loop7 14528 14528 0 100% /snap/gnome-characters/296
/dev/loop8 4352 4352 0 100% /snap/canonical-livepatch/93
/dev/loop9 31104 31104 0 100% /snap/gnome-3-28-1804/145
/dev/loop10 31104 31104 0 100% /snap/gnome-3-28-1804/142
/dev/loop11 31104 31104 0 100% /snap/gnome-3-28-1804/140
/dev/loop12 31104 31104 0 100% /snap/gnome-3-28-1804/139
/dev/loop13 31104 31104 0 100% /snap/gnome-3-28-1804/138
/dev/loop14 31104 31104 0 100% /snap/gnome-3-28-1804/137
/dev/loop15 31104 31104 0 100% /snap/gnome-3-28-1804/136
/dev/loop16 31104 31104 0 100% /snap/gnome-3-28-1804/135
/dev/loop17 31104 31104 0 100% /snap/gnome-3-28-1804/134
/dev/loop18 31104 31104 0 100% /snap/gnome-3-28-1804/133
/dev/loop19 31104 31104 0 100% /snap/gnome-3-28-1804/132
/dev/loop20 31104 31104 0 100% /snap/gnome-3-28-1804/131
/dev/loop21 31104 31104 0 100% /snap/gnome-3-28-1804/130
/dev/loop22 31104 31104 0 100% /snap/gnome-3-28-1804/129
/dev/loop23 31104 31104 0 100% /snap/gnome-3-28-1804/128
/dev/loop24 31104 31104 0 100% /snap/gnome-3-28-1804/127
/dev/loop25 31104 31104 0 100% /snap/gnome-3-28-1804/126
/dev/loop26 10240 10240 0 100% /snap/gnome-logs/61
/dev/loop27 34304 34304 0 100% /snap/gnome-calculator/448
/dev/sdb1 1048576 0 1048576 0% /mnt/newdisk
In the output above, you can see that the new partition is mounted to the /mnt/newdisk directory and has a size of 1G.
- To add an extra hard disk to your Ubuntu machine, first identify the new disk using the
lsblkcommand. - Partition the new disk using the
fdiskcommand. - Format the new partition using the
mkfscommand. - Mount the new partition to a directory in the
/mntdirectory. - Verify that the new partition has been added to your Ubuntu machine using the
dfcommand.