[dm-crypt] How to recognize a LUKS container

H McCurdy hmccurdy at yahoo.com
Wed Sep 23 04:29:55 CEST 2015


Thanks everyone.  Since the issue was Ubuntu installer software not figuring it out, I was wondering about a way to solve the problem so that a program could figure it out (without human help).
I might have figured it out but can't test my idea until tomorrow.  My thought is to try to access it as if it exists and if the function returns -1, then it's not a valid LUKS container.  Anyway, that's my idea.
I might need to examine errno to make sure the error isn't something like EPERM.


 


     On Tuesday, September 22, 2015 4:20 PM, Michael Kjörling <michael at kjorling.se> wrote:
   

 On 22 Sep 2015 22:03 +0200, from ralf+dm at ramses-pyramidenbau.de (Ralf Ramsauer):
> - If you have a dump, you can also use the 'file' command
> 
> Or the sophisticated one :-)
> - Look at the first few bytes of your partition/dump and check, if it
> contains the magic header "LUKS"

Or you can use 'file' directly, if you pass '-s' (--special-files) to it:

$ sudo file -s /dev/sdXY
/dev/sdXY: sticky LUKS encrypted file, ver 1 [aes, xts-plain64, sha512] UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
$ 

But I expect that 'cryptsetup isLuks' would be the best bet, as well
as lending itself better to automation (assuming of course that is the
end goal).

-- 
Michael Kjörling • https://michael.kjorling.semichael at kjorling.se
OpenPGP B501AC6429EF4514 https://michael.kjorling.se/public-keys/pgp
                “People who think they know everything really annoy
                those of us who know we don’t.” (Bjarne Stroustrup)
_______________________________________________
dm-crypt mailing list
dm-crypt at saout.de
http://www.saout.de/mailman/listinfo/dm-crypt


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.saout.de/pipermail/dm-crypt/attachments/20150923/951b22f5/attachment-0001.html>


More information about the dm-crypt mailing list