# Encryption mapper for external USB HD

## larophel

Hi,

I am currently trying to encrypt my external USB HD using this tutorial: http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS

Everything works fine, until I unplug the HD and then plug it in again.

At that point, udev changes the name of the device (e.g. from /dev/sdb3 to /dev/sdc3).

This means, that my mapping in /dev/mapper is not valid anymore and I cannot mount my hard disk unless I remove the mapping and create a new one.

Of course, this is rather cumbersome. 

I tried to use a symbolic link during the "luksOpen" step, e.g.:

cryptsetup --key-file /root/canvio.key luksOpen /dev/disk/by-uuid/6d71b948-1230-4a68-a865-f57c5c85af37 canvio 

but the result was the same.

I also tried to create an udev rule to always name my hard disk the same:

BUS=="usb", SYSFS{serial}=="2010030517B8", KERNEL=="sd?3", NAME="sdb3"

but udev just ignores it:

Jan 10 00:09:58 [udevd-work] kernel-provided name 'sdc3' and NAME= 'sdb3' disagree, please use SYMLINK+= or change the kernel to provide the proper name_

I would appreciate any help in getting this solved.

Thanks,

----------

## Veldrin

before unplugging your hdd, do you close it properly (i.e luksClose)

if you want to symlink your device, you have to use a non-standard name, otherwise you will have some overlap, and that is why udev complains.

use something like NAME=usb or similar.

But this does not help, if the hdd get unmounted uncleanly, because then udev will create a new dev node, and you will run into the same issue as before.

V.

----------

## larophel

Actually, I was not using luksClose so this was part of the problem.

Unfortunately, you cannot use "NAME=xxx" because udev doesn't allow it.

However, I have now resorted to SYMLINK="sdb3"

It is not perfect because another removable device could take up that device name but it works for now.

Thanks for your input!

----------

## Veldrin

shoot - my mistake

you haveto use SYMLINK, and you may just give it a name. 

On an older installation, I used SYMLINK=usbhd to be able to use my fstab entries. simply put, replace your /dev/sdb3 with /dev/usbhd inside your fstab. recheck the naming convention - I am not quite up to speed with udev naming.

I strongly discourage the use of SYMLINK=sdb3, as it may already be taken.

cheers

V.

----------

## larophel

Ah, I understand what you mean now.

Now, I have a new problem: I added the following line to my fstab:

```

/dev/canvio     /mnt/canvio     crypt   noatime,user,noauto,keyfile=/home/larohel/.canvio.key,fsk_cipher=none            0 0

```

But when I execute "mount /mnt/canvio" as an user, I get this error: "crypt_init: Block device required".

If I execute this command as root, it works:

mount.crypt_LUKS -o keyfile=/home/manuel/.canvio.key -o fsk_cipher=none /dev/canvio /mnt/canvio

Any idea how this could be solved?

Thanks again,

----------

## robinmarlow

Hi,

Did you manage to figure out how to get this to work?

I'm having similar problems now.

Thanks,

Robin

----------

