How to Mount a New Storage Drive in Linux

Mounting a new storage drive in Linux is a straightforward administrative task that involves detecting the disk, preparing a filesystem, creating a target directory, and attaching the drive to the Linux directory tree. This guide provides a direct, step-by-step walkthrough for identifying an attached drive, formatting it if necessary, mounting it for immediate use, and configuring the system to mount it automatically on every boot.

1. Identify the New Storage Drive

Connect the drive to your system, open a terminal, and list the available block devices to identify the drive's system name:

lsblk

Locate your new drive in the output (commonly labeled as /dev/sdb, /dev/sdc, or /dev/nvme1n1). Note the device name and verify that it does not contain a partition or mount point already in use.

2. Partition and Format the Drive

If the drive is brand new and unformatted, you must create a partition and file system.

To create a partition using fdisk:

sudo fdisk /dev/sdb

Type n to create a new partition, accept the default values by pressing Enter through the prompts, and type w to write the changes to the disk.

Next, format the newly created partition (e.g., /dev/sdb1) with the standard ext4 filesystem:

sudo mkfs.ext4 /dev/sdb1

3. Create a Mount Point

A mount point is an empty directory where the drive’s contents will be accessed. Create a directory inside /mnt or /media:

sudo mkdir -p /mnt/storage

4. Mount the Drive Manually

Attach the drive to the mount point directory:

sudo mount /dev/sdb1 /mnt/storage

Verify that the drive is mounted and check available space:

df -h /mnt/storage

5. Configure Persistent Mounting on Boot

Manual mounts do not persist after a system restart. To make the mount permanent, configure the /etc/fstab file using the drive's Universally Unique Identifier (UUID).

Find the UUID of your partition:

sudo blkid /dev/sdb1

Copy the UUID="..." value from the output (excluding the quotes).

Open the /etc/fstab file in a text editor:

sudo nano /etc/fstab

Add the following line at the end of the file, replacing the placeholder with your actual UUID:

UUID=your-uuid-here /mnt/storage ext4 defaults 0 2

Save and exit the editor. Test the configuration to ensure there are no syntax errors before rebooting:

sudo mount -a

If no errors are returned, the storage drive is properly configured and will mount automatically on every system startup.