[SOLVED] Mounting an encrypted drive

droidus

Well-Known Member
Apr 5, 2020
112
2
58
35
I am trying to mount an encrypted drive on Proxmox. Here is the tutorial that I am following: https://averagelinuxuser.com/encrypt-hard-drive-in-linux/. I am running PVE 6.3-3. I've done this type of thing before, but on PVE, it seems like it has to be done differently... when I get to the "mount /dev/mapper/sdb1 /mnt/encrypted" step, then do a df . -h in that directory, it reports on /dev/mapper/pve-root. I can't figure out why it is doing this... it seems like it is not mounting to that specified local directory. I even add verbosity to the command, but it just says "mount: /dev/mapper/sda1 mounted on /mnt/hd." The "df" command should report almost 1 tb, but it's reporting less than 100gb.
 
hi,

can you post the output of lsblk -f?

is your partition actually called /dev/sdb1 ?
 
Sure:
Code:
lsblk -f
NAME                                                                 FSTYPE      LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINT
sda                                                                                                                                         
└─sda1                                                               crypto_LUKS       61044672-b4ef-4c96-b7c7-d49aa93185e4                 
  └─sda1                                                             ext4              83adff7e-062b-423f-9527-073d75c85064                 
sdb                                                                                                                                         
├─sdb1                                                                                                                                       
├─sdb2                                                               vfat              13AC-6EE2                               510.7M     0% /boot/efi
└─sdb3                                                               LVM2_member       gBYPnI-37nh-yaae-DdQ9-I2my-mh1G-LsC51C               
  ├─pve-swap                                                         swap              82b037c1-26b1-4e55-a6db-70c1dcb73db3                  [SWAP]
  ├─pve-root                                                         ext4              d1e46b00-86f1-48c5-9b64-09a70abb68f3     31.5G    61% /
  ├─pve-data_tmeta                                                                                                                           
  │ └─pve-data-tpool                                                                                                                         
  │   ├─pve-data                                                                                                                             
  │   ├─pve-vm--102--disk--0
...

It is actually sda1.
 
ok assuming you want to encrypt the whole /dev/sda drive, you can do the following (to start over. please move any data if already used)
Code:
cryptsetup luksFormat /dev/sda1
cryptsetup luksOpen /dev/sda1 mydisk
mkfs.ext4 /dev/mapper/mydisk
tune2fs -m 0 /dev/mapper/mydisk
mkdir /mnt/encrypted
mount /dev/mapper/mydisk /mnt/encrypted

now you should have the encrypted drive mounted on /mnt/encrypted where you can copy/move files

when you're done with the disk just run umount /mnt/encrypted && cryptsetup luksClose mydisk

to remount it run cryptsetup luksOpen /dev/sda1 mydisk && mount /dev/mapper/mydisk /mnt/encrypted again

if you want to use it persistently you have to add it to your /etc/fstab or /etc/crypttab
 
Last edited:
  • Like
Reactions: droidus
ok assuming you want to encrypt the whole /dev/sda drive, you can do the following (to start over. please move any data if already used)
Code:
cryptsetup luksFormat /dev/sda1
cryptsetup luksOpen /dev/sda1 mydisk
mkfs.ext4 /dev/mapper/mydisk
tune2fs -m 0 /dev/mapper/mydisk
mkdir /mnt/encrypted
mount /dev/mapper/mydisk /mnt/encrypted

now you should have the encrypted drive mounted on /mnt/encrypted where you can copy/move files

when you're done with the disk just run umount /mnt/encrypted && cryptsetup luksClose mydisk

to remount it run cryptsetup luksOpen /dev/sda1 mydisk && mount /dev/mapper/mydisk /mnt/encrypted again

if you want to use it persistently you have to add it to your /etc/fstab or /etc/crypttab
Great, this worked, thank you! :)