OPEN
OPS

DISK PARTITIONING & Arch Installation

Practical exercises — from loop devices to Arch Linux install · AGH University of Science and Technology

fallocate losetup fdisk mkfs mount fstab pacstrap grub
1 Title Slide
OPEN OPERATING SYSTEMS
DISK PARTITIONING
& Arch Installation
Practical exercises — from loop devices to Arch Linux install
PART 1
Creating filesystems
PART 2
Mounting — visual guide
PART 3
Arch Linux install from scratch
PRESENTER NOTES
TITLE SLIDE — "Open Operating Systems: Disk Partitioning & Arch Installation"

This presentation covers 4 practical parts:
  Part 1: Creating filesystems — loop devices, fallocate/dd, mkfs
  Part 2: Mounting — visual step-by-step guide with filesystem trees
  Part 3: Arch Linux install from scratch — pacstrap, chroot, GRUB

All exercises are done using loop devices — no real hardware is required and there is no risk of data loss on the host machine.
Emphasise: loop devices are a safe sandbox for experimenting with partitioning.
2 Step 1 — Connect to the lab server

Step 1 — Connect to the lab server via SSH:

$ ssh aghos@oos.wimic.agh.edu.pl
PRESENTER NOTES
SSH LOGIN SLIDE

Students connect to the lab server using SSH.
Command (red, shown on slide): ssh aghos@oos.wimic.agh.edu.pl

Remind students:
- They need a terminal (Linux/macOS: built-in; Windows: PuTTY or Windows Terminal)
- The username is aghos — same for everyone
- No password is set for this user
3AGHOS Boot Menu

After logging in, type 1 to select the AGHOS boot menu entry.

A numbered boot menu appears. Option 1 starts your personal QEMU virtual machine session.

PRESENTER NOTES
AGHOS BOOT MENU

After SSH login, students see a simple numbered menu.
Pressing 1 starts a QEMU virtual machine session booted from the AGHOS ISO.
The boot output is forwarded over serial → terminal, so they see it in their SSH window.
This is where the hands-on work happens — inside the VM.
4Language Selection

Then choose the preferred language.

Select English (US) for the keyboard/locale layout. This is a standard live-system locale selection.

PRESENTER NOTES
LANGUAGE SELECTION

After the AGHOS GRUB menu loads, students choose a keyboard/language layout.
Most students should pick English (US).
This is a standard live-system locale selection — nothing unusual here.
5Login as aghos

After booting, log in as the aghos user (no password required), then gain root privileges:

$ sudo su
Note: Initial boot may take a while depending on your network speed — the system image is downloaded on first launch.
PRESENTER NOTES
LOGIN AS AGHOS

Inside the booted VM, students log in as user aghos with no password.
Then they escalate to root with: sudo su

Important note: first boot may take a while — the system image is pulled over the network. This is normal.
6 ADVANCED What is actually happening — Lab infrastructure explained

For the more technically curious — what is actually happening behind the scenes:

SESSION START (option 1)

When you select option 1 at login, the server automatically starts a dedicated QEMU virtual machine session for each user, booting from the AGHOS ISO image.

SERIAL → TERMINAL OUTPUT

AGHOS GRUB detects headless mode (no monitor). If no monitor is connected, it redirects all output to the serial port, which is forwarded to your terminal — that is why you can see the boot screen inside your SSH session.

OPTION 2 AT LOGIN

Selecting option 2 simply logs you in as a regular (non-QEMU) user on the host machine.

ENDING THE SESSION

Do NOT use exit — that only logs you out of the shell. To properly shut down the VM, type:

$ shutdown -h now

THE VIRTUAL DISK

The 100 GB disk.img file is a raw disk image that appears as /dev/vda inside the QEMU session — it is your virtual hard drive. If it is too large to download, create a smaller image, copy only your data to it, and download that instead.

PRESENTER NOTES
TECHNICAL BACKGROUND — HOW THE LAB INFRASTRUCTURE WORKS

This is an optional deep-dive slide for curious students. Not required to follow the lab.

Key points to mention:
- Each student gets their own isolated QEMU session — changes do not affect others
- AGHOS GRUB auto-detects headless mode and routes output to serial → terminal
- To end the session: shutdown -h now (not exit — exit only logs out of the shell)
- Option 2 at login = plain host shell (no VM)
- disk.img (100 GB) = the virtual hard drive visible as /dev/vda inside QEMU
- If disk.img is too large to download, students can create a smaller image and copy data to it
7 PART 1 Loop Devices & Partitioning
Loop Devices
& Partitioning
Create a virtual disk inside a file · partition it · no real hardware needed
fallocate / dd
Create raw file
losetup
Connect to /dev/loop
fdisk / parted
Partition the file
kpartx / -P
Expose partitions
PRESENTER NOTES
PART 1 SECTION DIVIDER — Loop Devices & Partitioning

Key concepts to introduce:
- A loop device maps a regular file to a block device (like /dev/loop0)
- This allows partitioning and formatting a FILE as if it were a real disk
- Tools used: fallocate (or dd) → losetup → fdisk/parted → kpartx or -P flag

Analogy: "Think of disk.img as a USB drive that lives inside a file."
8 How to create a virtual disk file

Two tools to create a raw file of a specific size — choose one:

Method A — fallocate (fast, recommended)

# Check the free space on the disk $ df -h $ fallocate -l 30G disk.img # Verify size $ ls -lh disk.img -rw-r--r-- 1 user 30G disk.img # Check it looks like raw data $ file disk.img disk.img: data

fallocate -l SIZE FILE

-l = length · Supports: K, M, G, T
Example: -l 500M

Method B — dd (slower, fills with zeros)

# Create a 2 GB file filled with zeros # bs=1M = block size, count=2048 = 2 GB $ dd if=/dev/zero of=disk.img bs=1M count=2048 # With progress indicator $ dd if=/dev/zero of=disk.img bs=1M count=2048 \ status=progress

dd if=SRC of=DST

if=input · of=output · bs=block size · count=num blocks

WHY 2 GB?

Large enough to hold a real OS. Use any size — even 500M for practice.

PRESENTER NOTES
CREATING A VIRTUAL DISK FILE — fallocate vs dd

Two methods shown side by side:
  Method A: fallocate -l 30G disk.img  — fast, allocates space without writing zeros (recommended)
  Method B: dd if=/dev/zero of=disk.img bs=1M count=2048  — slower, fills with zeros

Key flags to explain:
  fallocate -l = length (supports K, M, G, T)
  dd: if=input source, of=output file, bs=block size, count=number of blocks

Why 2 GB? Large enough to hold a real OS. Students can use 500M for quick practice.
Always check free space first: df -h
9 Lab Machine — 3 Drives Overview
/dev/nvme0n1
1 TB — very fast NVMe SSD
/dev/nvme1n1
1 TB — very fast NVMe SSD
/dev/sda
10 TB — slow SATA drive · cheap but spacious
PRESENTER NOTES
DRIVES OVERVIEW — The lab machine has 3 drives

Drive layout:
  /dev/nvme0n1 — 1 TB, very fast NVMe SSD
  /dev/nvme1n1 — 1 TB, very fast NVMe SSD
  /dev/sda     — 10 TB, slow but spacious SATA HDD

This slide sets up the scenario for the upcoming multi-drive mount exercise.
10–14 Partition Planning — Visual Drive Diagrams

Slides 10–14 show animated bar diagrams of the drives being partitioned. Key assignment plan:

Drive 1 — /dev/nvme0n1 (fast SSD)
/boot
/ root
/var
/home
Drive 2 — /dev/nvme1n1 (fast SSD)
/home/user_name/games
Drive 3 — /dev/sda (slow SATA, 10 TB)
/home/user_name/media
PRESENTER NOTES
PARTITION PLANNING — Drive 1 (NVMe SSD)

  p1 → /boot   (EFI system partition, FAT32)
  p2 → /        (root filesystem, ext4)
  p3 → /var     (variable data — logs, databases)
  p4 → /home    (user home directories)

Discuss WHY we separate /var and /home:
- /var can grow quickly (logs, package cache) — isolating it prevents it from filling root
- /home on its own partition = user data survives OS reinstall

Drive 2: dedicated to fast game storage — games benefit from fast NVMe I/O.
Drive 3: slow but spacious SATA — media files (videos, photos) don't need fast random I/O.
15–16 Partition Assignment Summary & 3D Visualisation

ASSIGNMENT PLAN

  • Fast SSD → /boot, / (root), /var, /home
  • Fast SSD → /home/user_name/games
  • Slow SATA → /home/user_name/media (10 TB)

Drives rotated 90° for better visualisation — relative partition sizes shown proportionally. This is the planning phase: no commands yet, just the target layout.

PRESENTER NOTES
PARTITION ASSIGNMENT SUMMARY & 3D DRIVE VIEW

Each bar labelled with its intended mount point.
This is the planning phase — no commands yet, just the target layout.

3D view: drives rotated 90° for clearer perspective. Labels: Drive 1 (left), Drive 2 (centre), Drive 3 (right).
17 PART 2 The Linux Filesystem Tree — Booted Live System

Booted Live (USB or ISO) system

/ ├── /bin ├── /boot ├── /etc ├── /lib ├── /mnt ← empty! staging area ├── /usr ├── /var ├── /tmp ├── /root └── /home/

KEY CONCEPT: /mnt

On a live system, /mnt is empty. We use it as the staging area to assemble the new system's directory tree before installing.

THE PLAN

We will mount each partition from our 3 drives under /mnt, mirroring the final system layout. Then run pacstrap to install into it.

PRESENTER NOTES
LINUX FILESYSTEM TREE — The booted live system

Shows the directory tree of the running live system (USB/ISO).
Key directory: /mnt — this is where we will attach the new system.
Explain: on a live system, /mnt is empty. We use it as the staging area to build the new OS tree.
18–20 Mounting Plan — Partition Assignment

This is the partition assignment plan — no mounts have happened yet.

Mount PointPartitionDriveFilesystem
/mnt/dev/nvme0n1p2Drive 1 (NVMe)ext4 — root
/mnt/boot/dev/nvme0n1p1Drive 1 (NVMe)FAT32 — EFI
/mnt/var/dev/nvme0n1p3Drive 1 (NVMe)ext4
/mnt/home/dev/nvme0n1p4Drive 1 (NVMe)ext4
/mnt/home/user/games/dev/nvme1n1p1Drive 2 (NVMe)ext4 — fast
/mnt/home/user/media/dev/sda1Drive 3 (SATA)ext4 — spacious
PRESENTER NOTES
MOUNTING PLAN — Assigning partitions to directories

Same live system tree, now annotated with the partition assignment plan.
Key point: "It's just a plan for now — no mounts have happened yet."
21 mount Command Anatomy
$ mount /dev/nvme0n1p2 /mnt └────── └───────────── └── command device mountpoint

Every mount command follows this exact pattern. The device must be a formatted partition, and the mountpoint directory must already exist.

PRESENTER NOTES
MOUNT COMMAND ANATOMY

Breakdown: mount [device] [mountpoint]
  command:    mount
  device:     /dev/nvme0n1p2
  mountpoint: /mnt

Simple, but important. Every subsequent mount follows the same pattern.
22–30 Step-by-step Mounting — Building the Tree
1

Mount root partition first

$ sudo mount /dev/nvme0n1p2 /mnt

Root partition is mounted at /mnt — currently empty, ready for subdirectories.

2

Create subdirectories inside the mounted root

$ mkdir /mnt/boot $ mkdir /mnt/var $ mkdir /mnt/home

Directories must exist inside the already-mounted root before other partitions can mount into them.

3

Mount boot, var, home partitions

$ sudo mount /dev/nvme0n1p1 /mnt/boot $ sudo mount /dev/nvme0n1p3 /mnt/var $ sudo mount /dev/nvme0n1p4 /mnt/home
4

Create home subdirectories and mount the two extra drives

$ mkdir /mnt/home/games $ mkdir /mnt/home/media $ sudo mount /dev/nvme1n1p1 /mnt/home/games <<< SSD drive for games $ sudo mount /dev/sda1 /mnt/home/media <<< SATA drive for media
Rule: Always mount root first → create subdirectories → then mount the rest. The order matters!
PRESENTER NOTES
STEP-BY-STEP MOUNTING

Step 1: Mount root first — /mnt is the anchor point.
Step 2: Create dirs INSIDE the mounted root. If you create them before mounting, they will be inside the live system, not the new root.
Step 3: Mount boot (EFI), var, home from Drive 1.
Step 4: Create games/media dirs inside the now-mounted /home, then mount Drive 2 and Drive 3.

Common mistake: forgetting to create the target directory before mounting.
Also: note the different devices — nvme1n1p1 (fast NVMe) vs sda1 (spacious SATA).
31 PART 3 Arch Linux Install from Scratch
Arch Linux
Install from Scratch
loop file · partitions · filesystems · pacstrap · chroot · GRUB
1Create
disk.img
2Partition
it
3Format
partitions
4Mount
everything
5pacstrap
-K
6genfstab
+chroot
7GRUB
bootloader
PRESENTER NOTES
PART 3 SECTION DIVIDER — Arch Linux Install from Scratch

7-step process. Tell students: "This is a complete OS install — the same steps you'd use on real hardware."
32 LAB 4.1 Steps 1–3: disk file, partitions, filesystems
# STEP 1: Create the disk file (4 GB) $ fallocate -l 4G arch.img # STEP 2: Attach + partition $ sudo losetup -P --find --show arch.img /dev/loop0 $ sudo parted -s /dev/loop0 \ mklabel gpt \ mkpart ESP fat32 1MiB 513MiB \ set 1 esp on \ mkpart primary ext4 513MiB 100% # STEP 3: Format # p1 = EFI System Partition (must be FAT32!) $ sudo mkfs.vfat -F 32 /dev/loop0p1 # p2 = root filesystem $ sudo mkfs.ext4 /dev/loop0p2 # Verify $ lsblk -f /dev/loop0 NAME FSTYPE SIZE loop0p1 vfat 512M loop0p2 ext4 3.5G
p1 512M EFI
p2 3.5G / ext4

COMMON MISTAKE

Students try to format /dev/loop0 directly. Always format the partition: /dev/loop0p1 or /dev/loop0p2.

losetup -P FLAG

The -P flag tells losetup to scan the image for partition nodes and create /dev/loop0p1, /dev/loop0p2 etc.

PRESENTER NOTES
LAB 4.1 — Steps 1–3: disk file, partitions, filesystems

Step 1: fallocate -l 4G arch.img  (creates a 4 GB raw image file)
Step 2: losetup -P --find --show arch.img  (attaches as /dev/loop0, -P scans for partition nodes)
        parted creates GPT + EFI partition (512M, FAT32) + root partition (rest, ext4)
Step 3: mkfs.vfat -F 32 /dev/loop0p1  (EFI must be FAT32!)
        mkfs.ext4 /dev/loop0p2         (root filesystem)
        lsblk -f /dev/loop0            (verify)

Common mistake: students try to format /dev/loop0 directly instead of /dev/loop0p1 or p2.
33 LAB 4.2 Step 4: mount partitions at /mnt

Create the directory tree and mount each partition into the right place.

# Mount root partition FIRST $ sudo mount /dev/loop0p2 /mnt # Create /boot INSIDE the mounted root $ sudo mkdir -p /mnt/boot # Mount EFI partition inside $ sudo mount /dev/loop0p1 /mnt/boot # Verify $ findmnt /mnt TARGET SOURCE FSTYPE SIZE /mnt /dev/loop0p2 ext4 3.5G /mnt/boot /dev/loop0p1 vfat 512M $ df -h /mnt /mnt/boot /dev/loop0p2 3.4G 24K 3.2G 1% /mnt /dev/loop0p1 511M 0 511M 0% /mnt/boot

MOUNT TREE

/mnt ← loop0p2 (ext4) ├─ boot/ ← loop0p1 (vfat) ├─ bin/ ├─ etc/ ↑ created by ├─ usr/ pacstrap └─ var/
⚠ CRITICAL ORDER: Mount / (loop0p2) BEFORE creating /mnt/boot and mounting loop0p1 inside it!
PRESENTER NOTES
LAB 4.2 — Step 4: Mounting partitions

CRITICAL ORDER: mount root FIRST, then create /mnt/boot, then mount EFI inside it.
  sudo mount /dev/loop0p2 /mnt            ← root first
  sudo mkdir -p /mnt/boot                 ← create dir inside mounted root
  sudo mount /dev/loop0p1 /mnt/boot       ← EFI inside

Verify with:  findmnt /mnt  and  df -h /mnt /mnt/boot

Warning: if you create /mnt/boot before mounting loop0p2, it will be inside the live system, not the new root.
34 LAB 4.2b Mounting a partition inside a user home directory & /etc/fstab

How to permanently mount a partition into /home/username/directory — and configure fstab mount options

1

Create the mount point directory

The directory must exist before mounting:

$ mkdir -p /home/alice/data
2

Test-mount manually first

Always verify the partition works before editing fstab:

$ sudo mount /dev/sdb1 /home/alice/data $ ls /home/alice/data # verify it works $ sudo umount /home/alice/data
3

Get the partition UUID

Always use UUID in fstab — device names (/dev/sdb1) can change after reboot:

$ blkid /dev/sdb1 /dev/sdb1: UUID="a1b2c3d4-..." TYPE="ext4"
4

Add an entry to /etc/fstab

$ sudo nano /etc/fstab
5

Test without rebooting

$ sudo mount -a # mount all fstab entries $ findmnt /home/alice/data # verify

fstab entry format — 6 fields:

UUID=a1b2... /home/alice/data ext4 defaults,nofail 0 2
[1] device[2] mountpoint[3] fstype[4] options[5] dump[6] pass

Key mount options (field 4):

defaultsrw, suid, dev, exec, auto, nouser, async
nofailboot succeeds even if drive is missing
noatimedo not update access timestamps (faster)
uid=1000,gid=1000force ownership (FAT32/NTFS only)
x-systemd.automountmount on first access (lazy)

dump / pass fields:

dump = 0always 0 — legacy backup flag, ignored today
pass = 0skip fsck on boot (use for extra drives)
pass = 1fsck root (/) first
pass = 2fsck other partitions after root
⚠ WARNING: A typo in fstab can prevent the system from booting!
Always run mount -a to catch errors before reboot.
PRESENTER NOTES
LAB 4.2b — Mounting a partition inside a user home directory and configuring /etc/fstab

Key teaching points:
- The mountpoint directory MUST exist before mounting — always create it with mkdir -p first
- Always test-mount manually before editing fstab, to verify the partition and filesystem are healthy
- Use UUID (not /dev/sdXN) in fstab — device names can change between reboots if drives are reordered
- The nofail option is critical for extra drives in /home — without it, a missing drive will drop the system into emergency mode at boot
- Always run: sudo mount -a   after editing fstab to catch typos BEFORE the next reboot

fstab field explanation:
  1. device    — UUID=... (from blkid) or /dev/sdXN
  2. mountpoint — absolute path, must exist
  3. fstype    — ext4, vfat, btrfs, ntfs-3g, etc.
  4. options   — comma-separated flags (defaults,nofail,noatime...)
  5. dump      — always 0 (legacy, ignored)
  6. pass      — 0=skip fsck, 1=check root first, 2=check after root
35 LAB 4.3 Step 5: pacstrap — install base system

pacstrap downloads and installs Arch Linux packages directly into /mnt.

# -K = initialize a new pacman keyring in /mnt # base = minimal Arch userland # linux = the kernel # linux-firmware = hardware firmware blobs $ sudo pacstrap -K /mnt base linux linux-firmware # Recommended: add useful tools in the same command $ sudo pacstrap -K /mnt base linux linux-firmware \ vim nano grub efibootmgr networkmanager

MINIMUM REQUIRED

base linux linux-firmware

ALSO INSTALL

grub efibootmgr networkmanager vim

IF pacstrap FAILS

ping archlinux.org
then reflector to update mirrors

PRESENTER NOTES
LAB 4.3 — Step 5: pacstrap

pacstrap downloads and installs Arch base packages directly into /mnt (the new root):
  sudo pacstrap -K /mnt base linux linux-firmware
  -K = initialise a fresh pacman keyring in /mnt

Recommended extras: vim nano grub efibootmgr networkmanager

This step requires internet. If it fails:
  - Check: ping archlinux.org
  - Update mirrors: reflector --save /etc/pacman.d/mirrorlist
36 LAB 4.4 Steps 6–7: genfstab and arch-chroot

Step 6 — Generate /etc/fstab

$ genfstab -U /mnt >> /mnt/etc/fstab $ cat /mnt/etc/fstab # verify! UUID=aaaa / ext4 rw,relatime 0 1 UUID=bbbb /boot vfat rw,relatime 0 2

Step 7 — chroot into new system

$ sudo arch-chroot /mnt # You are now INSIDE the new system! [root@archiso /]# # Set timezone [root@archiso /]# ln -sf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime [root@archiso /]# hwclock --systohc # Set hostname [root@archiso /]# echo 'myhostname' > /etc/hostname # Set root password [root@archiso /]# passwd # Enable NetworkManager [root@archiso /]# systemctl enable NetworkManager

arch-chroot vs plain chroot

arch-chroot is smarter than plain chroot — it automatically bind-mounts /proc /sys /dev /run inside the new root. Always use arch-chroot.

genfstab -U

The -U flag uses UUIDs (not device names). Always verify with cat before proceeding — an empty or wrong fstab will prevent the system from booting.

PRESENTER NOTES
LAB 4.4 — Steps 6–7: genfstab and arch-chroot

genfstab -U /mnt >> /mnt/etc/fstab
  Generates the filesystem table using UUIDs. ALWAYS verify the output with: cat /mnt/etc/fstab

arch-chroot /mnt
  Smarter than plain chroot — auto-binds /proc, /sys, /dev, /run into the new root.
  After this you are INSIDE the new system!

Inside chroot: set timezone, hostname, root password, enable NetworkManager.
These are the minimum steps for a bootable system.
37 LAB 4.5 Step 8: install GRUB bootloader
# Inside arch-chroot! # Install GRUB EFI binary [root@archiso /]# grub-install \ --target=x86_64-efi \ --efi-directory=/boot \ --bootloader-id=ARCH \ --removable # Generate GRUB config [root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-linux Found initrd image: /boot/initramfs-linux.img done # Verify EFI file was created [root@archiso /]# ls /boot/EFI/BOOT/ BOOTX64.EFI
FlagMeaning
--target=x86_64-efiEFI mode (use i386-pc for BIOS/MBR)
--efi-directory=/bootwhere EFI partition is mounted
--bootloader-id=ARCHlabel in UEFI firmware menu
--removablewrites fallback EFI path BOOTX64.EFI
--removable is ESSENTIAL for loop device installs. Without it, GRUB registers with the HOST machine's UEFI — the loop image won't be portable.
PRESENTER NOTES
LAB 4.5 — Step 8: GRUB bootloader

grub-install flags:
  --target=x86_64-efi       EFI mode (use i386-pc for legacy BIOS)
  --efi-directory=/boot     where the EFI partition is mounted
  --bootloader-id=ARCH      label shown in UEFI firmware menu
  --removable               writes to /boot/EFI/BOOT/BOOTX64.EFI (fallback path)

IMPORTANT: --removable is ESSENTIAL for loop device installs.
Without it, GRUB registers itself with the HOST machine's UEFI firmware.

Then: grub-mkconfig -o /boot/grub/grub.cfg  (generates the menu)
38 LAB 4.6 Finish installation and test with QEMU
# Still inside arch-chroot [root@archiso /]# echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen [root@archiso /]# locale-gen [root@archiso /]# echo 'LANG=en_US.UTF-8' > /etc/locale.conf [root@archiso /]# exit # Back on host — unmount in REVERSE order! $ sudo umount /mnt/boot $ sudo umount /mnt $ sudo losetup -d /dev/loop0 # Test with QEMU (optional) $ qemu-system-x86_64 \ -drive file=arch.img,format=raw \ -m 2G \ -bios /usr/share/ovmf/OVMF.fd \ -nographic

VERIFY WITHOUT QEMU

$ sudo losetup -P --find --show arch.img $ sudo mount /dev/loop0p2 /mnt $ sudo mount /dev/loop0p1 /mnt/boot $ ls /mnt/boot vmlinuz-linux initramfs-linux.img EFI/ grub/ $ sudo umount /mnt/boot /mnt $ sudo losetup -d /dev/loop0
Unmount order: reverse of mount order. umount /mnt/boot then umount /mnt — never the other way!
PRESENTER NOTES
LAB 4.6 — Finish installation and test with QEMU

Inside chroot: set locale and LANG, then exit.

Back on host — unmount in REVERSE ORDER (innermost first!):
  umount /mnt/boot   ← boot first
  umount /mnt        ← root last
  losetup -d /dev/loop0

Test with QEMU (optional) or verify by re-mounting and checking /mnt/boot contents.
39–41 SUMMARY Complete Command Reference

Loop device

fallocate -l 4G file.img # create disk file losetup -P --find --show f # attach + scan losetup -l # list loop devices losetup -d /dev/loop0 # detach

Partitioning

fdisk /dev/loop0 # interactive parted -s /dev/loop0 mklabel gpt parted -s /dev/loop0 mkpart primary 1MiB 513MiB lsblk /dev/loop0 # verify

Filesystems

mkfs.vfat -F 32 /dev/loop0p1 # FAT32 for EFI mkfs.ext4 /dev/loop0p2 # ext4 lsblk -f # show FS types blkid /dev/loop0p2 # show UUID

Mounting

mount /dev/loop0p2 /mnt # mount root mount /dev/loop0p1 /mnt/boot # mount EFI findmnt /mnt # show tree umount /mnt/boot && umount /mnt

Arch install (minimal)

pacstrap -K /mnt base linux linux-firmware grub efibootmgr genfstab -U /mnt >> /mnt/etc/fstab arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --removable grub-mkconfig -o /boot/grub/grub.cfg

Arch install (full desktop)

pacstrap -K /mnt ntfs-3g firejail vlc steam signal-desktop \ nextcloud-client sof-firmware git cargo \ extra/plasma-meta extra/kde-applications-meta plasma-nm
PRESENTER NOTES
SUMMARY — Complete command reference (3 pages in PPTX)

Page 1: loop device, partitioning, filesystem, mounting commands — cheat sheet for the lab.
Page 2: minimal pacstrap package set (base linux linux-firmware grub efibootmgr net-tools dhclient nano mc)
Page 3: extended full KDE desktop install — shown as a real-world example. Students do NOT need to run all of this for the lab.
42 REFERENCE Common Errors and Fixes

losetup: /dev/loop0 is busy

Maybe still mounted. Run umount first, then:

losetup -d /dev/loop0

mount: /dev/loop0p1 does not exist

The -P flag scans for partition nodes. Use:

losetup -P --find --show disk.img

mkfs: disk.img contains a filesystem

Use the PARTITION, not the disk file:

mkfs.ext4 /dev/loop0p2 not disk.img

grub-install: EFI variables not supported

Add the removable flag, or load the module:

grub-install --removable
modprobe efivars

pacstrap: failed to retrieve files

Check internet, then update mirror list:

ping archlinux.org
reflector --save /etc/pacman.d/mirrorlist

umount: target is busy

Kill processes using the mount:

fuser -km /mnt
or lsof +D /mnt

PRESENTER NOTES
REFERENCE — Common errors and fixes

Six error cards, each with cause and fix:
  1. losetup: /dev/loop0 is busy → umount first, then losetup -d
  2. mount: /dev/loop0p1 does not exist → use losetup -P to scan partition nodes
  3. mkfs: disk.img contains a filesystem → format the partition (p1/p2), not the raw image
  4. grub-install: EFI variables not supported → add --removable flag
  5. pacstrap: failed to retrieve files → check internet, update mirrors with reflector
  6. umount: target is busy → kill blocking processes with fuser -km /mnt or lsof +D /mnt