(RHCSA) Configure Local Storage

This is part of the RHCSA Exam Study Guide series

image

This is part of the independent and unofficial RHCSA Exam Study Guide series providing free πŸ€‘ resources to prepare for the exam.

This post covers the objectives under the section:

“CONFIGURE LOCAL STORAGE”

It contains two main parts:

  • Resources: with links to learn and practice for each objective.
  • Cheatsheet: containing some examples of commands and actions performed in each objective (when applied).

πŸ“š Resources:

Attention: You must add more virtual disks to the RHEL virtual machine in order to practice for this objective.

LIST, CREATE, DELETE PARTITIONS ON MBR AND GPT DISKS
CREATE AND REMOVE PHYSICAL VOLUMES / ASSIGN PHYSICAL VOLUMES TO VOLUME GROUPS / CREATE AND DELETE LOGICAL VOLUMES
CONFIGURE SYSTEMS TO MOUNT FILE SYSTEMS AT BOOT BY UNIVERSALLY UNIQUE ID (UUID) OR LABEL
ADD NEW PARTITIONS AND LOGICAL VOLUMES, AND SWAP TO A SYSTEM NON-DESTRUCTIVELY

πŸ“‘ Cheatsheet:

LIST, CREATE, DELETE PARTITIONS ON MBR AND GPT DISKS
  • lsblk ➑ list block devices.

  • parted /dev/vdb mklabel msdos ➑ label a new disk as msdos.

  • parted /dev/vdb print ➑ display disk info.

  • parted /dev/vdb mkpart primary 1 101m ➑ create a new primary partition on disk, with size of 100mb.

  • parted /dev/vdb rm 1 ➑ remove partition 1.

  • gdisk /dev/vdc ➑ create/modify partitions on disk using gdisk.

  • partprobe ➑ inform the OS of partition table changes.

  • wipefs --all /dev/vdg ➑ wipe any partition table, fs, RAID signatures from block device.

CREATE AND REMOVE PHYSICAL VOLUMES / ASSIGN PHYSICAL VOLUMES TO VOLUME GROUPS / CREATE AND DELETE LOGICAL VOLUMES
  • vgs, pvs, lvs ➑ list volume groups, physical volumes and logical volumes.

  • pvcreate /dev/vdc ➑ initialize physical volume to use in LVM.

  • pvremove /dev/vdb /dev/vdc ➑ uninitialize physical volumes.

  • vgcreate vg100 /dev/vdb -s 16M ➑ create volume group using /dev/vdb physical volume, with PE size of 16MB.

  • vgdisplay vg100 ➑ check vg100 attributes.

  • vgextend vg100 /dev/vdc ➑ extend volume gropup adding a new physical volume.

  • vgremove vg100 ➑ remove volume group.

  • lvcreate -L 100M vg100 -n lvol0 ➑ create logical volume lvol0 on vg100 with 100MB of size.

  • lvextend -L +200M /dev/vg100/lvol0 ➑ expand logical volume size.

  • lvextend -r -L +80M /dev/vg200/lv200 ➑ extend local volume and its file system.

  • lvreduce -L -252M /dev/vg100/lvol0 ➑ reduce logical volume size.

  • lvremove /dev/vg100/lvol0 ➑ remove logical volume.

CONFIGURE SYSTEMS TO MOUNT FILE SYSTEMS AT BOOT BY UNIVERSALLY UNIQUE ID (UUID) OR LABEL
  • blkid ➑ locate/print block devices attributes (ex.: UUID).

  • df -h ➑ show file distem disk usage.

  • du -sh /usr/bin ➑ show dir disk usage.

  • du -sc /etc /usr/bin ➑ show disk usage for each dir and the sum of both.

  • lsblk -f ➑ list block devices, show file system type and UUID.

  • mkfs.vfat /dev/sdd1 ➑ initialize the partition with the VFAT filesystem type.

  • /etc/fstab example entries:

    • UUID=3C65-A634 /vfatfs5 vfat defaults 0 0
    • UUID=7eaf462a-ecd2-4d09-91d0-09bdba6fa491 /ext4fs5 ext4 defaults 0 0
    • UUID=d9cdb722-ad2d-4d2c-901d-d274950ccc55 /xfsfs5 xfs defaults 0 0
    • /dev/mapper/vdo5 /vdofs5 xfs _netdev-systemd.requires=vdo.service 0 0
    • /dev/vg200/lv200 /lvmfs5 ext4 defaults 0 0
    • /dev/vg200/lv300 /lvmfs6 xfs defaults 0 0
    • UUID=a30f9774-a11d-4a01-ad87-4bfa6f74ba64 /strfs5 xfs _netdev-systemd.requires=stratisd.service 0 0
    • /dev/vde1 swap swap defaults 0 0
    • /dev/vg200/swapvol swap swap defaults 0 0
  • mount -a ➑ mount all fs mentioned on fstab.

  • mount -o rw /stratis/strpool5/strfs5 /strfs5 ➑ mount strfs5 stratis fs on /strfs5 dir.

  • lsblk /stratis/strpool5/strfs5 -o UUID > /tmp/uuid ➑ save strfs5 fs UUID on a temp file.

ADD NEW PARTITIONS AND LOGICAL VOLUMES, AND SWAP TO A SYSTEM NON-DESTRUCTIVELY
  • mkswap /dev/vde1 ➑ initialize partition with swap structures.

  • mkswap -L swappart /dev/vde1 ➑ apply swappart label to partition.

  • swapon -a ➑ activate all swap partitions described on fstab.

  • swapon -s ➑ list all active swap partitions.


Next:

(RHCSA) Create and Configure File Systems

…or back to Red Hat Certified System Administrator (RHCSA) Exam Study Guide



Footnotes:

  • Follow me on Twitter to get more posts like this and other quick tips in your feed.
  • If you have any doubts or tips about this article, I’d appreciate knowing and discussing it via email.
  • Do you have any other Linux tips? Would you like to publish that in this blog? Please send an email to all drops.
  • As English is not my native language, I apologize for the errors. Corrections are welcome.
  • Contact: contact [@] alldrops [.] info.

Read more on linux drops: