Enabling Disk Encryption in a Nutshell

Daniel
2 min readNov 30, 2021
Security Flashcard explaining how to create an encrypted device on the Linux command line.
Instructions to encrypt a device on the command line. (source: https://security-flashcards.com)

The goal of this article is to present the minimal steps required to create an encrypted filesystem on a USB drive on Ubuntu. It is intended for people who are already familiar with the basic concepts and don’t need an explanation for each single step.

The Nutshell — Create an Encrypted Device

Let’s assume your device is /dev/sdb9. Then, perform the following steps as root to create an encrypted filesystem on that device.

cryptsetup luksFormat /dev/sdb9
cryptsetup luksOpen /dev/sdb9 mydrive
mkfs.ext4 /dev/mapper/mydrive -L labelofdrive -m 0
cryptsetup luksClose mydrive

Now, the next time you connect the device to your computer you will be asked for the password.

Introduction

Does the following sound familiar to you?

Occasionally, you get a new device, you want to create an encrypted filesystem on that device so that the content is protected in case you lose it but you can’t remember the exact commands? You start to search with Google and a lot of articles pop up that contain a lot of noise. You have to go through all the noise to grab just the piece of information you are looking for. Welcome to my world.

--

--