KB 227031 - Adding a Secondary Drive to Linux

KB 227031 - Adding a Secondary Drive to Linux


In Windows, A secondary drive will simply show, up as Local Disk (D:), after initiation. This guide will cover how to achieve the same in any Linux Installation.

Create a mount folder

Usually, external drives are mounted inside the /mnt or /media folder. to create a folder or mount point, you can run:

sudo mkdir /mnt/salman

Mount the drive manually

Fist you need to find the drive you are looking to mount:

Run:

sudo fdisk -l

Or:

lsblk

to get a list of disks or block devices in the system, identify your drive and not down its path (usually /dev/sdX)

Now, you can run the following command to mount the drive:

sudo mount /dev/sdX /mnt/salman

this mounts the drive at the folder we created earlier, now you can access the drive until you shut down or remove the drive. to unmount you can use the umount command instead.

Auto-mount the drive at boot

Find the UUID of the partition

To get the UUID of desired partition, run:

sudo blkid

This would show a list of partitions with their labels and UUID. 

You can identify a partition by its Label. Or use lsblk to identify the partition by its size. Note down the UUID of desired partition.

Create an fstab entry

Open the fstab file in your preferred text editor:

sudo nano /etc/fstab

Add this line to the end:

UUID=<your_uuid> /mnt/salman ext4 defaults 0 0

Note: Make sure to replace the data with the right value for your situation. the elements are:

<UUID or Label>  <Mount point>  <File system type>  <Mount options>  <fs_freq>  <fs_passno>