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.
π How to add new drives to a VirtualBox virtual machine (this is s setup step! Follow the “Adding the disk” section only.)
π RHCSA v8 Practice Session: Configure local storage (a single video presenting of all the objectives below)
LIST, CREATE, DELETE PARTITIONS ON MBR AND GPT DISKS
π gdisk Command: How to Create GUID Partitions (GPT) in Linux (skip “Formatting the partition in Linux” and following sections.)
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
π Using mkfs command in Linux to Format the Filesystem on a Disk or Partition
π Linux Essentials - Automatically mounting storage volumes with /etc/fstab
ADD NEW PARTITIONS AND LOGICAL VOLUMES, AND SWAP TO A SYSTEM NON-DESTRUCTIVELY
π What is Linux swap?
π Cheatsheet:
LIST, CREATE, DELETE PARTITIONS ON MBR AND GPT DISKS
lsblk
β‘ list block devices.parted /dev/vdb mklabel msdos
β‘ label a new disk asmsdos
.parted /dev/vdb print
β‘ display disk info.parted /dev/vdb mkpart primary 1 101m
β‘ create a newprimary
partition on disk, with size of 100mb.parted /dev/vdb rm 1
β‘ remove partition1
.gdisk /dev/vdc
β‘ create/modify partitions on disk usinggdisk
.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
β‘ listvolume groups
,physical volumes
andlogical 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
β‘ createvolume group
using/dev/vdb
physical volume
, withPE
size of 16MB.vgdisplay vg100
β‘ checkvg100
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 volumelvol0
onvg100
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 onfstab
.mount -o rw /stratis/strpool5/strfs5 /strfs5
β‘ mountstrfs5
stratis fs on/strfs5
dir.lsblk /stratis/strpool5/strfs5 -o UUID > /tmp/uuid
β‘ savestrfs5
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
β‘ applyswappart
label to partition.swapon -a
β‘ activate all swap partitions described onfstab
.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
Useful links & references:
Enable Sysadmin (a blog from Red Hat)
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.