How to mount LUKS encrypted partitions manually

In the last days I played a bit with Slackware Linux on my netbook. But I play a bit too much and I had to recover some important files from my home folder but it is encrypted. The system wasn’t able to boot successfully. I had to boot from an usb-stick. But the problem was to decrypt the partition with my home folder.

H0nk3ym0nk3y wrote a post How to mount a LUKS encrypted partition on boot. But I had to do it manually and the solution is surprisingly easy:
The first step is to get the name of the encrypted partition, with the following command:

blkid | grep crypto

sample output:

/dev/sda2: UUID="VERY LONG NUMBER" TYPE="crypto_LUKS"

Now we know the name of the partition /dev/sda2. The next step is to open the partition and set up a mapping name:

cryptsetup luksOpen /dev/sda2/ crypthome

You have to enter the passphrase to decrypt the partition. Feel free to change the mapping name crypthome to whatever you want. The mapped partition is now available in /dev/mapper/crypthome but it isn’t mounted. The last step is create a mount point and to mount the mapped partition:

mkdir /mnt/crypthome && mount /dev/mapper/crypthome /mnt/crypthome

Now the partition is decrypted and mounted and you are able to access your files.

Last update: 14.06.2015

Posted on October 29, 2012, in Command-Line, Cryptography, Security, Troubleshooting and tagged , , , , , , , , , . Bookmark the permalink. 21 Comments.

  1. thanks, you saved may day!

  2. Hi I have a problem, I get this error message.

    When I type in: cryptsetup luksOpen /dev/sda6 crypthome
    it prompts me for my password and afterward I get this message:
    Cannot use device /dev/sda6 which is in use (already mapped or mounted).
    I would greatly appreciate some help. Thanks

    • Hi, sorry for the late answer. In my opinion the device is already mounted. Try to unmount the device with “umount”. If the device is busy and can not be unmounted, use “lsof” to find the process which blocks /dev/sda6. I hope this helps a bit. If you need more help, write a comment or an email.

  3. Hi,

    After using the command cryptsetup, I got an error ‘Device /dev/sdb1/ doesn’t exist or access denied’

    Please help. Thanks

    • If the device exists, it’ll be a permission problem (access denied). You need root permissions to create the mapping device. If you need more help, send a message and I try to figure out what’s the problem.

    • Chuck Nelson

      remove the trailing /
      line should be:
      cryptsetup luksOpen /dev/sda2 crypthome

      that resolved the same error here

  4. Thanks. Need your help with root permissions too . I’m not pro in this OS.

  5. Entire drive is password protected. Before initiating cryptsetup, I unlocked it using the password (Using Disks app), but still I get error ‘Device /dev/sdb1/ doesn’t exist or access denied’ when I initiate cryptsetup

  6. Your instructions are quite good and straightforward. They have helped me a lot. However I’ve got another problem: I installed an Arch distro (Antergos via Cnchi script) on top of Ubuntu. My /home partition was already encrypted, and I mistakenly opted during the install to mount this partition as encrypted with LUKS. Following your directions I succeeded in accessing the arch /home, but there is no trace of my original /home mounted under Ubuntu. I’m clueless.

    • I’m not the author of this post, but it sounds like you have overwritten your old /home partition. It’s hard to tell what happened, because the provided information is too vague.

      Open a terminal and list all available partitions with this command:

      lsblk

      If your old home partition still exists it should be listed there. Good luck!

  7. hi

    i did everything as you said and where do i find my hardrive when im done

  8. Awesome! I had to recover files from the USB dirve crypted by a QNAP NAS, and this procedure worked perfectly. Thanks!

  9. All I get when trying to mount is

    mount: unknown filesystem type ‘LVM2_member’

  10. why do you need this?

    Hi,
    O.k. I believe I overwrote my grub configuration files in sda1 wyhile trying to install an OS to an external hard drive. I have to mount my internal hard drive located at sda5, but it is encrypted.
    When I type cryptsetup luksOpen /dev/sda5/crypthome I get:
    “Command requires device and mapped name as arguments.”
    Do I just place them after the command with a space between?

    Thanks!

  11. just an FYI typing in your encryption into a terminal is a bad move long term.

  12. Your instructions were simple and the explanation was the easiest to understand compared to other sites.

Leave a comment