How to access and decrypt LUKS encrypted SSD that has been moved from internal drive to external USB drive
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
sudo vgscan
[sudo] password for USER:
Reading volume groups from cache.
WARNING: Device mismatch detected for mint-vg/root which is accessing /dev/mapper/luks-789f33eb-fd24-4251-b38b-0ed5d2609870 instead of /dev/mapper/sdc3_crypt.
WARNING: Device mismatch detected for mint-vg/swap_1 which is accessing /dev/mapper/luks-789f33eb-fd24-4251-b38b-0ed5d2609870 instead of /dev/mapper/sdc3_crypt.
Found volume group "mint-vg" using metadata type lvm2
Found volume group "kubuntu-vg" using metadata type lvm2
That all depends on how this disk was encrypted in Mint. Did you do this yourself, or use an automated utility? A lot of automated utilities LOVE to couple LUKS with LVM for some reason. In my view that only adds an unnecessary layer of complexity. Essentially you would then you would need to figure out how to set up the lvm layer on your Ubuntu setup. If you unlock this on the command line using 'cryptsetup' as sda3_crypt you would then need to run your lvm programs viz. /dev/mapper/sda3_crypt and not /dev/sda3, which is probably what your device notifiers are trying to do as they have no underlying reason to automatically assume that every encrypted partition is also LVM.
You may need to poke around in the /dev/mapper directory to find out exactly where the appropriate entry actually is. In my experience, different versions of udev handle this differently though you should be able to find it rather easily.
su
cryptsetup luksOpen /dev/sdc3 usbdisk
mkdir /mnt/usbdisk
mount /dev/mapper/usbdisk /mnt/usbdisk
chown -R username /mnt/usbdisk <-- could be necessary, could not
Not sure if you can do it with sudo, so I added SU infront instead. Perhaps do not do this in a terminal but TTY1 or TTY2 instead. Login as root. ctrl+alt+f1 for tty1 or ctl+alt+f2 for tty2.
or just run the same commands with sudo in front. In your case to continue from post 1:
Code:
sudo mkdir /mnt/disk
sudo mount /dev/mapper/sdc3_crypt /mnt/disk
sudo cd /mnt/disk
Pull the USB out, wait a few minutes then run "vgscan --cache".
Failing that you may have to temporarily disable lvmetad - the cache mentioned after the vgscan. Presuming systemd you should be able to stop it and the associated socket service, or update lvm.conf and reboot. Don't forget to reverse the change later.
Ooh man... Am I misunderstanding something here, or are you making things awfully complicated?
It's easy..
- "cryptsetup luksOpen" decrypts the device. Ok!
- the name you put AFTER that command ex. "usbdisk" creates a mapping device (unencrypted version of your disk)
- mapping device is placed in /dev/mapper (ex. "usbdisk")
- "mkdir /mnt/usbdisk" just makes a place to put your mapped device
- "mount /dev/mapper/usbdisk /mnt/usbdisk" mounts the mapped and unencrypted version of your disk to the specified location
doing these steps, your data will be available, decrypted in /mnt/usbdisk!!!!
Ok, so why did I add "chown -R username /mnt/usbdisk"? If you moved the disk from your computer to an external case, most likely the user you currently use CANNOT access the data with a different owner. With this command you change all folders and files owner to the desired owner (current logged in username/uid).
After doing that, you should be able to access all data, even if they have incorrect permissions as well.
Ooh man... Am I misunderstanding something here, or are you making things awfully complicated?
It's easy..
- "cryptsetup luksOpen" decrypts the device. Ok!
- the name you put AFTER that command ex. "usbdisk" creates a mapping device (unencrypted version of your disk)
- mapping device is placed in /dev/mapper (ex. "usbdisk")
- "mkdir /mnt/usbdisk" just makes a place to put your mapped device
- "mount /dev/mapper/usbdisk /mnt/usbdisk" mounts the mapped and unencrypted version of your disk to the specified location
doing these steps, your data will be available, decrypted in /mnt/usbdisk!!!!
Ok, so why did I add "chown -R username /mnt/usbdisk"? If you moved the disk from your computer to an external case, most likely the user you currently use CANNOT access the data with a different owner. With this command you change all folders and files owner to the desired owner (current logged in username/uid).
After doing that, you should be able to access all data, even if they have incorrect permissions as well.
When I mean decrypting, I just want to decrypt whole LVM partition so that I don't need to go through the mounting and unmounting (have to do that through terminal since Kubuntu 18.04 "device notifier" doesn't let me access it through it) every time I connect external USB storage.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.