RHCSA Rapid Track
In this lab, you will create a physical volume, volume group, logical volume, and an XFS file system. You will also persistently mount the logical volume file system.
Outcomes
You should be able to:
Create physical volumes, volume groups, and logical volumes with LVM tools.
Create new file systems on logical volumes and persistently mount them.
Log in as the student user on workstation using student as the password.
On workstation, run the lab lvm-creating start command.
This command runs a start script that determines if the servera machine is reachable on the network.
It also verifies that storage is available and that the appropriate software packages are installed.
[student@workstation ~]$lab lvm-creating start
Use the
sshcommand to log in toserveraas thestudentuser. 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 -icommand to switch to therootuser. The password for thestudentuser isstudent.[student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Create the physical resources on the
/dev/vdbdevice.Use
partedto create two 256 MiB partitions and set them to type Linux LVM.[root@servera ~]#parted -s /dev/vdb mklabel gpt[root@servera ~]#parted -s /dev/vdb mkpart primary 1MiB 257MiB[root@servera ~]#parted -s /dev/vdb set 1 lvm on[root@servera ~]#parted -s /dev/vdb mkpart primary 258MiB 514MiB[root@servera ~]#parted -s /dev/vdb set 2 lvm onUse
udevadm settlefor the system to register the new partitions.[root@servera ~]#udevadm settle
Use
pvcreateto add the two new partitions as PVs.[root@servera ~]#pvcreate /dev/vdb1 /dev/vdb2Physical volume "/dev/vdb1" successfully created. Physical volume "/dev/vdb2" successfully created.Use
vgcreateto create a new VG namedservera_01_vgbuilt from the two PVs.[root@servera ~]#vgcreate servera_01_vg /dev/vdb1 /dev/vdb2Volume group "servera_01_vg" successfully createdUse
lvcreateto create a 400 MiB LV namedservera_01_lvfrom theservera_01_vgVG.[root@servera ~]#lvcreate -n servera_01_lv -L 400M servera_01_vgLogical volume "servera_01_lv" created.This creates a device named
/dev/servera_01_vg/servera_01_lvbut without a file system on it.Add a persistent file system.
Add an
XFSfile system on theservera_01_lvLV with themkfscommand.[root@servera ~]#mkfs -t xfs /dev/servera_01_vg/servera_01_lv...output omitted...Create a mount point at
/data.[root@servera ~]#mkdir /dataAdd the following line to the end of
/etc/fstabonservera:/dev/servera_01_vg/servera_01_lv /data xfs defaults 1 2
Use
systemctl daemon-reloadto updatesystemdwith the new/etc/fstabconfiguration.[root@servera ~]#systemctl daemon-reloadVerify the
/etc/fstabentry and mount the newservera_01_lvLV device with themountcommand.[root@servera ~]#mount /data
Test and review your work.
As a final test, copy some files to
/dataand verify how many were copied.[root@servera ~]#cp -a /etc/*.conf /data[root@servera ~]#ls /data | wc -l34You will verify that you still have the same number of files in the next guided exercise.
parted /dev/vdb printlists the partitions that exist 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: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 269MB 268MB primary lvm 2 271MB 539MB 268MB primary lvmNotice the
Numbercolumn, which contains the values1and2. These correspond to/dev/vdb1and/dev/vdb2, respectively. Also notice theFlagscolumn, which indicates the partition type.pvdisplaydisplays information about each of the physical volumes. Optionally, include the device name to limit details to a specific PV.[root@servera ~]#pvdisplay /dev/vdb2--- Physical volume --- PV Name /dev/vdb2 VG Name servera_01_vg PV Size 256.00 MiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 63 Free PE 26 Allocated PE 37 PV UUID 2z0Cf3-99YI-w9ny-alEW-wWhL-S8RJ-M2rfZkThis shows that the PV is allocated to VG
servera_01_vg, is 256 MiB in size (although 4 MiB is not usable), and the physical extent size (PE Size) is 4 MiB (the smallest allocatable LV size).There are 63 PEs, of which 26 are free for allocation to LVs in the future and 37 are currently allocated to LVs. These translate to MiB values as follows:
Total 252 MiB (63 PEs x 4 MiB); remember, 4 MiB is unusable.
Free 104 MiB (26 PEs x 4 MiB)
Allocated 148 MiB (37 PEs x 4 MiB)
vgdisplayshows information about the volume group namedvgnamevgname.[root@servera ~]#vgdisplay servera_01_vgVerify the following values:
VG Sizeis504.00MiB.Total PEis126.Alloc PE / Sizeis100 / 400.00MiB.Free PE / Sizeis26 / 104.00MiB.
lvdisplay /dev/displays information about the logical volume namedvgname/lvnamelvname.[root@servera ~]#lvdisplay /dev/servera_01_vg/servera_01_lvReview the
LV Path,LV Name,VG Name,LV Status,LV Size, andCurrent LE(logical extents, which map to physical extents).The
mountcommand shows all mounted devices and any mount options. It should include/dev/servera_01_vg/servera_01_lv.Note
Many tools report the device mapper name instead,
/dev/mapper/servera_01_vg-servera_01_lv; it is the same logical volume.[root@servera ~]#mountYou should see (probably on the last line)
/dev/mapper/servera_01_vg-servera_01_lvmounted on/dataand the associated mount information.df -hdisplays human-readable disk free space. Optionally, include the mount point to limit details to that file system.[root@servera ~]#df -h /dataFilesystem Size Used Avail Use% Mounted on /dev/mapper/servera_01_vg-servera_01_lv 395M 24M 372M 6% /dataAllowing for file-system metadata, these values are expected.
Log off from
servera.[root@servera ~]#exitlogout[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$