* [dm-crypt] how to determine the mapped device from the original device
@ 2009-12-10 0:37 Alvin Thompson
2009-12-10 1:20 ` Uwe Menges
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alvin Thompson @ 2009-12-10 0:37 UTC (permalink / raw)
To: dm-crypt
Hi,
I was wondering if it is possible to determine the mapped device from the original device. For example, if you used the command:
cryptsetup luksOpen /dev/sdd1 backup
Can you later determine the mapped device name ('backup' in this case) if all you know is the device (/dev/sdd1)?
Thanks,
Alvin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dm-crypt] how to determine the mapped device from the original device
2009-12-10 0:37 [dm-crypt] how to determine the mapped device from the original device Alvin Thompson
@ 2009-12-10 1:20 ` Uwe Menges
2009-12-10 7:35 ` Milan Broz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Uwe Menges @ 2009-12-10 1:20 UTC (permalink / raw)
To: dm-crypt
Alvin Thompson wrote:
> I was wondering if it is possible to determine the mapped device from the original device. For example, if you used the command:
>
> cryptsetup luksOpen /dev/sdd1 backup
>
> Can you later determine the mapped device name ('backup' in this case) if all you know is the device (/dev/sdd1)?
I don't know that, but I use entries in /etc/crypttab like:
backup01 /dev/disk/by-uuid/... /dev/shm/backupkey luks,noauto
and use
# cryptdisks_start backup01
which causes /dev/mapper/backup01 to appear.
Corresponding /etc/fstab entry is:
LABEL=backup01 /backup/disk1 auto noauto,noatime,nodiratime
Maybe this helps you with handling the devices.
Yours, Uwe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dm-crypt] how to determine the mapped device from the original device
2009-12-10 0:37 [dm-crypt] how to determine the mapped device from the original device Alvin Thompson
2009-12-10 1:20 ` Uwe Menges
@ 2009-12-10 7:35 ` Milan Broz
2009-12-11 4:17 ` Arno Wagner
2009-12-11 9:15 ` Mario 'BitKoenig' Holbe
3 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2009-12-10 7:35 UTC (permalink / raw)
To: Alvin Thompson; +Cc: dm-crypt
On 12/10/2009 01:37 AM, Alvin Thompson wrote:
> I was wondering if it is possible to determine the mapped device from the original device. For example, if you used the command:
>
> cryptsetup luksOpen /dev/sdd1 backup
>
> Can you later determine the mapped device name ('backup' in this case) if all you know is the device (/dev/sdd1)?
For really low-level, you can try dmsetup.
If you know the major:minor of that device (ls -l /dev/sdd1) check "dmsetup ls --tree" or similar.
The reverse is "cryptsetup status backup" and see device there.
All active encrypted devices you can see with "dmsetup status --target crypt" (or dmsetup table and check table directly).
Anyway, this seems like good idea to add some new command to cryptsetup, like "cryptsetup deps <dev>" to display
encrypted device mapped to underlying <dev>... add new issue to project page if you want this please.
Milan
--
mbroz@redhat.ocm
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dm-crypt] how to determine the mapped device from the original device
2009-12-10 0:37 [dm-crypt] how to determine the mapped device from the original device Alvin Thompson
2009-12-10 1:20 ` Uwe Menges
2009-12-10 7:35 ` Milan Broz
@ 2009-12-11 4:17 ` Arno Wagner
2009-12-11 9:15 ` Mario 'BitKoenig' Holbe
3 siblings, 0 replies; 5+ messages in thread
From: Arno Wagner @ 2009-12-11 4:17 UTC (permalink / raw)
To: dm-crypt
Here is a way (not pretty):
1. Get a list of all names in /dev/mapper via "dmsetup info"
2. Do a "cryptsetup status" for all of them
3. Search the device you want to know about in the output of 2.
Should be doable in Perl/Python in half an hour or so.
Arno
On Wed, Dec 09, 2009 at 07:37:26PM -0500, Alvin Thompson wrote:
> Hi,
>
> I was wondering if it is possible to determine the mapped device from the original device. For example, if you used the command:
>
> cryptsetup luksOpen /dev/sdd1 backup
>
> Can you later determine the mapped device name ('backup' in this case) if all you know is the device (/dev/sdd1)?
>
> Thanks,
> Alvin
>
> _______________________________________________
> dm-crypt mailing list
> dm-crypt@saout.de
> http://www.saout.de/mailman/listinfo/dm-crypt
>
--
Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: arno@wagner.name
GnuPG: ID: 1E25338F FP: 0C30 5782 9D93 F785 E79C 0296 797F 6B50 1E25 338F
----
Cuddly UI's are the manifestation of wishful thinking. -- Dylan Evans
If it's in the news, don't worry about it. The very definition of
"news" is "something that hardly ever happens." -- Bruce Schneier
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dm-crypt] how to determine the mapped device from the original device
2009-12-10 0:37 [dm-crypt] how to determine the mapped device from the original device Alvin Thompson
` (2 preceding siblings ...)
2009-12-11 4:17 ` Arno Wagner
@ 2009-12-11 9:15 ` Mario 'BitKoenig' Holbe
3 siblings, 0 replies; 5+ messages in thread
From: Mario 'BitKoenig' Holbe @ 2009-12-11 9:15 UTC (permalink / raw)
To: dm-crypt
Alvin Thompson <alvin@thompsonlogic.com> wrote:
> Can you later determine the mapped device name ('backup' in this case) if all you know is the device (/dev/sdd1)?
There is no way to do this offline, i.e. as long as the mapped device is
not created. LUKS does not store information about "preferred names" or
something like that.
If the device is online, you can try
ls -l /sys/block/dm-*/slaves/*
Just modify the pattern to your needs, like /sys/block/dm-*/slaves/sdd1
The mapping from dm-x to the symbolic name could be a bit harder, just
in case the dm-* names don't fit your needs.
I'd go for
ls -l /dev/mapper/* | grep " $(sed -e 's/:/, */' /sys/block/dm-x/dev) "
or something like that. Mind the surrounding spaces to get the pattern
safe or use grep -w.
regards
Mario
--
There are trivial truths and the great truths.
The opposite of a trivial truth is plainly false.
The opposite of a great truth is also true.
-- Niels Bohr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-11 9:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-10 0:37 [dm-crypt] how to determine the mapped device from the original device Alvin Thompson
2009-12-10 1:20 ` Uwe Menges
2009-12-10 7:35 ` Milan Broz
2009-12-11 4:17 ` Arno Wagner
2009-12-11 9:15 ` Mario 'BitKoenig' Holbe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.