Linux Hands-On Lab - Storage Management
Linux Learning Path for Cloud and DevOps Engineers
📝Introduction
In this lab, we’re going to go over managing and formatting partitions. Having a solid understanding of how to use these tools is a fundamental component of a Linux sysadmin career.
These are the objectives of this lab:
Create a 2 GB GPT Partition
Create a 2 GB MBR Partition
Format the GPT Partition with XFS and Mount the Device persistently
Format the MBR Partition with ext4 and Mount the Device.
📝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 2 GB GPT Partition
📌Note: You must create it for free extra disks available in your VM.
On this link, you can check the differences between GPT and MBR partitions in OS.
Switch to root
user and create the partition:
sudo -i
gdisk /dev/<disk>
Enter n
to create a new partition.
Accept the default for the partition number.
Accept the default for the starting sector.
For the ending sector, enter +2G
to create a 2 GB partition.
Accept the default partition type.
Enter w
to write the partition information.
Enter y
to proceed.
Finalize the settings:
partprobe
📝Create a 2 GB MBR Partition
Create the partition:
fdisk /dev/<disk>
Enter n
to create a new partition.
Accept the default partition type.
Accept the default for the partition number.
Accept the default for the starting sector.
For the ending sector, type +2G
to create a 2 GB partition.
Enter w
to write the partition information.
Finalize the settings:
partprobe
📝Format the GPT Partition with XFS and Mount the Device on /mnt/gptxfs
Persistently
Format the partition:
mkfs.xfs /dev/<disk>
Getting It Ready for Mounting
Run the following:
blkid
Copy the UUID of the partition at /dev/nvme1n1p1
.
Open the /etc/fstab
file:
vim /etc/fstab
Add the following, replacing <UUID>
with the UUID you just copied:
UUID="<UUID>" /mnt/gptxfs xfs defaults 0 0
Save and exit the file by pressing Escape followed by :wq
.
Create a Mount Point
Create the mount point we specified in fstab
:
mkdir /mnt/gptxfs
Mount everything that's described in fstab
and check that it's mounted:
mount -a
mount
The partition should be listed in the output.
Format the MBR Partition with ext4 and Mount the Device on /mnt/mbrext4
Format the partition:
mkfs.ext4 /dev/nvme2n1p1
Create a Mount Point
Create the mount point:
mkdir /mnt/mbrext4
Mount it:
mount /dev/nvme2n1p1 /mnt/mbrext4
Check that it's mounted:
mount
The partition should be listed in the output.
📌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 managing and formatting partitions in Linux.
Thank you for reading. I hope you understood and learned something helpful from my blog.
Please follow me on CloudDevOpsToLearn and LinkedIn, franciscojblsouza