Double layer of device mapper - customising dm-crypt

135 views Asked by At

Is it possible to create a device mapper over another device mapper?

I need to apply some checks in addition to encrypting the data on disk. So, I thought of creating a mapper (for additional checks) over the mapper created by dm-crypt and use new mapper's ioctl for applying those checks.

The dm-crypt created a mapper (say crypt_mapper) with starting sector and length as, say, 0 and 20000.

When I created a new mapper over this, the system crashes. There are no logs in dmesg.

echo 0 20000 access_target /dev/mapper/crypt_mapper 0 | dmsetup create access_mapper.
1

There are 1 answers

0
user2255299 On

The issue is resolved.

Didn't know that dm-crypt changes (reduces) the total size. It needs to store crypt headers.

# blockdev --getsize /dev/loop7
20000
# blockdev --getsize /dev/mapper/crypt_mapper
15904

I was creating the new mapper length over 20000 instead of 15904.