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 servera as the student user and switch to the root user.
student@workstation ~]$ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Create an msdos disk label on the /dev/vdb device.
[root@servera ~]# parted /dev/vdb mklabel msdos
Information: 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 parted interactive 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 MB
Verify your work by listing the partitions on the /dev/vdb device.
[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 primary
Run the udevadm settle command.
This command waits for the system to register the new partition, and returns when it is done.
[root@servera ~]# udevadm settleFormat the new partition with the XFS file system.
[root@servera ~]# mkfs.xfs /dev/vdb1
meta-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 /archive directory persistently.
Create the /archive directory.
[root@servera ~]# mkdir /archiveDiscover the UUID of the /dev/vdb1 device.
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-ad526e46d987
Add an entry to the /etc/fstab file.
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 systemd daemon for the system to register the new /etc/fstab file configuration.
[root@servera ~]# systemctl daemon-reloadMount the new file system with the new entry in the /etc/fstab file.
[root@servera ~]# mount /archiveVerify that the new file system is mounted on the /archive directory.
[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/vdb1 device is mounted on the /archive directory.
When done, log out from servera.
Reboot servera.
[root@servera ~]# systemctl reboot
Connection to servera closed by remote host.
Connection to servera closed.
[student@workstation ~]$Wait for servera to reboot and log in as the student user.
[student@workstation ~]$ ssh student@servera
...output omitted...
[student@servera ~]$Verify that the /dev/vdb1 device is mounted on the /archive directory.
[student@servera ~]$ mount | grep /archive
/dev/vdb1 on /archive type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)Return to the workstation machine as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$This concludes the section.