(RHCSA) Create and Configure File Systems

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:

“CREATE AND CONFIGURE FILE SYSTEMS”

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:

CREATE, MOUNT, UNMOUNT, AND USE VFAT, EXT4, AND XFS FILE SYSTEMS
MOUNT AND UNMOUNT NETWORK FILE SYSTEMS USING NFS
EXTEND EXISTING LOGICAL VOLUMES
CREATE AND CONFIGURE SET-GID DIRECTORIES FOR COLLABORATION
CONFIGURE DISK COMPRESSION
MANAGE LAYERED STORAGE
DIAGNOSE AND CORRECT FILE PERMISSION PROBLEMS

(This objective is also covered in: “understand and use essential tools / list, set, and change standard ugo/rwx permissions” and “manage security / create and use file access control lists”)


šŸ“‘ Cheatsheet:

CREATE, MOUNT, UNMOUNT, AND USE VFAT, EXT4, AND XFS FILE SYSTEMS
  • mkfs.ext4 /dev/sdb1 āž” create an ext4 file system in /dev/sdb1 partition.

  • mount /dev/sdb1 /test āž” mount /dev/sdb1 file system at /test mountpoint (won’t survive a system reboot).

  • unmount /dev/sdb1 āž” unmount /dev/sdb1 filse system.

  • On /etc/fstab add /dev/sdb1 /test ext4 defaults 0 0 āž” to mount the file system on system startup.

  • mount -a āž” mount all filesystems mentioned in /etc/fstab.

MOUNT AND UNMOUNT NETWORK FILE SYSTEMS USING NFS

(Requires nfs-utils and autofs packages)

  • Setup NFS server (to serve a directory):

    • chmod 755 /common āž” add full permissions to dir, before sharing.
    • firewall-cmd --permanent --add-service nfs & firewall-cmd --reload āž” allow NFS traffic to pass through firewalld.
    • systemctl --now enable nfs-server āž” enable NFS server.
    • On /etc/exports file add: /common/ 192.168.0.110(rw)
    • exportfs -av āž” export or unexport all items on /etc/exports (verbose mode).
  • exportfs -u 192.168.0.110:/common āž” unexport dir.

  • Mount share on NFS client (old way to mount):

    • mkdir /local
    • mount 192.168.0.120:/common /local āž” to mount manually.
    • On /etc/fstab add: 192.168.0.120:/common /local nfs _netdev 0 0 āž” to mount on system startup.
    • mount | grep local āž” to confirm mounting success.
  • Mount share on client on-demand using AutoFS (preferred way to mount):

    (If using AutoFS for a sharing, do not mount manually or via /etc/fstab!)

    • USING DIRECT MAP

      • mkdir /autodir
      • On /etc/auto.master add /- /etc/auto.master.d/auto.dir āž” to create the mapping.
      • Create /etc/auto.master.d/auto.dir file and add /autodir 192.168.0.120:/common āž” to automount the shared fs on /autodir.
    • USING INDIRECT MAP (preferred way)

      • On /etc/auto.master add /autoindir /etc/auto.master.d/auto.indir āž” to create the indirect mapping.
      • Create /etc/auto.master.d/auto.indir file and add common 192.168.0.120:/common āž” to automount the shared fs on /autodir(name the mountpoint just like the shared folder’s name).
      • systemctl enable --now autofs or systemctl restart autofs āž” to start.
EXTEND EXISTING LOGICAL VOLUMES
  • vgextend vg100 /dev/vdc āž” extend volume gropup adding a new physical volume.

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

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

  • resize2fs /dev/vg200/lv200 3T āž” resize ext4 file system.

  • xfs_growfs /dev/vg200/lv200 āž” resize xfs file system.

CREATE AND CONFIGURE SET-GID DIRECTORIES FOR COLLABORATION
  • chmod +2000 /usr/bin/write, chmod g+s /usr/bin/write āž” enables setgid in write file without touching other predefined permissions.

  • chmod +1000 /tmp, chmod o+t /tmp āž” sets the sticky bit on the specified directory without altering existing underlying permissions. (sticky bit on public and shared writable dirs are used to protect files and subdirs owned by normal users from being deleted or moved by other normal users.)

CONFIGURE DISK COMPRESSION

(If kernel update was previously installed from file, you might need to download and install vdo and kmod-kvdo from file too.)

  • vdo list, vdostats, lsblk āž” see vdo volumes.

  • vdo create --name=testvdo --device=/dev/vdh --vdoLogicalSize=16G --vdoSlabSize=128M āž” create new vdo volume named testvdo with logical size of 16GB and slab size of 128mb.

  • vdo status --name testvdo | grep -i dupl āž” check if vdo volume has deduplication enabled.

  • mkfs.xfs -K /dev/mapper/vdo-name āž” create xfs filesystem on vdo volume.

  • mkfs.ext4 -E nodiscard /dev/mapper/vdo-name āž” create ext4 filesystem on vdo volume, avoid discarding blocks.

  • On /etc/fstab add /dev/mapper/vdo-name mount-point xfs defaults,x-systemd.device-timeout=0,x-systemd.requires=vdo.service 0 0 to mount the xfs file system.

  • On /etc/fstab add /dev/mapper/vdo-name mount-point ext4 defaults,x-systemd.device-timeout=0,x-systemd.requires=vdo.service 0 0 to mount the ext4 file system.

  • vdo disableCompression --name testvdo āž” disable compression to vdo volume.

MANAGE LAYERED STORAGE

(Requires stratisd and stratis-cli packages)

  • systemctl enable --now stratisd āž” Start Stratis service.

  • stratis pool create strpool /dev/vdg āž” create strpool stratis pool using /dev/vdg block device.

  • stratis pool list āž” list pools.

  • stratis blockdev āž” display information of block devices used by stratis.

  • stratis fs āž” display information of stratis filesystems.

  • stratis pool add-data strpool /dev/vdh āž” expand the stratis pool adding another block device.

  • stratis fs snapshot my-pool my-fs my-fs-snapshot āž” create a snapshot from my-fs stratis filesystem.

  • mount /dev/stratis/my-pool/my-fs mount-point āž” mount a stratis snapshot.

  • stratis filesystem destroy my-pool my-fs-snapshot āž” remove a stratis snapshot (you must unmount the snapshot first).

  • stratis pool destroy strpool āž” remove stratis pool.

  • stratis filesystem create strpool5 strfs5 āž” create strfs5 filesystem on strpool5 stratis pool.

  • On /etc/fstab add UUID=a1f0b64a-4ebb-4d4e-9543-b1d79f600283 /fs1 xfs defaults,x-systemd.requires=stratisd.service 0 0 āž” to mount a stratis file system (it must be identified by it’s UUID).

DIAGNOSE AND CORRECT FILE PERMISSION PROBLEMS
  • chmod 644 somefile.txt āž” set file permissions to u=rw,g=r,o=r.

  • chmod +022 somefile.txt āž” add g=w,o=w permissions to the file.

  • chmod ug+x,o-w āž” add user and group execute permission and remove write permission from others.

  • chown root:sgrp /sdir āž” change ownership and owning group to root and sgrp respectively.

  • chmod +4000 /usr/bin/su, chmod u+s /usr/bin/su āž” enables setuid in su file without touching other predefined permissions. (setuid is used to give special permissions on executable files)

  • chmod +2000 /usr/bin/write, chmod g+s /usr/bin/write āž” enables setgid in write file without touching other predefined permissions.

  • chmod +1000 /tmp, chmod o+t /tmp āž” sets the sticky bit on the specified directory without altering existing underlying permissions. (sticky bit on public and shared writable dirs are used to protect files and subdirs owned by normal users from being deleted or moved by other normal users.)

  • setfacl -m u:user100:6 file1, setfacl -m u:user100:rw file1 āž” gives user100 read and write permissions on file1 by using Access Control Lists (ACLs).

  • setfacl -x u:user100 file1 āž” removes any user100 āž” ACL permissions for file1.

  • setfacl -b file1 āž” resets ACL permissions for file1.

  • setfacl -dm u:user100:7,u:user200:rwx projects/ āž” allocate default rwx permissions to user100 and user200 on projects/ dir.

  • setfacl -k projects/ āž” deletes default ACL permissions for projects/ directory.


Next:

(RHCSA) Deploy, Configure, and Maintain Systems

(šŸ‘† To be delivered in nov/2021)

…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: