LFCS lab: Ubuntu, AlmaLinux, and safe storage practice
Two Ubuntu hosts and one RHEL host, because LFCS is sat on either family and the candidate chooses. None of the three has a spare disk, so the Storage domain is taught on loop devices - a file, losetup, and then genuinely mkfs, mount and /etc/fstab against a real block device. That started as a constraint and turned out to be the better lesson, because a reader following along has no spare disk either.
Start Here Guide 2 of 38 Beginner
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- LVM2.03.31 (Ubuntu) / 2.03.36 (AlmaLinux)
- nftables1.1.6 (Ubuntu) / 1.1.5 (AlmaLinux)
- TimeAbout 16 min
Ubuntu 26.04 with kernel 7.0.0 and systemd 259; RHEL 10.0 with kernel 6.12 and systemd 257. Loop devices behave identically on both.
- Firewallufw 0.36.2 enabled but reporting inactive / firewalld active
- Network confignetplan + systemd-networkd / NetworkManager 1.56.0
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LFCS-A01 | 192.168.0.70 | Ubuntu 26.04 LTS | Primary host - most guides run only here | 2 Core | 4 GB | 50 GB |
| LFCS-B01 | 192.168.0.71 | Ubuntu 26.04 LTS | Second host - so networking has two ends | 2 Core | 4 GB | 50 GB |
| LFCS-C01 | 192.168.0.72 | AlmaLinux 10.2 | The other distribution - dnf, firewalld and NetworkManager | 2 Core | 4 GB | 50 GB |
This guide includes
Use this before the first LFCS guide. This matters because the exam lets you choose the distribution and this lab has no spare disk - so every storage task is done on a block device you build out of a file.
- meeting the three machines, two Ubuntu and one RHEL
- finding that there is no spare disk, and making a real block device from a file
- putting a filesystem on it, and mounting it
- taking it back down in the order that actually works
- checking what sudo is set up to allow, since every guide on this path uses it
Before you start
- guide 1 - the domains these machines are for.
-
The three machines
One primary Ubuntu host, a second Ubuntu host so networking has two ends, and one RHEL host for every command that differs.
bash Example session hostnamectl | head -8 Static hostname: lfcs-a01 Icon name: computer-vm Chassis: vm 🖴Chassis Asset Tag: 8665-3071-9889-5090-6456-3643-06 Machine ID: 0866a31c6c9e49e38f752fa07a1c8c72 Boot ID: f796628f1ad64c93a5a19e6040b4b41e Virtualization: microsoft Operating System: Ubuntu 26.04 LTShostnamectl hostname; . /etc/os-release; echo "$PRETTY_NAME kernel $(uname -r)"lfcs-a01Ubuntu 26.04 LTS kernel 7.0.0-30-generichostnamectl hostname; . /etc/os-release; echo "$PRETTY_NAME kernel $(uname -r)"lfcs-c01AlmaLinux 10.2 (Lavender Lion) kernel 6.12.0-211.7.3.el10_2.x86_64Expected result
lfcs-a01on Ubuntu 26.04,lfcs-b01on Ubuntu 26.04, andrhcsa-util01on RHEL 10.0.Success conditionYou know which machine each command belongs to.
-
No spare disk
One 50 GB disk, all of it in use - and that is the same situation a reader following along is in.
bash Example session lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT | grep -v '^sr0\|^fd0'NAME SIZE TYPE FSTYPE MOUNTPOINTsda 50G disk|-sda1 1M part|-sda2 2G part xfs /boot`-sda3 48G part LVM2_member |-almalinux_lfcs--c01-root 44.1G lvm xfs / `-almalinux_lfcs--c01-swap 3.9G lvm swap [SWAP]df -h / /boot | column -tFilesystem Size Used Avail Use% Mounted on/dev/mapper/almalinux_lfcs--c01-root 44G 6.0G 39G 14% //dev/sda2 2.0G 454M 1.5G 23% /bootls -l /dev/loop-control && losetup -a | head -3; echo "attached loop devices: $(losetup -a | wc -l)"crw-rw----. 1 root disk 10, 237 Aug 29 13:36 /dev/loop-controlattached loop devices: 0Expected result
sdawith a 1M BIOS partition, a 2G/boot, and 48G of LVM holding/- and zero attached loop devices.Success conditionYou know why the storage track is written the way it is.
-
A real block device, made from a file
truncatea file, attach it withlosetup, and look at what the kernel now thinks it has.Compare the two
duoutputs.bash Example session sudo mkdir -p /opt/lfcs && sudo truncate -s 512M /opt/lfcs/tour.img && ls -lh /opt/lfcs/tour.img && du -h --apparent-size /opt/lfcs/tour.img && du -h /opt/lfcs/tour.img-rw-r--r--. 1 root root 512M Aug 29 15:15 /opt/lfcs/tour.img512M /opt/lfcs/tour.img0 /opt/lfcs/tour.imgsudo losetup --find --show /opt/lfcs/tour.img/dev/loop0lsblk -o NAME,SIZE,TYPE /dev/loop0 && sudo blockdev --getsize64 /dev/loop0 && cat /sys/block/loop0/queue/logical_block_sizeNAME SIZE TYPEloop0 512M loop536870912512Expected result
512Mfromls -lhanddu --apparent-size, but0fromdu- then/dev/loop0, 512M, typeloop, 536870912 bytes, 512-byte sectors.Success conditionYou can create a block device on any machine.
-
A filesystem on it, and a mount
mkfs.ext4,blkid,mount- the same three commands you would run on/dev/sdb1.bash Example session sudo mkfs.ext4 -q -L lfcstour /dev/loop0 && sudo blkid /dev/loop0/dev/loop0: LABEL="lfcstour" UUID="f32dc454-84fa-44dc-b3fb-3564bd6dd4be" BLOCK_SIZE="4096" TYPE="ext4"sudo mkdir -p /mnt/tour && sudo mount /dev/loop0 /mnt/tour && df -h /mnt/tour | tail -1 && sudo touch /mnt/tour/proof && ls /mnt/tour/dev/loop0 488M 24K 452M 1% /mnt/tourlost+foundproofExpected resultA LABEL, a UUID and
BLOCK_SIZE="4096"fromblkid; thendfreporting 488M of a 512M device, withlost+foundand the file just created.Success conditionYou have a working filesystem you made yourself.
-
And taken back down
The cleanup, in the order it has to happen.
bash Example session sudo umount /mnt/tour && sudo losetup -d /dev/loop0 && sudo rmdir /mnt/tour && sudo rm -f /opt/lfcs/tour.img && sudo rmdir /opt/lfcs 2>/dev/null; losetup -a | wc -l; ls /opt/lfcs 2>&1 | tail -10ls: cannot access '/opt/lfcs': No such file or directoryExpected result
0attached loop devices and/opt/lfcs: No such file or directory.Success conditionYou can leave the machine as you found it.
-
What sudo is set up to allow
Every guide on this path uses
sudo, so it is worth seeing exactly what that means here.bash Example session sudo -n -l | tail -4User sysadmin may run the following commands on lfcs-a01: (ALL : ALL) ALL (ALL) NOPASSWD: ALLid; groupsuid=1000(sysadmin) gid=1000(sysadmin) groups=1000(sysadmin),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),101(lxd)sysadmin adm cdrom sudo dip plugdev users lxdExpected result
(ALL : ALL) ALLand(ALL) NOPASSWD: ALL, and membership ofsudoamong others.Success conditionYou know why no command on this path prompts for a password.
Troubleshooting
losetup: cannot find an unused loop device.Why: All the pre-created loop devices are attached, or the module is not loaded.
Fix:
losetup -ato see what is attached andlosetup -dto release.modprobe loopif/dev/loop-controlis missing.umount: target is busy.Why: A process has a file open under the mount point, or your shell is sitting in it.
Fix:
cdout, thenfuser -vm /mnt/pointorlsof +D /mnt/pointto find the holder.The loop file is much smaller on disk than its size suggests.
Why:
truncatecreates a sparse file - correct, and usually what you want.Fix:
duagainstdu --apparent-sizeshows both numbers. Usefallocateto reserve the space for real.The loop device is gone after a reboot.
Why: Nothing reattached it. Loop devices are not persistent by themselves.
Fix:For a lab, reattach with
losetup./etc/fstabcan mount a file directly with theloopoption if you want it back automatically.A fresh filesystem reports less space than the device has.
Why: Metadata and the root reserve, not an error.
Fix:
tune2fs -m 0removes the reserve on ext4 if the space matters more than the safety margin.