Skip to main content

Command Palette

Search for a command to run...

Linux Hands-On Lab - Adding a New Hard Disk to a Linux System

Linux Learning Path for Cloud and DevOps Engineers

Published
3 min read
Linux Hands-On Lab - Adding a New Hard Disk to a Linux System
F

I have over 20 years of experience in IT Infrastructure and currently work at Microsoft as an Azure Kubernetes Support Engineer, where I support and manage the AKS, ACI, ACR, and ARO tools. Previously, I worked as a Fault Management Cloud Engineer at Nokia for 2.9 years, with expertise in OpenStack, Linux, Zabbix, Commvault, and other tools. In this role, I resolved critical technical incidents, ensured consistent uptime, and safeguarded against revenue loss from customers. Additionally, I briefly served as a Technical Team Lead for 3 months, where I distributed tasks, mentored a new team member, and managed technical requests and activities raised by our customers. Previously, I worked as an IT System Administrator at BN Paribas Cardif Portugal and other significant companies in Brazil, including an affiliate of Rede Globo Television (Rede Bahia) and Petrobras SA. In these roles, I developed a robust skill set, acquired the ability to adapt to new processes, demonstrated excellent problem-solving and analytical skills, and managed ticket systems to enhance the customer service experience.

My ability to thrive in high-pressure environments and meet tight deadlines is a testament to my organizational and proactive approach. By collaborating with colleagues and other teams, I ensure robust support and incident management, contributing to the consistent satisfaction of my customers and the reliability of the entire IT Infrastructure.

📝Introduction

A Linux system administrator must know how to add a new disk drive, create a file system on that drive, and have it permanently mounted in a file. So, this lab will assist in creating a new filesystem, mounting the filesystem to a directory, and configuring the system so the mount persists across reboots.

These are the objectives of this lab:

  • Create a GPG Key for a specific user

  • Configure GPG for another specific user

  • Generate a Signed Document and Send It to a specific user

  • Verify the Signature of the Emailed Document

  • Decrypt the Attached File

📝Log in to the AWS Management Console

Using your credentials, make sure you're using the right Region. In my case, I am using AWS as my cloud provider and chose us-east-1. However, you can choose any cloud provider and create your Linux Server VM (I am using a CentOS 7 distro) for this hands-on lab.

📌Note: You must create the AWS Access Key and AWS Secret Access Key and configure the AWS CLI in the terminal to use it.

You can use link1 and link2 for it.

📝Create a New Partition

Let's run the lsblk command to verify we have any disk device available. Once we've confirmed that, we'll create a partition on the /dev/xxxxx disk using fdisk. Note that we'll need to preface these commands with sudo for these commands. This partition we create will span the entire disk:

lsblk
sudo fdisk /dev/<disk>

After running fdisk, we'll have to perform a few tasks.

At the Command (m for help): command, type n to make a new partition, then hit Enter. Our Partition type will be p, primary. Press Enter for Partition number, the First sector, and the Last sector options. This will make fdisk ready to create the partition. Type p at the Command (m for help): to print out what the disk will look like after we commit our changes. If that all looks good, type w and press Enter to write our changes to disk.

📝Create the Filesystem

Next, we've got to create a filesystem, so we can read and write data. We'll format the partition to the XFS file system with the mkfs.xfs command. Once that is complete, we'll run blkid on the newly created partition to obtain the UUID. We'll have to make a note of this UUID, since we're going to need it later:

sudo mkfs.xfs /dev/<disk>
sudo blkid /dev/<disk>

📝Mount the New Filesystem and Make It Permanent

We can mount this partition up manually with the mount command, but it won't be a persistent mount; it won't get mounted after something like a reboot.

We're going to edit /etc/fstab and create a new entry for the new disk at the bottom.

sudo vi /etc/fstab

When you want to add text: hit the esc key and then i to go into insert mode type as normal.

When you want to save: hit the esc key and then :wq!

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

We can save the file (:wq!), Then run:

sudo mount -a

This will mount everything that's listed in fstab, including our new partition.

And running a quick df -h /opt should show us the disk space available for the /opt directory.

📌Note - At the end of each hands-on Lab, always clean up all the resources previously created to avoid being charged if you used a Cloud Provider to provision them.

Congratulations — you have completed this hands-on lab covering the basics of Adding a New Hard Disk to a Linux System.

Thank you for reading. I hope you understood and learned something helpful from my blog.

Please follow me on CloudDevOpsToLearn and LinkedIn, franciscojblsouza