[Closed] Mounting Encrypted SD card after kernel rollback

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
altoid_mint

[Closed] Mounting Encrypted SD card after kernel rollback

Post by altoid_mint »

I recently did an update to my laptop and had the SD card reader fail.

See post: viewtopic.php?f=49&t=257816&p=1391392#p1391392

Now that the reader is working, the procedure I had used to mount the encrypted partition on the SD card is failing.

Prior to the failure I would run the following script from the / directory using terminal:

Code: Select all

#!/bin/bash
# A simple shell to mount disk encryption based parition under Linux.
# Tested on Debian and Ubuntu base NAS servers.
# ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/>
# (c) 2008 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated: 05/Dec/2011
# ----------------------------------------------------------------------------
 
### commands ###
_crypt="/sbin/cryptsetup"
_vg="/sbin/vgscan"
_vgc="/sbin/vgchange"
_mnt="/bin/mount"
 
### SET ME FIRST ###
### Partition specific settings ###
### SET ME FIRST ###
_device="/dev/mmcblk3p1"
_name="Data"
_mnts="/dev/mapper/Data"
_mntd="/media/andrew/Data"

printf "Mounting Drive"

echo 
${_crypt} luksOpen ${_device} $_name
 
echo 
${_vg} --mknodes
${_vgc} -ay
 
echo 
${_mnt} ${_mnts} ${_mntd}
I would be prompted for both my root password and the encryption password, which I would then enter. The drive would mount and there would be much rejoicing.

Now however, when I insert the SD card the encrypted partition refuses to mount. Initially upon inserting the card I receive a prompt for a password. Naturally I enter the password for the encryption and I receive the following error:

Code: Select all

Error mounting /dev/dm-4 at /media/andrew/Data: Command-line `mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/dm-4" "/media/andrew/Data"' exited with non-zero exit status 32: mount: wrong fs type, bad option, bad superblock on /dev/mapper/luks-4a6b3368-e4fc-4063-886a-fda46e330224,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
Using disks I can see that the partition in question has been unlocked yet it refuses to mount.

The readout of lsblk is the following:

Code: Select all

NAME                               MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
mmcblk0rpmb                        179:24   0     4M  0 disk  
mmcblk3                            179:32   0 183.4G  0 disk  
├─mmcblk3p2                        179:34   0    90G  0 part  /media/andrew/Lore
└─mmcblk3p1                        179:33   0  93.4G  0 part  
  └─luks-4a6b3368-e4fc-4063-886a-fda46e330224
                                   253:4    0  93.4G  0 crypt 
mmcblk0boot0                       179:8    0     4M  1 disk  
mmcblk0boot1                       179:16   0     4M  1 disk  
mmcblk0                            179:0    0  28.5G  0 disk  
├─mmcblk0p2                        179:2    0   488M  0 part  /boot
├─mmcblk0p3                        179:3    0  27.5G  0 part  
│ └─mmcblk0p3_crypt                253:0    0  27.5G  0 crypt 
│   ├─mint--vg-root                253:1    0  25.6G  0 lvm   /
│   └─mint--vg-swap_1              253:2    0   1.9G  0 lvm   
│     └─cryptswap1                 253:3    0   1.9G  0 crypt [SWAP]
└─mmcblk0p1                        179:1    0   512M  0 part  /boot/efi
'Lore' is the unencrypted partition on the SD card. 'Data' (aka luks-4a6b3368-e4fc-4063-886a-fda46e330224) is the encrypted partition. (Hooray for Star Trek references in computers)

I'm not sure what to do next and I would greatly appreciate some direction. Thank you all.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
WharfRat

Re: Mounting Encrypted SD card after kernel rollback

Post by WharfRat »

It seems to be trying to mount /dev/mapper/luks-4a6b3368-e4fc-4063-886a-fda46e330224 :?

Can you paste back ls -lh /dev/mapper after opening the LUKS container.
altoid_mint

Re: Mounting Encrypted SD card after kernel rollback

Post by altoid_mint »

Code: Select all

total 0
crw------- 1 root root 10, 236 Nov 27 15:50 control
lrwxrwxrwx 1 root root       7 Nov 27 15:50 cryptswap1 -> ../dm-3
lrwxrwxrwx 1 root root       7 Nov 27 15:50 mint--vg-root -> ../dm-1
lrwxrwxrwx 1 root root       7 Nov 27 15:50 mint--vg-swap_1 -> ../dm-2
lrwxrwxrwx 1 root root       7 Nov 27 15:50 mmcblk0p3_crypt -> ../dm-0
One other thing, when I ran the mount.script I got kicked back:

Code: Select all

IO error while decrypting keyslot.
WharfRat

Re: Mounting Encrypted SD card after kernel rollback

Post by WharfRat »

Did you run mount /dev/mapper/mint--vg-root /mnt before listing /dev/mapper.

I don't see anything in there except your lvm mappings.
altoid_mint

Re: Mounting Encrypted SD card after kernel rollback

Post by altoid_mint »

I tried to mount the drive, but I think it has become corrupted. To check I swapped the SD card in my phone with the one from my laptop. The reader in the laptop read the card from the phone fine, however the phone read the card from the laptop as corrupted and asked to reformat. I think there is a good chance the card is just that, corrupted and that the data is irretrievable. I swapped the cards back and looked at the possibly corrupted card in the Disks utility. The contents are 'unavailable' and no longer shows the partitions. I am thinking that the card is irreparably screwed up and that I'll have to reformat.

Is there anything you could suggest prior to me reformatting it?
WharfRat

Re: Mounting Encrypted SD card after kernel rollback

Post by WharfRat »

The phone might report corrupted because it's LUKS encrypted.

I made a mistake in my previous post - it should have been did you run sudo /sbin/cryptsetup luksOpen /dev/mmcblk3p1 Data before listing /dev/mapper as your script does :?:
altoid_mint

Re: Mounting Encrypted SD card after kernel rollback

Post by altoid_mint »

I don't think it is the phone because I partitioned the card into an encrypted and non-encrypted partition, neither of which show up in Disks when it is inserted into the laptop. Prior to this whole debacle, the two partitions would show up in Disks with the encrypted partition being listed as locked. This however is not what is showing up now. Likewise lsblk only lists mmcblk3, with neither the encrypted or unencrypted partitions. The card now is just showing an unrecognizable the size of the whole card. I tried gparted to see if it could recognize and possibly recover the partition data, but it kept giving me an input/output error. When I tried that mount code you posted it kicked back /dev/mmcblk3pl doesn't exist or access denied. I think the card is just toast and reformatting is my only option. :\ I guess this is my first lesson in backing up data.
WharfRat

Re: Mounting Encrypted SD card after kernel rollback

Post by WharfRat »

Yea, then that does sound like it's toast now.

I didn't know that you had two partitions and it was previously readable on the phone.

It looks like format is the only remaining option at this point.
altoid_mint

Re: Mounting Encrypted SD card after kernel rollback

Post by altoid_mint »

Oh yeah, I think this card is toast. I can't even reformat it without getting errors kicked back. I don't know what the hell happened to it, but it looks like I'm doomed into purchasing another. :(
Locked

Return to “Storage”