How can I set a label on a dm-crypt+LUKS container?

for a permanent solution to change the label of the container, use:

sudo cryptsetup config /dev/sdb1 --label YOURLABEL

This method seems to have worked for me: http://www.cyberciti.biz/faq/linux-partition-howto-set-labels/

So, if you are using an EXT filesystem (I'm using ext4 here):

  1. Unlock the LUKS partition.
  2. Set the name of the unlocked filesystem (not LUKS partition).

    e2label <path> <name>
    

    The path generaly is /dev/mapper/<something> if using cryptsetup. But in my case, because I'm using udisks, it was /dev/dm-x, where x is a number.

I think this method stores the information on the removable media, as you wanted, but I still didn't test.


I think the solution is to write udev rules like this.

KERNEL=="sd*", ENV{ID_FS_UUID}=="your-sdb1-uuid", ENV{ID_FS_LABEL}="Partition_1", ENV{ID_FS_LABEL_ENC}="Partition_1"
KERNEL=="sd*", ENV{ID_FS_UUID}=="your-sdb2-uuid", ENV{ID_FS_LABEL}="Partition_2", ENV{ID_FS_LABEL_ENC}="Partition_2"