Skip to content

Instantly share code, notes, and snippets.

@flbuddymooreiv
Last active February 20, 2025 19:34
Show Gist options
  • Save flbuddymooreiv/01ceaee67bd91cd6beed to your computer and use it in GitHub Desktop.
Save flbuddymooreiv/01ceaee67bd91cd6beed to your computer and use it in GitHub Desktop.
CryptSetup / LUKS cheat sheet
# Install the tools
apt-get install cryptsetup

# -y for password confirmation prompt
cryptsetup -y -v luksFormat /dev/sdx # THIS DELETES ALL THE DATA

# Open it and look at status
cryptsetup luksOpen /dev/sdx cryptoblock
cryptsetup -v status cryptoblock

# Zero the contents device (looks like random data to keyless observers)
# `killall -USR1 dd` will print status
dd if=/dev/zero of=/dev/mapper/cryptoblock bs=128M

# Put a filesystem on it
mkfs.ext4 /dev/mapper/cryptoblock

# Mount it
mkdir /mnt/cryptoblock
mount /dev/mapper/cryptoblock /mnt/cryptoblock

# Unmount it
umount /mnt/cryptoblock

# Unmap it
cryptsetup luksClose cryptoblock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment