Installing cryptsetup
Outcome: a cryptsetup command that
runs and states its version, plus the
throwaway practice file every later
chapter uses. The program first; the
disks — real or pretend — after.
The package
cryptsetup is ordinary distribution software, not a download from a project site. On Debian, Ubuntu and their relatives:
sudo apt install cryptsetup
On Fedora and its relatives the same
name works with sudo dnf install
cryptsetup; on Arch it is in the base
system more often than not. There is
nothing to configure afterwards: the
package is a command-line tool plus
its library, and it talks to the
kernel only when you ask it to open
something (chapter 5).
One warning that belongs in this
chapter and nowhere later, because
later is too late: nearly every command
in this guide needs root. You will see
sudo in front of real-disk work on
your machine. The lab ran as root
already, so its transcripts omit it —
add it back in your head as you read
them.
The version check
cryptsetup --version
The lab's answer:
cryptsetup 2.7.0 flags: UDEV BLKID KEYRING FIPS KERNEL_CAPI HW_OPAL
Version 2.7.0 is what wrote every
transcript in luks-lab/transcripts/.
The flags after the number describe
optional features compiled in; you do
not need to memorise them, but the
version itself matters for one reason:
LUKS2 has been the default format
since cryptsetup 2.1, so anything 2.x
will behave as this guide describes.
Older 1.x tools still open LUKS2
devices poorly or not at all — check
before you borrow a rescue system.
The practice file
Every distribution installer will
happily let you point cryptsetup at a
real disk, and luksFormat believes
you: pointed at the wrong device, it
will destroy a filesystem without a
moment's doubt about its correctness.
So this guide never practices on a
disk. It uses an ordinary file, filled
with zeros, as a pretend device:
mkdir luks-labwork && cd luks-labwork
dd if=/dev/zero of=vault.img bs=1M count=64
64 MB is large enough for a header (16 MB) and a meaningful stretch of data segment, small enough to copy, corrupt and restore freely — chapters 5 and 8 do all three. On a real machine this file can also be attached as a loop device and opened for real; the lab's sandbox had no loop devices, so its open step is the documented one (chapter 5, transcript t08).
The lab's own working copies of this
file went further: vault1.img for the
LUKS1 comparisons of chapter 4, and
vault-copy.img, the sacrificial twin
whose header chapter 8 destroys and
restores. Make the same habit yours:
never rehearse on the only copy of
anything.
A note on the lab's own install
Honesty about the evidence, once:
this guide's lab machine is a shared
sandbox whose package system was
repeatedly reset by other tenants
while the lab ran — cryptsetup was
installed from the distribution
archive, vanished mid-lab, and was
finally fetched as the distribution's
own .deb and unpacked into the lab
folder, running as the identical
binary against the identical system
libraries. The version string above is
the same by both routes.
criteria.md records the details; the
commands and outputs in the
transcripts are unaffected — but a
guide that teaches "verify, don't
assume" should say how its own tool
arrived.