Adding a New Hard Disk to a Linux System

Get Started
30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Linux system administrators need to know how to add a new disk drive to a system, create a file system on that drive, and have it permanently mounted via the `/etc/fstab` file. This exercise will assist you in your practice of creating a new file system and mounting the file system to a directory, and configuring the system so that this mount persists across reboots.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a New Partition

Run the lsblk command to verify that you have a /dev/nvme1n1 device available. Once confirmed, create a partition on the /dev/nvme1n1 disk using fdisk (note you will need to run sudo for these commands) that uses the entire disk:

 lsblk
 sudo fdisk /dev/nvme1n1
Create the File System

Create a new XFS file system on this partition with the mkfs.xfs command. Once that is complete, run the blkid command on the newly created partition to obtain the UUID. Make a note of this UUID:

 sudo mkfs.xfs /dev/nvme1n1p1
 sudo blkid /dev/nvme1n1p1
Mount the new File System and Make it Permanent

Edit the /etc/fstab file and create a new entry at the bottom for your new disk. The format should follow the following (be sure to use your disk’s UUID from the previous step):

UUID=YOURUUID /opt xfs defaults 0 0

Save and close the file, then run the sudo mount -a command to mount your new partition.
A df -h /opt command should show you roughly 5GB available for the /opt directory.

Additional Resources

You are running a test server whose sole purpose is for trying out new software. Through the virtual machine GUI interface, you have added a new 5GB disk image file that you will need to mount at /opt. This will be the directory that you will run all of your new test software from. This drive should contain one MBR partition. You will need to create an XFS file system on this drive, and have it mount permanently to the /opt directory. Once you have completed this task, hand the system over to your teammate to verify your work.

NOTE: In the lab, you will now be provided a block device of /dev/nvme1n1 (instead of /dev/xvdg) to create the partition nvme1n1p1.

To save in vim, use: :wq!

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?