Preface on preexisting partition layout
All that is written below assumes that your additional hard drive has one single partition and is formatted ext4 (Ubuntu default). We also assume that the existing hard drive device name is
/dev/sda containing at least partitions
sda1 for root and
sda2 for swap.
List all partitions with this command in a terminal (
sudo will ask for your password that you will have to type blindly):
sudo fdisk -l
Disk /dev/sda: 55,9 GiB, 60022480896 bytes, 117231408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0001fb85
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 117229567 117227520 55,9G 83 Linux
Disk /dev/sdb: 2,7 TiB, 3000592982016 bytes, 5860533168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: DA1A0C2A-06C2-4648-85BF-720E005BD5BD
Device Start End Sectors Size Type
/dev/sdb1 81920000 5860532223 5778612224 2,7T Linux filesystem
In the above example disk
/dev/sda holds one partition
/dev/sdb holds one partition
/dev/sdb1 (my swap is on another hard disk).
Check here whether partition
/dev/sdb1 really is from the new drive.
Create a mount point for the new drive
We can give any name for the directory (mount point) or subdirectory that holds the new drive but we should avoid a name that already exists (or may exist later). Below is only an example, choose whatever best suits your layout.
For now let's choose a simple name
data1 and let it mount to
/data1. In your terminal give in the following command:
sudo mkdir /data1
First unmount the new hard drive then mount it (presumably
/dev/sdb1) to the new mountpoint to see that all is as expected:
sudo mount /dev/sdb1 /data1
sudo chmod 755 /data1 ## make sensible permissions
cd /data1 ## change to the mount directory
ls -a ## list content of the new hard drive
If all is OK we can unmount the drive with
sudo umount /dev/sdb1
More information on mount and mountpoints:
Get the UUID of the new hard drive partition
Any partition of any hard drive will have a unique number called UUID (Universally Unique Identifier). So your old hard drive will have a UUID and your new drive will have another. This UUID will be used later to make sure it is the correct partition we mount. To list the UUIDs of attached drives issue:
In the resulting list you will find the device name of each registered partition, and it's UUID (you may not have a LABEL).
/dev/sda1: LABEL="ROOT" UUID="ede85c57-e919-4e1f-be24-f8bae5dbb500" TYPE="ext4" PARTUUID="0001fb85-01"
/dev/sdb1: LABEL="BIGSHARE" UUID="c3fa201e-f00b-4959-ae27-4a947d7c2584" TYPE="ext4" PARTUUID="a2617ede-6bd2-40c1-8f4c-2a28a0c839af"
Copy the UUID of the new drive (above that would be
c3fa201e-f... yours will be different) for being able to paste it later.
Edit fstab to add the new drive
We have a configuration file
/etc/fstab where all partitions are listed that will be mounted at boot.
Let us first make a backup of that file to be able to revert changes:
sudo cp /etc/fstab /etc/fstab.bak
Then add a new partition by editing this file as root:
sudo nano /etc/fstab
At the bottom of that file add a line similar to this:
UUID=<paste number copied from above> /data1 ext4 defaults 0 2
Write the file with Ctrl + O then Return. Quit the editor with Ctrl + X.
Detailed information on fstab: Ubuntu Community Wiki
To see if the drive is mounted correctly we can simulate the mount process at boot with
sudo mount -a
All files of the new hard drive can now be seen in
/data1 and they will still be there on the next reboot.
Want to move all HOME to the new drive?
We may want to move all of the HOME directory to that new drive. To do so see my answer to the following question:
For an alternative approach see: How to mount a new drive on startup