Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On this page are there examples of LUKS encryptions. Example below.

Why are the dmsetup commands there?

What do they do?

dd if=/dev/zero of=./volumes/vol_default.vol bs=1M count=1
losetup /dev/loop0 ./volumes/vol_default.vol
echo password1234567890ABC | cryptsetup-luks luksFormat /dev/loop0
cryptsetup-luks luksDump /dev/loop0 
echo password1234567890ABC | cryptsetup-luks luksOpen /dev/loop0 myMapper
dmsetup ls
dmsetup table
dmsetup status
cryptsetup-luks status myMapper
losetup /dev/loop1 /dev/mapper/myMapper
mkdosfs /dev/loop1
mkdir ./test_mountpoint
mount /dev/loop1 ./test_mountpoint
cp ./test_files/SHORT_TEXT.txt        ./test_mountpoint
cp ./test_files/BINARY_ZEROS.dat      ./test_mountpoint
cp ./test_files/BINARY_ABC_RPTD.dat   ./test_mountpoint
cp ./test_files/BINARY_00_FF_RPTD.dat ./test_mountpoint
umount ./test_mountpoint
losetup -d /dev/loop1
cryptsetup-luks luksClose myMapper
losetup -d /dev/loop0
rm -rf ./test_mountpoint
share|improve this question
up vote 3 down vote accepted

My guess is they want you to look at the active device mapper devices before you run the losetup commands or anything else. Perhaps /dev/loop1 is already in use. They don't want you to trash something accidentally if you already happen to be using that on your system.

A quick look at the dmsetup man page quickly reveals that ls, status, and table are all intended for you to look at the various aspects of the current state of the device mapper. It is always a good idea to look at the current state of your system before running commands that are potentially destructive.

share|improve this answer
I see. You mentioned the /dev/loop1. Why is losetup /dev/loop1 /dev/mapper/myMapper actually needed? Isn't /dev/mapper/myMapper created in the previous step? – Sandra Nov 29 '12 at 21:53
I am not sure why they are doing all that. IMO, they have made something more complicated then it needs to be for some odd reason. – Zoredache Nov 29 '12 at 21:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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