File systems & mounts.
A partition is just bytes until you format it with a filesystem and mount it somewhere. Watch a block device become an XFS filesystem, get mounted, and survive a reboot via /etc/fstab β then learn the options that govern its behavior.
Linux filesystems and mounts animated tutorial. mkfs.xfs and mkfs.ext4, the mount command, mount options, /etc/fstab format and UUIDs, fsck and tune2fs, xfs_growfs and resize2fs. RHCSA EX200 ready.From a bare partition to a mounted, persistent filesystem β six layers, all with their own commands.
- Β·The partitions lesson (lsblk, blkid)
- Β·Comfortable as root
- Β·Know what a journaling filesystem is, vaguely
Format a partition with mkfs, mount it, persist it in /etc/fstab using UUID, pick the right mount options, and grow / check it.
pace: 9 minutes
/dev/sdb1(none)(unmounted)(no entry)Pick a filesystem β XFS or ext4
Two RHCSA defaults: XFS (RHEL's default since 7) β fast, scales to huge volumes, grows online but CANNOT shrink. ext4 β slightly older, slower at scale, supports BOTH grow and shrink (offline shrink). Pick XFS unless you specifically need to shrink. Both journal, both are stable.
$lsblk -f /dev/sdb1$blkid /dev/sdb1The chain: block device β filesystem β mount β fstab. Skip the last step and your work vanishes at reboot. ALWAYS run `mount -a` after editing fstab β if you don't, the next reboot might drop into emergency mode and the only way out is rescue media.
$mkfs.xfs / mkfs.ext4 DEV$mkfs.xfs -L LABEL DEV$mount DEV MOUNTPOINT$umount MOUNTPOINT$mount -a$mount -o remount,ro DIR$findmnt / findmnt --verify$lsof DIR / fuser -mv DIR$blkid DEV$/etc/fstab$xfs_growfs MP$resize2fs DEV$xfs_repair DEV (unmounted)$fsck.ext4 -y DEV$tune2fs -l DEV$df -hT / du -sh DIRYou added a new line to /etc/fstab and want to verify it works WITHOUT rebooting.
You need to SHRINK a filesystem. Which filesystem can you use?
`umount /data` returns 'target is busy'. How do you find the culprit?
Why reference partitions by UUID in /etc/fstab?
These aren't graded β they're just for active recall, which is what actually makes the lesson stick.
LVM stacking
Put LVM between the partition and the filesystem and growing space online becomes one command. See the whole stack: disks β PVs β VG β LVs β FS.
Read this lesson as text6 chapters Β· quiz answers
01Pick a filesystem β XFS or ext4
Two RHCSA defaults: XFS (RHEL's default since 7) β fast, scales to huge volumes, grows online but CANNOT shrink. ext4 β slightly older, slower at scale, supports BOTH grow and shrink (offline shrink). Pick XFS unless you specifically need to shrink. Both journal, both are stable.
$ lsblk -f /dev/sdb1β what's there now (probably nothing)$ blkid /dev/sdb1β blank? blkid says nothing
02mkfs β format the partition
mkfs.xfs /dev/sdb1writes an XFS filesystem onto the block device β superblock, inodes, journal, the works.mkfs.ext4 /dev/sdb1for ext4.-L mylabelsets a human label. The command takes seconds for normal sizes. DESTRUCTIVE: anything previously on the device is gone.$ mkfs.xfs /dev/sdb1β format as XFS$ mkfs.xfs -L data /dev/sdb1β with a label$ mkfs.ext4 /dev/sdb1β ext4 instead$ blkid /dev/sdb1β now has TYPE + UUID
03mount β attach it to the tree
A filesystem only becomes usable when mounted at a directory.
mkdir -p /data && mount /dev/sdb1 /datamakes anything written into /data go onto the new filesystem. The mount lives only until reboot orumount.mountwith no args lists everything currently mounted;findmntis the pretty version.$ mkdir -p /dataβ create mount point$ mount /dev/sdb1 /dataβ mount it$ mount | grep /dataβ verify$ umount /dataβ detach$ lsof /data / fuser -mv /dataβ umount busy? find who's using it
04Persist with /etc/fstab
/etc/fstab is the boot-time mount list. Format: <device> <mountpoint> <fstype> <options> <dump> <pass>. Always use UUID= (from blkid) β device names can shift when disks are added or reordered. After editing, test with
mount -a(mounts everything not already mounted) β if it fails, fix BEFORE rebooting or the system may drop to emergency mode.findmnt --verifychecks the file for syntax.$ blkid /dev/sdb1β get UUID$ echo 'UUID=β¦ /data xfs defaults 0 0' >> /etc/fstabβ persist$ mount -aβ TEST without rebooting$ findmnt --verifyβ syntax check fstab
05Mount options that matter
The options column of fstab tunes behavior.
defaults= rw,suid,dev,exec,auto,nouser,async (covers most cases). Useful overrides: ro (read-only), noexec (no executables β /tmp hardening), nosuid (ignore SUID β /home hardening), noatime (don't update access time β perf win), nofail (don't block boot if the device is missing β great for removable disks). Combine with commas:defaults,noexec,nosuid.$ mount -o remount,ro /dataβ remount read-only without unmounting$ mount -o noexec,nosuid /dev/sdb1 /tmpβ harden /tmp$ mount -o noatime β¦β skip atime writes (perf)$ mount -o nofail β¦β don't block boot if absent
06Grow, check, repair
XFS grows online with
xfs_growfs /dataonce the underlying LV/partition is bigger. ext4 usesresize2fs /dev/sdb1(online for grow, offline for shrink).fsckchecks/repairs an UNMOUNTED filesystem (xfs_repair for XFS). RHEL won't fsck a mounted FS; for the root FS, set the 6th fstab column to 1 (root) or 2 (other) and the boot scripts will run it for you.$ xfs_growfs /dataβ grow XFS online$ resize2fs /dev/sdb1β grow/shrink ext4$ xfs_repair /dev/sdb1β repair (UNMOUNTED)$ fsck.ext4 -y /dev/sdb1β ext4 repair$ tune2fs -l /dev/sdb1β ext4 superblock info
Quiz β answers
- You added a new line to /etc/fstab and want to verify it works WITHOUT rebooting.
- βRun
mount -aβ it mounts everything in fstab that isn't already mounted. If your new entry has a syntax error or bad device, you find out NOW instead of in emergency mode after a reboot.ALWAYSmount -aafter editing fstab. A bad entry can drop the next boot into emergency mode.findmnt --verifyis a syntax-only check that complements it. - You need to SHRINK a filesystem. Which filesystem can you use?
- βext4 β supports shrinking (offline, with resize2fs).XFS grows but does NOT shrink β at all. ext4 supports shrink, but the FS must be unmounted first. If you need shrink capability, choose ext4 up front (or migrate by recreating).
umount /datareturns 'target is busy'. How do you find the culprit?- β
lsof /dataorfuser -mv /dataβ lists every open file descriptor and process inside the mount. Kill or change directory out, then umount cleanly.Both lsof and fuser show what's keeping the mount busy β often someone's shell sitting in that directory, or a service writing logs there.umount -fcan leave open files in odd states; identify and stop the user(s) first. - Why reference partitions by UUID in /etc/fstab?
- βBecause /dev/sdXn names depend on enumeration order β add or remove a disk and the names shift. UUIDs are tied to the filesystem and stay stable.The kernel assigns sd* names in the order it finds disks. Adding an extra disk can rename your boot disk to sdb. UUIDs (from blkid) stay with the filesystem itself, so fstab keeps working.
keep going β these pair well with what you just learned.
SELinux contexts
Why Apache can't read your file. Watch the policy engine decide β and learn the workflow for fixing denials. RHCSA-ready.
Linux boot process
From power button to login prompt. Every stage in the chain β UEFI, GRUB, kernel, initramfs, systemd β with the rescue moves that save you. RHCSA-ready.
LVM stacking
Layer-by-layer build of an LVM stack: disks β PVs β VG β LVs β filesystem. Then extend live and snapshot. RHCSA-ready.