RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this exercise, you create a partition on a new storage device, format it with an XFS file system, configure it to mount at boot, and mount it for use.
Outcomes
Use the
parted,mkfs.xfs, and other commands to create a partition on a new disk, format it, and persistently mount it.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start storage-partitions
Instructions
Log in to
serveraas thestudentuser and switch to therootuser.student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Create an
msdosdisk label on the/dev/vdbdevice.[root@servera ~]#
parted /dev/vdb mklabel msdosInformation: You may need to update /etc/fstab.Add a 1 GB primary partition. For correct alignment, start the partition at the 2048 sector. Set the partition file-system type to XFS.
Use
partedinteractive mode to create the partition.[root@servera ~]#
parted /dev/vdbGNU Parted 3.4 Using /dev/vdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)mkpartPartition type? primary/extended?primaryFile system type? [ext2]?xfsStart?2048sEnd?1001MB(parted)quitInformation: You may need to update /etc/fstab.Because the partition starts at the 2048 sector, the previous command sets the end position to 1001 MB to get a partition size of 1000 MB (1 GB).
Alternatively, you can perform the same operation with the following non-interactive command:
parted /dev/vdb mkpart primary xfs 2048s 1001 MBVerify your work by listing the partitions on the
/dev/vdbdevice.[root@servera ~]#
parted /dev/vdb printModel: Virtio Block Device (virtblk) Disk /dev/vdb: 5369MB Sector size (logical/physical): 512B/512B Partition Table:msdosDisk Flags: Number Start End Size Type File system Flags 1 1049kB 1001MB1000MB primaryRun the
udevadm settlecommand. This command waits for the system to register the new partition, and returns when it is done.[root@servera ~]#
udevadm settle
Format the new partition with the XFS file system.
[root@servera ~]#
mkfs.xfs /dev/vdb1meta-data=/dev/vdb1 isize=512 agcount=4, agsize=61056 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=1 inobtcount=1 data = bsize=4096 blocks=244224, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1566, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0Configure the new file system to mount to the
/archivedirectory persistently.Create the
/archivedirectory.[root@servera ~]#
mkdir /archiveDiscover the UUID of the
/dev/vdb1device. The UUID in the output is probably different on your system.[root@servera ~]#
lsblk --fs /dev/vdbNAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS vdb └─vdb1 xfs881e856c-37b1-41e3-b009-ad526e46d987Add an entry to the
/etc/fstabfile. Replace the UUID with the one that you discovered from the previous step....output omitted... UUID=
881e856c-37b1-41e3-b009-ad526e46d987/archive xfs defaults 0 0Update the
systemddaemon for the system to register the new/etc/fstabfile configuration.[root@servera ~]#
systemctl daemon-reloadMount the new file system with the new entry in the
/etc/fstabfile.[root@servera ~]#
mount /archiveVerify that the new file system is mounted on the
/archivedirectory.[root@servera ~]#
mount | grep /archive/dev/vdb1 on /archive type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
Reboot
servera. After the server rebooted, log in and verify that the/dev/vdb1device is mounted on the/archivedirectory. When done, log out fromservera.Reboot
servera.[root@servera ~]#
systemctl rebootConnection to servera closed by remote host. Connection to servera closed. [student@workstation ~]$Wait for
serverato reboot and log in as thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$Verify that the
/dev/vdb1device is mounted on the/archivedirectory.[student@servera ~]$
mount | grep /archive/dev/vdb1 on /archive type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)Return to the
workstationmachine as thestudentuser.[student@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.