Install cryptsetup
apt install cryptsetup -y
Identify which partition
fdisk -l
...
Disk /dev/sdc: 931,48 GiB, 1000170586112 bytes, 1953458176 sectors
Disk model: Elements 25A2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Umount the partition (if necessary)
umount /dev/sdc1
Edit partition table
fdisk /dev/sdc
Command (m for help): n
Select (default p): p
Command (m for help): w
cryptsetup --verbose luksFormat --type luks2 /dev/sdc1 --verify-passphrase
WARNING!
========
This will overwrite data on /dev/sdc1 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /dev/sdc1:
Verify passphrase:
Existing 'crypto_LUKS' superblock signature (offset: 0 bytes) on device /dev/sdc1 will be wiped.
Existing 'crypto_LUKS' superblock signature (offset: 16384 bytes) on device /dev/sdc1 will be wiped.
Key slot 0 created.
Command successful.
cryptsetup -v luksOpen /dev/sdc1 luks-sto2-bck
Enter passphrase for /dev/sdc1:
Key slot 0 unlocked.
Command successful.
Format the partition that we just encrypt
mkfs.ext4 -L luks-sto2-bck /dev/mapper/luks-sto2-bck
Ouvrir et monter la partition chiffrée
mkdir /media/jescoffier/luks-sto2-bck -p
mount /dev/mapper/luks-sto2-bck /media/jescoffier/luks-sto2-bck/ -v
chown -R jescoffier:jescoffier /media/jescoffier/luks-sto2-bck
cryptsetup -v luksClose luks-sto2-bck
LUKS cannot mount device (File exist)
USER@HOSTNAME:$ sudo dmsetup ls --tree
HOSTNAME--vg-root (254:1)
└─nvme0n1p3_crypt (254:0)
└─ (259:3)
HOSTNAME--vg-swap_1 (254:2)
└─nvme0n1p3_crypt (254:0)
└─ (259:3)
luks-058fb581-adf1-4588-bf0d-18b4eb35e65e (254:3) <- External USB LUKS encrypted disk
└─ (8:1)
USER@HOSTNAME:$ sudo lsof |grep 254,3
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
lsof: WARNING: can't stat() fuse.portal file system /run/user/1000/doc
Output information may be incomplete.
bash 105083 jescoffier cwd DIR 254,3 4096 19136513 /faulty_folder <- Not real name obviously
In this specific case you have 2 choices:
If still have these messages
Mar 4 10:54:46 HOSTNAME udisksd[679]: Error probing device: Error sending ATA command IDENTIFY DEVICE to '/dev/sdb': Unexpected sense data returned:#0120000: 70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 p...............#0120010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................#012 (g-io-error-quark, 0)
Mar 4 10:54:46 HOSTNAME fwupd[1984]: 09:54:46:0262 FuDeviceList ignoring device ada802f438db2b9d8fa5aab6462922dc6708f24d [ata:(null)] existing device a3957c3ae533b1a740ecfa31d7aef93fb6a8eb9e [ata:(null)] already exists
Mar 4 10:54:48 HOSTNAME udisksd[679]: Cleaning up LUKS device /dev/dm-3 (backing device 8:1 no longer exists)
Mar 4 10:54:48 HOSTNAME gnome-shell[1687]: Unable to mount volume 500 GB Encrypted: Gio.IOErrorEnum: Error unlocking /dev/sdb1: Failed to activate device: File exists
Try to unlock the device manually:
sudo udisksctl unlock -b /dev/sdb1
passhrase: