LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-13-2019, 05:57 PM   #1
Chripcikas
Member
 
Registered: Jun 2017
Distribution: Kubuntu 20.04
Posts: 88

Rep: Reputation: Disabled
Lightbulb How to access and decrypt LUKS encrypted SSD that has been moved from internal drive to external USB drive


Internal disk ran on mint kde 18.3, now trying to access and decrypt it on kubuntu 18.04 as usb drive.

"Device notifier" shows this message: "You are not authorized to mount this device"

"KDE partition manager" freezes up when trying to open it with usb drive inside.

Not sure how to proceed after
Code:
sudo cryptsetup luksOpen /dev/sdc3 sdc3_crypt
.

More info:

Code:
lsblk
NAME                     MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                      7:0    0   720K  1 loop  /snap/ufw/296
loop1                      7:1    0  91,1M  1 loop  /snap/core/6259
loop2                      7:2    0  89,5M  1 loop  /snap/core/6130
loop3                      7:3    0  50,7M  1 loop  /snap/p7zip-desktop/163
loop4                      7:4    0 174,3M  1 loop  /snap/inkscape/4693
loop5                      7:5    0    91M  1 loop  /snap/core/6350
sda                        8:0    0 238,5G  0 disk  
├─sda1                     8:1    0   512M  0 part  /boot/efi
├─sda2                     8:2    0   732M  0 part  /boot
└─sda3                     8:3    0 237,3G  0 part  
  └─sda3_crypt           253:0    0 237,3G  0 crypt 
    ├─kubuntu--vg-root   253:1    0 236,3G  0 lvm   /
    └─kubuntu--vg-swap_1 253:2    0   976M  0 lvm   [SWAP]
sdc                        8:32   0 238,5G  0 disk  
├─sdc1                     8:33   0   512M  0 part  
├─sdc2                     8:34   0   488M  0 part  /media/USER/80c7bce1-470c-4cf0-a0b9-0eaa9f6b5f1a
└─sdc3                     8:35   0 237,5G  0 part  
  └─sdc3_crypt           253:6    0 237,5G  0 crypt

Code:
 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
Code:
 df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                          3,9G     0  3,9G   0% /dev
tmpfs                         787M  1,5M  785M   1% /run
/dev/mapper/kubuntu--vg-root  232G   72G  149G  33% /
tmpfs                         3,9G   63M  3,8G   2% /dev/shm
tmpfs                         5,0M  4,0K  5,0M   1% /run/lock
tmpfs                         3,9G     0  3,9G   0% /sys/fs/cgroup
/dev/sda2                     705M  275M  380M  42% /boot
/dev/sda1                     511M  6,1M  505M   2% /boot/efi
/dev/loop0                    768K  768K     0 100% /snap/ufw/296
/dev/loop3                     51M   51M     0 100% /snap/p7zip-desktop/163
/dev/loop2                     90M   90M     0 100% /snap/core/6130
/dev/loop1                     92M   92M     0 100% /snap/core/6259
/dev/loop4                    175M  175M     0 100% /snap/inkscape/4693
/dev/loop5                     91M   91M     0 100% /snap/core/6350
tmpfs                         787M   60K  787M   1% /run/user/1000
/dev/mapper/mint--vg-root     226G  164G   51G  77% /media/USER/061eaa3b-c178-440d-a605-3f9104a243e7
/dev/sdc2                     473M  221M  228M  50% /media/USER/80c7bce1-470c-4cf0-a0b9-0eaa9f6b5f1a
 
Old 02-13-2019, 09:26 PM   #2
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 302

Rep: Reputation: 89
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.
 
Old 02-14-2019, 03:27 PM   #3
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Code:
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

Last edited by zeebra; 02-14-2019 at 03:31 PM.
 
Old 02-14-2019, 04:39 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 02-16-2019, 06:44 PM   #5
Chripcikas
Member
 
Registered: Jun 2017
Distribution: Kubuntu 20.04
Posts: 88

Original Poster
Rep: Reputation: Disabled
So I managed to access the disk after reconnecting usb drive. Checked
Code:
lsblk
, now sdc3 has become sdb3.

Then:
Code:
sudo cryptsetup luksOpen /dev/sdb3 sdb3
Code:
sudo mkdir /home/USER/encrypted
Code:
sudo mount /dev/mapper/mint--vg-root  /home/USER/encrypted
.

Now it's time for decrypting. I'm not sure that
Code:
chown -R username /mnt/usbdisk
suggestion is such a good idea, how will removing ownership of the mounted lvm partition help me in any way to decrypt it?

Last edited by Chripcikas; 02-16-2019 at 07:08 PM. Reason: correction
 
Old 02-16-2019, 07:46 PM   #6
Chripcikas
Member
 
Registered: Jun 2017
Distribution: Kubuntu 20.04
Posts: 88

Original Poster
Rep: Reputation: Disabled
Is there a way to safely decrypt LUKS LVM partition without losing files? Or is it better to just mount, move files and format usb drive?
 
Old 02-19-2019, 04:26 AM   #7
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
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.
 
Old 02-19-2019, 04:26 AM   #8
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
If you have additional encryption, you need to handle that AFTER those steps.
 
Old 02-21-2019, 07:52 AM   #9
Chripcikas
Member
 
Registered: Jun 2017
Distribution: Kubuntu 20.04
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zeebra View Post
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.
 
  


Reply

Tags
decrypt, encrypted, external, kubuntu, luks



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] What commands/scripts does Slackware use to decrypt and mount a luks device? laxware Slackware 3 06-22-2018 02:27 PM
[SOLVED] Slackware boots and prompts for password to decrypt LUKS but can't enter laxware Slackware 3 06-17-2018 06:53 PM
Access To Encrypted SSD Partition With Native Password in SSD>SATA Enclosure skidvicious Linux - Hardware 5 12-03-2015 04:40 PM
Ubuntu 12.04 hard drive encrypted and the existing password cannot decrypt it... andrew262 Ubuntu 2 05-22-2014 07:24 AM
[SOLVED] Moved offices. External websites/internal ssh both work, but internal http doesn't. jasonws Linux - Networking 3 08-04-2011 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration