September 22, 2024

Mount, unmount and power-off a LUKS-encrypted volume

Find the name of the volume

First you might need to find out the name of the volume, to do so, run:

$ lsblk

You can recognize the volume by its size.

Open the volume

Next, you need cryptsetup to open the volume (the drive).

$ sudo apt-get install cryptsetup

Then open the volume:

$ sudo cryptsetup luksOpen /dev/sdaX decrypted_volume

You can use lsblk again to check that decrypted_volume is nested under sdbX.

The name decrypted_volume is arbitrary.

Mount the volume

First create a folder where you’ll mount the volume:

$ sudo mkdir /media/device

Then mount the device on that point:

$ sudo mount /dev/mapper/decrypted_volume /media/device

The name device is arbitrary.

Encrypt and Unmount

To encrypt the volume, it needs to be unmounted first:

sudo umount /media/device

You can check that device is no longer mounted:

mount | grep sdbX

Now close the volume:

sudo cryptsetup luksClose decrypted_volume

check that decrypted_volume is closed:

$ lsblk

Power-off the USB device

Now power-off the device (this has to do with the connectivity of the USB port - you MUST unmount before powering off).

First download the package which contains the utility udisksctl:

sudo apt install udisks2

Then power off the device

udisksctl power-off -b /dev/sdbX

personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki backintime

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88