You are not logged in.

#1 2014-11-07 13:26:47

Lockheed
Member
Registered: 2010-03-16
Posts: 1,512

LUKS fails to open device properly

I have a working setup of LUKS > LVM > btrfs. No problems there.

I just got a new 2 TB disk and wanted to skip the LVM redundancy going LUKS > btrfs. I created the container, then I opened it with LUKS at /dev/mapper/2T, and created two partitions inside 2T device (tried both MBR and GPT). I got new devices under /dev/mapper/2T1 and .../2T2
Then I used mkfs to create btrfs systems on 2T1 and 2T2, mounted them and things worked fine...

That is, only until I unmounted the partition and closed LUKS.


When I try to open the container again, LUKS only creates /dev/mapper/2T (the block device) but not the partitions (2T1 and 2T2). If I run gparted on 2T, I can see the partition and can reformat them. If I do so, 2T1 and 2T2 appear again. But it is not a solution to have to format a partition before being able to mount it.

Here's some info

# cryptsetup luksDump /dev/sdb1
LUKS header information for /dev/sdb1

Version:       	1
Cipher name:   	serpent
Cipher mode:   	xts-plain64
Hash spec:     	sha1
Payload offset:	4096
MK bits:       	512
MK digest:     	af 1f 6e 7a f2 fd a4 ce e8 47 53 17 51 5e db 10 07 4f aa b0 
MK salt:       	b8 e8 03 a4 cd 99 e3 d8 66 e0 21 51 5f 1d 7c e8 
               	12 75 f5 01 4a c2 d3 38 cf 8f e1 0d 26 ab df d9 
MK iterations: 	426875
UUID:          	ab83b7a9-a9ea-4b5c-b3cd-21571f97fd2f

Key Slot 0: ENABLED
	Iterations:         	1693120
	Salt:               	03 08 88 f8 77 e2 03 d6 c6 10 b5 59 dc 46 74 ec 
	                      	2d 36 5e 35 83 b8 db 8e 7c 3d 1d 0b dc 25 bb 36 
	Key material offset:	8
	AF stripes:            	4000
Key Slot 1: ENABLED
	Iterations:         	332036
	Salt:               	bb 09 5a cc 05 ef 03 31 d7 4a 90 84 ce ac 8b e3 
	                      	c5 38 aa 95 3e a1 11 ea b8 b8 c8 aa a7 d4 fc df 
	Key material offset:	512
	AF stripes:            	4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED

and

$ echo $?
0

There is nothing in dmesg and the only thing that might be remotely related in the journal, is:

kernel doesn't support evdev-revocation

but I don't know if its appearance is a coincidence.

Offline

#2 2014-11-07 18:35:32

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: LUKS fails to open device properly

I'm not sure how you got those devices under /dev/mapper/2T to show up (as 2T{1,2}), nor how you could just luksClose your container without running into issues. (I mean if they showed up as /dev/mapper/2T1 they were devices (i.e. symlinks to ../dm-?) so surely they'd have to be released before you could close your LUKS container?)

Anyway, that's not usually how it's done. You would usually partition you disk as usual, so with 2 partitions - e.g. sdb1 & sdb2 - and then you'd create a LUKS container on each of them.

With what you're doing, writing a new partition table on /dev/mapper/2T (if I got it right), of course after opening the LUKS container it "doesn't work" : as far as the kernel goes/knows this is one device, where you need/want devices for each partition. You'd need to do something like `partprobe /dev/mapper/2T` which should "set up" those 2 devices and you should then be able to mount your filesystems normally, using /dev/mapper/2T{1,2}.
But then when you're done, after umounting them I think you'll need to use `dmsetup remove` on each one, before you can luksClose your container.

I'd say that if you want multiple partitions inside one LUKS container, using LVM is usually the way to do it. If you don't (wanna) use it, you should partition your disk and make a LUKS container on each partition (you can always use the same keyfile on both, or have the keyfile for the second one inside the first one, if you only want to have to enter one passphrase). I'm not sure doing it the way you're trying is common or has advantages, but I guess if you want to, with using partprobe/dmsetup as I described earlier it should work.

Offline

#3 2014-11-07 19:17:16

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: LUKS fails to open device properly

FWIW, I prefer kpartx to partprobe for enabling (and disabling) partitions on devices. But kpartx is part of multipath-tools which isn't in the repos.

Even in lieu of kpartx or partprobe you still shouldn't need to reformat. Just delete then re-create the partitions. They should be discovered just as when you first created them and the filesystems should be intact. That's no solution of course, just FYI.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2014-11-07 19:31:06

Lockheed
Member
Registered: 2010-03-16
Posts: 1,512

Re: LUKS fails to open device properly

partprobe works, indeed. But why don't the partitions show up automatically? If I do LVM in between LUKS and partitions, they do show up.

I want to use it for an internal drive that is being mounted at boot time so I am not sure partprobe is a usable solution here...

Offline

#5 2014-11-07 19:41:17

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: LUKS fails to open device properly

Lockheed wrote:

But why don't the partitions show up automatically?

Presumably because whatever is responsible for setting up partitions doesn't expect a LUKS device to be partitioned. The same is true for eg. partitioned LVM LVs.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#6 2014-11-07 19:51:05

Lockheed
Member
Registered: 2010-03-16
Posts: 1,512

Re: LUKS fails to open device properly

alphaniner wrote:
Lockheed wrote:

But why don't the partitions show up automatically?

Presumably because whatever is responsible for setting up partitions doesn't expect a LUKS device to be partitioned. The same is true for eg. partitioned LVM LVs.

On one hand you say nothing is expecting partitions inside LUKS, but on the other hand I have another disk with LUKS and LVM partitions in it, and they show up as soon as I open LUKS.

Offline

#7 2014-11-07 19:55:50

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: LUKS fails to open device properly

LVM LVs are not partitions.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB