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.
*This course is not approved or sponsored by Red Hat.*
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a 2 GB GPT Partition
Create the partition:
gdisk /dev/nvme1n1
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/nvme2n1
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 persistently
Format the partition:
mkfs.xfs /dev/nvme1n1p1
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
:mount -a
- Format the MBR Partition with ext4 and Mount the Device.
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.
Mount the disk:
mount /dev/nvme2n1p1 /mnt/mbrext4