0

Everytime i decrypt my luks drive the partition is not showing up:

cryptsetup -v luksOpen /dev/md0 md0_crypt

lsblk
sdb                             8:16   0   3,7T  0 disk  
└─sdb1                          8:17   0   3,7T  0 part  
  └─md0                         9:0    0   7,3T  0 raid5 
    └─md0_crypt               253:11   0   7,3T  0 crypt 
sdc                             8:32   0   3,7T  0 disk  
└─sdc1                          8:33   0   3,7T  0 part  
  └─md0                         9:0    0   7,3T  0 raid5 
    └─md0_crypt               253:11   0   7,3T  0 crypt 
sdd                             8:48   0   3,7T  0 disk  
└─sdd1                          8:49   0   3,7T  0 part  
  └─md0                         9:0    0   7,3T  0 raid5 
    └─md0_crypt               253:11   0   7,3T  0 crypt 

when i run partprobe

partprobe
lsblk
sdb                                 8:16   0   3,7T  0 disk  
└─sdb1                              8:17   0   3,7T  0 part  
  └─md0                             9:0    0   7,3T  0 raid5 
    └─md0_crypt                   253:11   0   7,3T  0 crypt 
      └─md0_crypt1                253:12   0   7,3T  0 part  
sdc                                 8:32   0   3,7T  0 disk  
└─sdc1                              8:33   0   3,7T  0 part  
  └─md0                             9:0    0   7,3T  0 raid5 
    └─md0_crypt                   253:11   0   7,3T  0 crypt 
      └─md0_crypt1                253:12   0   7,3T  0 part  
sdd                                 8:48   0   3,7T  0 disk  
└─sdd1                              8:49   0   3,7T  0 part  
  └─md0                             9:0    0   7,3T  0 raid5 
    └─md0_crypt                   253:11   0   7,3T  0 crypt 
      └─md0_crypt1                253:12   0   7,3T  0 part

fdisk:

Disk /dev/mapper/md0_crypt: 7,3 TiB, 8001299677184 bytes, 15627538432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Disklabel type: gpt
Disk identifier: A599A15F-07DA-B340-ADDC-AA56AE2E9249

Device                      Start         End     Sectors  Size Type
/dev/mapper/md0_crypt-part1  2048 15627536383 15627534336  7,3T Linux

I want to mount the md0_crypt1 partition every time i boot. But without runing partprobe every time.

Did i miss something?

0

It's unusual to partition LUKS/LVM devices and as such, this is not covered by most standard tools. In fact, keeping partitions hidden on Device Mapper devices is a feature, as Virtual Machines using Logical Volumes as backing devices would usually partition those but NOT want their partitions to show up on the host.

I want to mount the md0_crypt1 partition every time i boot. But without runing partprobe every time.

You're pretty much stuck with it. And once you snuggle it into your init script somewhere, you won't even notice the difference... (in other words: automate it)


Make a backup before trying anything below this point.
Also do this from a LiveCD where nothing is mounted.

Option 1)

You could remove the superfluous partition table altogether (shift all data by 2048s, i.e. the offset of the first and only partition). Highly Dangerous dd command:

dd status=progress bs=1M if=/dev/mapper/md0_crypt1 of=/dev/mapper/md0_crypt

Note: dd'ing in place like this has to make sure not to overwrite data that has yet to be read, so this wouldn't work in the other direction.

Option 2)

Converting the partition table to LVM might also be doable (and not require relocating any data), however LVM prefers a larger metadata area these days and also likes to zero and wipe signatures. So you have to be careful to avoid those and make sure the 1st PE starts at 1M, not 2M, or other larger defaults.

[ replace /dev/loop0 with /dev/mapper/md0_crypt ]
# vgcreate --dataalignment 1M --metadatasize 128K vgname /dev/loop0
[ this step will wipe GPT signature ]
# pvs -o +pe_start /dev/loop0
  PV         VG     Fmt  Attr PSize    PFree 1st PE 
  /dev/loop0 foobar lvm2 a--  1020.00m    0    1.00m
                                             ^^^^^^^
[ 1st PE must be 1.00m (2048s) otherwise abort mission! ]
# lvcreate --wipesignatures n --zero n -l100%FREE -n lvname vgname
# file -sL /dev/vgname/lvname
/dev/vgname/lvname: Linux rev 1.0 ext4 filesystem data [...]
[ if there's no filesystem, something went wrong ]

It can be done but should not be attempted without a full backup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.