[How-To] Mount and Use a New Drive in Ubuntu
Purpose
This is a general purpose doc aimed at solving for additional drives being mounted in Ubuntu and then this doc explaining how to find, mount, and use them.
Prerequisites
List of prerequisites:
- Sudo user
- Ubuntu Operating System
Mounting and Using New Drive
Step 1: Verify New Storage Availability
Before we can do anything with the new storage device, we need to verify that it is available. This is what you would do after installing an additional hard drive in a server, or adding a virtual hard drive to a VM. You can check the available physical storage devices with the below command:
lsblk
Or you could use this:
fdisk -l
Likely what you are looking for in Ubuntu if you only have the OS drive, is something at the bottom of the list like /dev/sdb. This is your new drive.
If you only see your singular OS drive or you don't see the new drive you added, do not proceed as the Operating System can't see the new drive.
Step 2: Format and Mount the Disk in Ubuntu
Assuming your disk device is /dev/sdb (replace with your actual device), partition and format the disk assuming its new and blank:
sudo parted /dev/sdb -- mklabel gpt
sudo parted -a optimal /dev/sdb mkpart primary ext4 0% 100%
sudo mkfs.ext4 /dev/sdb1
Then, create a mount point:
sudo mkdir -p /mnt/immich/photos
Next, mount the disk:
sudo mount /dev/sdb1 /mnt/immich/photos
Finally, check for successful mounting:
df -h | grep /mnt/immich/photos
If you don't see the correct size of the new drive, it didn't work. Revisit steps and try again.
Step 3: Make Mount Permanent in FStab
Get the UUID of the partition:
sudo blkid /dev/sdb1
Edit /etc/fstab
:
sudo nano /etc/fstab
Add a line like:
UUID=your-uuid-from-blkid /mnt/immich/photos ext4 defaults 0 2
Save and Exit. Now, update the daemon:
sudo systemctl daemon-reload
Then, unmount and remount:
sudo umount /mnt/immich/photos
sudo mount -a
Finally, run your check command again and verify you have the correct drive size showing:
df -h | grep /mnt/immich/photos
You have successfully formatted, partitioned, and mounted a new drive for use in Ubuntu.