Techie Notes‎ > ‎

Fedora 12 encrypting USB / Flash Drive

posted Mar 22, 2010 8:58 PM by Tedman Leung
Task Command
Partition your media fdisk /dev/sdb
Set the raw partition as encrypted
cryptsetup luksFormat /dev/sdb1
Create a temporary mapping so you can format partition for usage. I'm calling the temp mapping "temp".
cryptsetup luksOpen /dev/sdb1 temp
Format the encrypted partition
mkfs.ext3 /dev/mapper/temp
Set the label of the partition. I'm calling my partition backup.
e2label /dev/mapper/temp backup
un-map the temporary mapping
cryptsetup luksClose /dev/mapper/temp


At this point you will have an encrypted drive. If you unplug it and plug it back in it will automatically prompt you for the password and mount it. If you use the GUI to unmount the partition everything will work fine. If you accidentally umount it from the the command line or unplug the drive with out unmounting it, you will receive an error the next time you try to mount it. To fix that, you need to run the "cryptsetup luksClose" command on /dev/mapper/xxxxx where xxxxx is the mount point it complains about when it tries to mount it.