In this exercise, you will create a partition on a new storage device, format it with an XFS file system, configure it to be mounted at boot, and mount it for use.
Outcomes
You should be able to use parted, mkfs.xfs, and other commands to create a partition on a new disk, format it, and persistently mount it.
Log in as the student user on workstation using student as the password.
On workstation, run the lab storage-partitions start command.
This command runs a start script that determines if the servera machine is reachable on the network.
It also prepares the second disk on servera for the exercise.
[student@workstation ~]$lab storage-partitions start
Use the ssh command to log in to servera as the student user.
The systems are configured to use SSH keys for authentication, therefore a password is not required.
[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$
Use the sudo -i command to switch to the root user.
If prompted, use student as the password.
[student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Use parted to create a new disk label of type msdos on the /dev/vdb disk to prepare that new disk for the MBR partitioning scheme.
[root@servera ~]#parted /dev/vdb mklabel msdosInformation: You may need to update /etc/fstab.
Add a new primary partition that is 1 GB in size. For proper alignment, start the partition at the sector 2048. Set the partition file system type to XFS.
Use parted interactive mode to help you create the partition.
[root@servera ~]#parted /dev/vdbGNU Parted 3.2 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 sector 2048, the previous command sets the end position to 1001MB to get a partition size of 1000MB (1 GB).
As an alternative, you can perform the same operation with the following noninteractive command: parted /dev/vdb mkpart primary xfs 2048s 1001MB
Verify your work by listing the partitions on /dev/vdb.
[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 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 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=0
Configure the new file system to mount at /archive persistently.
Use mkdir to create the /archive directory mount point.
[root@servera ~]#mkdir /archive
Use the lsblk command with the --fs option to discover the UUID of the /dev/vdb1 device.
[root@servera ~]#lsblk --fs /dev/vdbNAME FSTYPE LABEL UUID MOUNTPOINT vdb └─vdb1 xfse3db1abe-6d96-4faa-a213-b96a6f85dcc1
The UUID in the previous output is probably different on your system.
Add an entry to /etc/fstab.
In the following content, replace the UUID with the one you discovered from the previous step.
...output omitted...
UUID=e3db1abe-6d96-4faa-a213-b96a6f85dcc1 /archive xfs defaults 0 0
Update systemd for the system to register the new /etc/fstab configuration.
[root@servera ~]#systemctl daemon-reload
Execute the mount /archive command to mount the new file system using the new entry added to /etc/fstab.
[root@servera ~]#mount /archive
Verify that the new file system is mounted at /archive.
[root@servera ~]#mount | grep /archive/dev/vdb1 on /archive type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
Reboot servera.
After the server has rebooted, log in and verify that /dev/vdb1 is mounted at /archive.
When done, log off from servera.
Reboot servera.
[root@servera ~]#systemctl rebootConnection to servera closed by remote host. Connection to servera closed.[student@workstation ~]$
Wait a few minutes for servera to reboot and log in as the student user.
[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$
Verify that /dev/vdb1 is mounted at /archive.
[student@servera ~]$mount | grep /archive/dev/vdb1 on /archive type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
Log off from servera.
[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$