Classroom / Training Lab — every student gets a fresh machine every class, in seconds.
You teach a Linux class. 30 students. By the end of the first lab, half of them have broken something. Traditionally, you reimage 30 machines overnight. Or you use VMs and pray the host has enough RAM. With kldload and ZFS, you snapshot the golden image before class, let students destroy things freely, and roll back every workstation in seconds. Students learn by breaking things. You recover by typing one command.
The recipe
Step 1: Build the golden image
# Install one workstation with everything students need
# Boot the kldload USB, pick desktop profile
# Install course-specific packages
kpkg install gcc make gdb python3 python3-pip nodejs git vim
# Create a student home directory template
kdir /home/student
cp -r /root/course-materials /home/student/
chown -R 1000:1000 /home/student
# Configure the system exactly how you want it
# Set wallpaper, bookmarks, terminal preferences, etc.
# Take the golden snapshot
zfs snapshot -r rpool@golden-$(date +%Y%m%d)
# This is your master image. Everything resets to this.
Step 2: Deploy to 30 workstations
# Option A: Boot each workstation from the kldload USB
# and install with unattended mode (same answers file)
# Option B: Send the golden image over the network
# From the golden machine, send to each workstation
for i in $(seq 1 30); do
echo "Deploying to ws-${i}..."
zfs send -R rpool@golden-20260323 | \
ssh ws-${i} "zfs recv -F rpool" &
done
wait
echo "All 30 workstations deployed."
# Each workstation is now an exact copy of the golden image
# Takes minutes, not hours. Only limited by network speed.
Step 3: Per-student datasets with quotas
# On each workstation (or run from the instructor's machine via SSH)
# Create per-student datasets so their work is isolated
# Script to set up a class roster
cat > /usr/local/bin/classroom-setup.sh <<'SETUP'
#!/bin/bash
set -euo pipefail
ROSTER="$1" # File with one username per line
while read -r student; do
echo "Setting up ${student}..."
# Create student dataset
zfs create -o quota=5G rpool/home/${student}
# Copy course materials
cp -r /home/student/course-materials /home/${student}/
# Create the user account
useradd -m -d /home/${student} -s /bin/bash "${student}"
echo "${student}:changeme" | chpasswd
chage -d 0 "${student}" # Force password change on first login
chown -R ${student}:${student} /home/${student}
done < "${ROSTER}"
SETUP
chmod +x /usr/local/bin/classroom-setup.sh
# Create the roster and deploy
seq -f "student%02g" 1 30 > /tmp/roster.txt
classroom-setup.sh /tmp/roster.txt
Step 4: The instructor workflow — snapshot, class, rollback
# BEFORE CLASS: Take the pre-class snapshot
# Run this on the instructor machine, targeting all workstations
cat > /usr/local/bin/classroom-snapshot.sh <<'SNAP'
#!/bin/bash
set -euo pipefail
TAG="${1:-pre-class-$(date +%Y%m%d-%H%M)}"
for i in $(seq 1 30); do
ssh ws-${i} "zfs snapshot -r rpool@${TAG}" &
done
wait
echo "Snapshot '${TAG}' created on all 30 workstations."
SNAP
chmod +x /usr/local/bin/classroom-snapshot.sh
# Take the snapshot
classroom-snapshot.sh pre-lab-03
# === CLASS HAPPENS HERE ===
# Students break things. That's the point.
# AFTER CLASS: Roll back every workstation
cat > /usr/local/bin/classroom-rollback.sh <<'ROLL'
#!/bin/bash
set -euo pipefail
TAG="${1}"
for i in $(seq 1 30); do
ssh ws-${i} "zfs rollback -r rpool@${TAG}" &
done
wait
echo "All 30 workstations rolled back to '${TAG}'."
ROLL
chmod +x /usr/local/bin/classroom-rollback.sh
# Reset everything
classroom-rollback.sh pre-lab-03
# 30 workstations, rolled back in seconds. Ready for the next class.
Step 5: Preserve student work before rollback
# Sometimes you want to keep student submissions before resetting
cat > /usr/local/bin/classroom-collect.sh <<'COLLECT'
#!/bin/bash
set -euo pipefail
ASSIGNMENT="$1" # e.g., "lab-03"
DEST="/srv/submissions/${ASSIGNMENT}"
mkdir -p "${DEST}"
for i in $(seq 1 30); do
student=$(printf "student%02d" ${i})
echo "Collecting from ${student} on ws-${i}..."
scp -r ws-${i}:/home/${student}/submit/ "${DEST}/${student}/" 2>/dev/null || \
echo " No submission from ${student}"
done
echo "Submissions collected to ${DEST}"
COLLECT
chmod +x /usr/local/bin/classroom-collect.sh
# Collect submissions
classroom-collect.sh lab-03
# NOW rollback safely
classroom-rollback.sh pre-lab-03
Step 6: Different golden images per course
# Keep multiple golden snapshots for different courses
zfs snapshot -r rpool@golden-linux101
zfs snapshot -r rpool@golden-python201
zfs snapshot -r rpool@golden-security301
# Switch an entire lab to a different course in seconds
classroom-rollback.sh golden-python201
# Monday: Linux 101 (C, gcc, make)
# Tuesday: Python 201 (Python3, Jupyter, pandas)
# Wednesday: Security 301 (Wireshark, nmap, Metasploit)
# Same hardware. Different golden images. Instant switch.
Why this changes everything for education
Students can break things
The entire point of learning is experimentation. When rollback takes seconds, you stop saying "don't touch that" and start saying "try it and see what happens."
Zero overnight reimaging
No more staying late to reimage 30 machines. Rollback is instant. The lab is ready for the next class before you finish packing your bag.
Per-student isolation
Each student has their own dataset with a quota. One student can't affect another. One student can't fill the disk for everyone.
Multi-course labs
Different golden images for different courses. Switch the entire lab between courses in seconds. One room serves every department.