Mounting Disk Drives to Centos/RHEL/Amazon Linux

Just a short step by step guide to add extra disk drives to Centos/RHEL/Amazon Linux. Applicable for when you add extra EBS to an AWS instance, but also useful for adding drives to any RHEL family of hosts. See here for official AWS documentation this was originally from.

While logged onto the server, perform the following steps:

Step 1: Find the drive name using lsblk:
lsblk

In my case it was nvme1n1

Step 2: Format the drive into something usable:
sudo mkfs -t xfs /dev/nvme1n1
Step 3: Make a data directory that we can mount to:
sudo mkdir /data
Step 4: Mount the drive onto the data directory:
sudo mount /dev/nvme1n1 /data

Now that it is mounted, we want to ensure it is mounted every time we start the OS.

Step 5: Find the ID of the drive using blkid:
sudo blkid

You should get something like this, with a UUID, thats what we want:

/dev/nvme1n1: UUID="388a99ed-9386-4a46-aeb6-06eaf6c87695" TYPE="xfs"
Step 6: Copy the fstab file and edit it:
sudo cp /etc/fstab /etc/fstab.bak

sudo vim /etc/fstab
Step 7: Add the UUID to fstab:
UUID=388a99ed-9386-4a46-aeb6-06eaf6c87695  /data  xfs  defaults,nofail  0  2

Ensure you change the UUID to the one you got from the blkid command

Step 8: Test that the fstab config is correct by unmounting and remounting:
sudo umount /data

sudo mount -a
Step 9: Verify you disk is now usable:
df -h

You should see your new disk mounted to /data with the correct size. Something like this:

Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        461M     0  461M   0% /dev
tmpfs           484M     0  484M   0% /dev/shm
tmpfs           484M   13M  471M   3% /run
tmpfs           484M     0  484M   0% /sys/fs/cgroup
/dev/nvme0n1p1  8.0G  2.2G  5.9G  27% /
tmpfs            97M     0   97M   0% /run/user/1000
/dev/nvme1n1     10G   33M   10G   1% /data

And that’s it, you should now have a new drive mounted and ready to go whenever you start the server.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s