← Back to section · Tutorials & Labs
Version Pinning and Snapshots for Your Lab Environment
A four-layer pinning method for reproducible environments: system packages, language packages, source commits and image digests fixed layer by layer, paired with a snapshot strategy and a rollback drill, so any experiment can return to the environment state it ran in.
The longer you run experiments, the more you meet a class of ghost problems: a workflow that passed last week fails this week for no visible reason; two machines run the same code and produce different numbers. Nine times out of ten the code did not change — the environment did: some package got upgraded, some build pulled a fresh commit. Version pinning and snapshots are the two tools against this: pinning keeps the environment from changing, snapshots let you go back after it has. This tutorial lays out a pinning method in four layers, a way to write an environment manifest, and the snapshot strategy that goes with them.
The Four Layers of Pinning
Layer one is system packages. On Debian / Ubuntu, install with the version written out: sudo apt install -y cmake=3.28.3-1build7 in package=version form (take the exact version string from apt-cache policy cmake for your repository); afterwards lock it with sudo apt-mark hold cmake so a later blanket upgrade cannot carry it away. For a full record, the output of dpkg -l is the complete system package inventory. Layer two is language packages: inside a Python environment, run pip freeze > requirements.txt to freeze the exact version combination into a file, and rebuild later with pip install -r requirements.txt — never record package names without versions. Layer three is sources: for every component built from a Git repository (liboqs, oqs-provider and the like), record the full commit hash with git rev-parse HEAD and check out with git checkout <hash> rather than sitting on a branch tip — branch tips move daily, a hash is a coordinate. Layer four is containers: reference images by digest instead of tag; get the digest from docker images --digests and record and reference the image as name@sha256:.... Only when all four layers are fixed is the environment truly pinned; if an experiment pins only one or two layers, its conclusions should state which layers were left unpinned.
Writing the Environment into a Manifest File
Pinning actions must settle into a file. Keep an ENVIRONMENT.md in the experiment directory containing: operating system version, kernel version, CPU model and instruction sets, compiler and CMake versions, OpenSSL version, the commit hashes of key source components, the Python requirements filename, and image digests. Generate it from command output, never by typing from memory: redirect the output of gcc --version, cmake --version, openssl version and friends straight into the file — hand transcription guarantees typos. Archive the manifest together with the experiment data. When reproducing the experiment later, rebuild the environment from the manifest, tick each item off, and only then run the workflow. If some version is no longer installable on the new machine (removed from the repository, superseded), the manifest also narrows the difference down to a specific line, turning “the environment differs” from a guess into a fact.
Snapshot Strategy: A Way Back from Every Change
Pinning governs intentional consistency; snapshots govern accidental damage. Take a snapshot before any high-risk operation — upgrading system packages, changing build configuration, trying a new component version. Choose the mechanism by environment shape: virtual machines use the hypervisor’s own snapshot feature (VirtualBox snapshots, qemu-img snapshots for QEMU), restoring in minutes; bare-metal or out-of-container directory state is preserved with dated tar archives or rsync copies of the key directories (source trees, the CA directory, experiment data); Docker environments get natural snapshot points from image digests — keep old images, give new builds new tags. Name snapshots uniformly with date and reason, e.g. 2026-11-22-before-openssl-upgrade, so they still make sense three months later. Keep a retention discipline too: snapshots are not “the more the better” — for each experiment, keep the “before it started” and “when conclusions were drawn” points and clean up the rest promptly, or the disk is eaten by snapshots first.
Rollback Drills and Common Misconceptions
A snapshot strategy counts as established when a restore has actually succeeded once, not when the button has been clicked. Before the first real experiment series, run a drill: take a snapshot, deliberately break one piece of configuration (uninstall a package, say), restore from the snapshot, and run the verification commands to confirm the environment is back. Drills commonly expose problems such as: the snapshot covered the system disk but not the data disk, services did not restart after the restore, or an overlong VM snapshot chain tanks performance — discoveries that are tuition in a drill and accidents in a real experiment. Three more misconceptions to name: treating snapshots as long-term backups (a snapshot lives and dies with its disk; when the disk fails the snapshot is gone too, so important data still needs independent backups); continuing an experiment after a restore without re-verification (the restore itself must be verified); and leaving snapshots hanging on long-running systems (an aged snapshot keeps growing and drags down IO — on lab machines, delete or merge them when the work is done).
Detecting That a Pin Has Quietly Failed
The worst pinning failure is not the absence of pins but pins that quietly work loose. Slippage usually enters through three doors: a distribution security update carries off a minor version of some library dependency; a language-package install resolves a transitive dependency to a newer version under a floating constraint; a source tree gets a casual git pull onto a new commit. Detect it by regular reconciliation: turn the manifest-generation commands into a small script, run it weekly or before every important experiment, and diff the output against the archived manifest — if any line disagrees, stop; data produced before the difference is explained should be marked as suspect. Reconciliation pays a second dividend: it tests the pinning mechanism itself. If a package marked with apt-mark hold was upgraded anyway, a higher-priority repository is at work, and the pinning strategy itself needs upgrading (for instance, reinstalling with the version written into the command). Make reconciliation routine and pinning becomes a continuously true state rather than a one-off configuration.
Wrapping Up
Pinning and snapshots together are a form of time management: pinning holds the environment at chosen coordinates, snapshots make misoperations reversible. Fix the execution order as a habit — write the environment manifest when a new experiment starts, snapshot before dangerous operations, and store a fresh manifest plus snapshot when conclusions are drawn — and “the environment changed” disappears from your lab notebook. For pinning at the Docker image layer in detail, see the companion article on this site.
Tags: Version PinningSnapshotsReproducibilityEnvironment Management