How to mount and unmount a LUKS encrypted USB

Published: 2021-12-03 | Last Updated: 2022-02-11 | ~2 Minute Read

Introduction

This is a very simple and to the point guide about how to use a LUKS encrypted drive from the command line. I write this since I recently had to use it and the specific commands escaped my memory due to not using this often enough.

For this you will need some programs installed on your computer, mainly cryptsetup. Slackware has this program installed as part of its full installation.

Mounting the USB drive

In order to mount the USB drive you need to run the following as the root user:

# cryptsetup luksOpen /dev/sdx1 name-of-volume

Once you have done this, the mounting process should work the same as with non encrypted drives but using the /dev/mapper mapper path as source:

# mount /dev/mapper/name-of-volume /tmp/usb-mount-folder

At this point you should be able to see the contents of the USB drive as usual.

Unmounting the USB drive

Once you are done using your USB drive or other mounted media you have to apply the same steps in a reverse order.

First unmount the drive as you normally would for a drive not using any type of encryption:

# umount /tmp/usb-mount-folder

And then close the LUKS volume:

# cryptsetup luksClose name-of-volume

At this point you can confirm that the USB drive is no longer mounted by checking the output of df -h and unplug your USB drive.

Conclusion

These set of commands are very simple and should be hard to forget, but just in case it does happen again the future, I can come here to check on my notes.

Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~grokkingnix/blog@lists.sr.ht [mailing list etiquette] [mailing list archive]


Posts from blogs I follow:

Free software licenses explained: MIT

This is the first in a series of posts I intend to write explaining how various free and open source software licenses work, and what that means for you as a user or developer of that software. Today we’ll look at the MIT license, also sometimes referred to …

via Drew DeVault's blog February 7, 2022
Introducing a Falkon extension RSS Finder

This weekend I decided to semi automate the process of searching for RSS feeds on websites while using Falkon web brosers. Many websites provide RSS feeds but do not provide any visible link or icon to access them (eg. many Wordpress based sites) and I ha…

via My land January 23, 2022
A warning to business owners and managers, you are a big part of the problem!

In my last couple of articles, mainly So-called modern web developers are the culprits and Is the madness ever going to end? I have written about some of the major problems with so-called modern web development and I have addressed the issues to the devel…

via unixsheikh.com January 13, 2022

Generated by openring