[SOLVED] Recovering dm-crypt LUKS partition; sector size issues

How to use TestDisk to recover lost partition
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Post Reply
Message
Author
garderobe
Posts: 4
Joined: 22 Feb 2018, 22:09

[SOLVED] Recovering dm-crypt LUKS partition; sector size issues

#1 Post by garderobe » 22 Feb 2018, 23:03

Hello,

I have a Seagate SSHD. After removing it from my Lenovo Z710 notebook and plugging it back in, the notebook stopped recognizing it as a boot device. I plugged it into another machine with this SATA to USB adapter, and GParted showed that the drive was unallocated. There should be three partitions on the drive; the only one I care about recovering is a large dm-crypt LUKS partition at the end of the drive.

I ran a TestDisk "Analyse" operation on the disk with the default options (including a default sector size of 4096), but it discovered an incorrect partition table. This is the testdisk.log; the disk in question is /dev/sdc.

Code: Select all

Thu Feb 22 13:15:00 2018
Command line: TestDisk

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 4.9.0-5-amd64 (#1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04)) x86_64
Compiler: GCC 6.2
ext2fs lib: 1.43.4, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.0
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size       1953525168 sectors
/dev/sda: user_max   1953525168 sectors
/dev/sda: native_max 1953525168 sectors
/dev/sda: dco        1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - ST1000LM048-2E7172, S/N:WDELC9CL, FW:SDM1
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63, sector size=4096 - ST1000LM 014-SSHD-8GB

Partition table type (auto): Intel
Disk /dev/sdc - 1000 GB / 931 GiB - ST1000LM 014-SSHD-8GB
Partition table type: Intel

Analyse Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63
Geometry from i386 MBR: head=173 sector=55


test_FAT()
 1 * FAT32                    0  32 33    62  53 55     997376
sector_size  0
cluster_size 0
reserved     47360
fats         0
dir_entries  0
sectors      47616
media        41
fat_length   0
secs_track   48640
heads        102
hidden       62849024
total_sect   3892314112
check_part_i386 failed for partition type 0B
check_part_i386 failed for partition type 83
check_part_i386 failed for partition type 83
Current partition structure:
Invalid FAT boot sector
 1 * FAT32                    0  32 33    62  53 55     997376
 1 * FAT32                    0  32 33    62  53 55     997376
No ext2, JFS, Reiser, cramfs or XFS marker
 2 P Linux                   62  53 56   124 107 47     999424
 2 P Linux                   62  53 56   124 107 47     999424
No ext2, JFS, Reiser, cramfs or XFS marker
 3 P Linux                  124 107 48   124 172 48       4096
 3 P Linux                  124 107 48   124 172 48       4096

search_part()
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63
check_FAT: number of bytes per sector mismatches 512 (FAT) != 4096 (HD)
Search for partition aborted

Results

interface_write()
 
No partition found or selected for recovery
simulate write!

write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition

TestDisk exited normally.
I quit TestDisk and ran it again. This time, I used the "Geometry" menu to change the Sector Size to 512. I ran a TestDisk "Analyse" operation on the disk, and this time it discovered a mostly correct partition table. Note in the following testdisk.log that I was able to use the "Advanced" menu's "Undelete"/"List" functionality to show the files in the first two partitions. The only thing that I recognize as incorrect is that partition 3, the LUKS partition, is much smaller than it should be. This is the testdisk.log; the disk in question is /dev/sdc.

Code: Select all

Thu Feb 22 13:43:05 2018
Command line: TestDisk

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 4.9.0-5-amd64 (#1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04)) x86_64
Compiler: GCC 6.2
ext2fs lib: 1.43.4, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.0
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size       1953525168 sectors
/dev/sda: user_max   1953525168 sectors
/dev/sda: native_max 1953525168 sectors
/dev/sda: dco        1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - ST1000LM048-2E7172, S/N:WDELC9CL, FW:SDM1
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63, sector size=4096 - ST1000LM 014-SSHD-8GB

Partition table type (auto): Intel
Disk /dev/sdc - 1000 GB / 931 GiB - ST1000LM 014-SSHD-8GB
Partition table type: Intel
New geometry
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63 sector_size=512

Analyse Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63
Geometry from i386 MBR: head=173 sector=55
FAT32 at 0/32/33
Info: size boot_sector 997376, partition 997376
FAT1 : 32-1004
FAT2 : 1005-1977
start_rootdir : 1978 root cluster : 2
Data : 1978-997369
sectors : 997376
cluster_size : 8
no_of_cluster : 124424 (2 - 124425)
fat_length 973 calculated 973
set_FAT_info: name from BS used
Current partition structure:
 1 * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
 2 P Linux                   62  53 56   124 107 47     999424
 3 P Linux                  124 107 48   124 172 48       4096

search_part()
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63
FAT32 at 0/32/33
FAT1 : 32-1004
FAT2 : 1005-1977
start_rootdir : 1978 root cluster : 2
Data : 1978-997369
sectors : 997376
cluster_size : 8
no_of_cluster : 124424 (2 - 124425)
fat_length 973 calculated 973
set_FAT_info: name from BS used

FAT32 at 0/32/33
     FAT32                    0  32 33    62  53 55     997376 [NO NAME]
     FAT32, blocksize=4096, 510 MB / 487 MiB

recover_EXT2: s_block_group_nr=0/61, s_mnt_count=2/4294967295, s_blocks_per_group=8192, s_inodes_per_group=2048
recover_EXT2: s_blocksize=1024
recover_EXT2: s_blocks_count 499712
recover_EXT2: part_size 999424
     Linux                   62  53 56   124 107 47     999424
     ext2 blocksize=1024 Sparse_SB, 511 MB / 488 MiB

     Linux                  124 107 48   124 172 48       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB
Search for partition aborted

Results
   * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
     FAT32, blocksize=4096, 510 MB / 487 MiB
   P Linux                   62  53 56   124 107 47     999424
     ext2 blocksize=1024 Sparse_SB, 511 MB / 488 MiB
   P Linux                  124 107 48   124 172 48       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Hint for advanced users. dmsetup may be used if you prefer to avoid to rewrite the partition table for the moment:
echo "0 997376 linear /dev/sdc 2048" | dmsetup create test0
echo "0 999424 linear /dev/sdc 999424" | dmsetup create test1
echo "0 4096 linear /dev/sdc 1998848" | dmsetup create test2

interface_write()
 1 * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
 2 P Linux                   62  53 56   124 107 47     999424
 3 P Linux                  124 107 48   124 172 48       4096
write!

write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
You will have to reboot for the change to take effect.

Interface Advanced
Geometry from i386 MBR: head=173 sector=55
FAT32 at 0/32/33
Info: size boot_sector 997376, partition 997376
FAT1 : 32-1004
FAT2 : 1005-1977
start_rootdir : 1978 root cluster : 2
Data : 1978-997369
sectors : 997376
cluster_size : 8
no_of_cluster : 124424 (2 - 124425)
fat_length 973 calculated 973
set_FAT_info: name from BS used
 1 * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
     FAT32, blocksize=4096, 510 MB / 487 MiB
 2 P Linux                   62  53 56   124 107 47     999424
     ext2 blocksize=1024 Sparse_SB, 511 MB / 488 MiB
 3 P Linux                  124 107 48   124 172 48       4096
     LUKS 1, 2097 KB / 2048 KiB

FAT: cluster=2(0x2), pos=4026
Directory /
       3 drwxr-xr-x     0      0         0 27-Jun-2015 18:16 EFI

Directory /
       2 drwxr-xr-x     0      0      1024 11-Jan-2018 14:04 .
       2 drwxr-xr-x     0      0      1024 11-Jan-2018 14:04 ..
      11 drwx------     0      0     12288 27-Jun-2015 02:45 lost+found
   30721 drwxr-xr-x     0      0      1024 27-Jun-2015 10:04 efi
      13 -rw-r--r--     0      0    157756 14-Dec-2017 13:27 config-3.16.0-4-amd64
      14 -rw-r--r--     0      0   3137712 14-Dec-2017 13:25 vmlinuz-3.16.0-4-amd64
   38913 drwxr-xr-x     0      0      1024 11-Jan-2018 14:04 grub
      16 -rw-r--r--     0      0    157786  9-Jan-2018 03:42 config-3.16.0-5-amd64
      12 -rw-r--r--     0      0   2684316 14-Dec-2017 13:27 System.map-3.16.0-4-amd64
      18 -rw-r--r--     0      0  17280594 11-Jan-2018 14:04 initrd.img-3.16.0-4-amd64
      17 -rw-r--r--     0      0   3139776  9-Jan-2018 03:40 vmlinuz-3.16.0-5-amd64
X     19 -rw-r--r--     0      0  17280295 11-Jan-2018 14:04 initrd.img-3.16.0-5-amd64.new
      15 -rw-r--r--     0      0   2683305  9-Jan-2018 03:42 System.map-3.16.0-5-amd64
      19 -rw-r--r--     0      0  17280295 11-Jan-2018 14:04 initrd.img-3.16.0-5-amd64
X     22 -rw-r--r--     0      0         0 11-Jan-2018 14:02 vmlinuz-3.16.0-4-amd64.dpkg-tmp
X     21 -rw-r--r--     0      0         0 11-Jan-2018 14:02 config-3.16.0-4-amd64.dpkg-new
X     14 -rw-r--r--     0      0   3137712 14-Dec-2017 13:25 config-3.16.0-4-amd64.dpkg-tmp
X     22 -rw-r--r--     0      0         0 11-Jan-2018 14:02 vmlinuz-3.16.0-4-amd64.dpkg-new
X     15 -rw-r--r--     0      0   2683305  9-Jan-2018 03:42 vmlinuz-3.16.0-4-amd64.dpkg-tmp

 3 P Linux                  124 107 48   124 172 48       4096
     LUKS 1, 2097 KB / 2048 KiB
Support for this filesystem hasn't been enable during compilation.

TestDisk exited normally.
After reading this post by cgrenier, I understand that TestDisk is only capable of detecting the beginning of a LUKS partition and that I need to manually set the end of the partition. I wrote the new partition table according to his instructions. This is the testdisk.log; the disk in question is /dev/sdc.

Code: Select all

Thu Feb 22 13:56:33 2018
Command line: TestDisk

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 4.9.0-5-amd64 (#1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04)) x86_64
Compiler: GCC 6.2
ext2fs lib: 1.43.4, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.0
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size       1953525168 sectors
/dev/sda: user_max   1953525168 sectors
/dev/sda: native_max 1953525168 sectors
/dev/sda: dco        1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - ST1000LM048-2E7172, S/N:WDELC9CL, FW:SDM1
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63, sector size=4096 - ST1000LM 014-SSHD-8GB

Partition table type (auto): Intel
Disk /dev/sdc - 1000 GB / 931 GiB - ST1000LM 014-SSHD-8GB
Partition table type: Intel
New geometry
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63 sector_size=512

Analyse Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63
Geometry from i386 MBR: head=173 sector=55
FAT32 at 0/32/33
Info: size boot_sector 997376, partition 997376
FAT1 : 32-1004
FAT2 : 1005-1977
start_rootdir : 1978 root cluster : 2
Data : 1978-997369
sectors : 997376
cluster_size : 8
no_of_cluster : 124424 (2 - 124425)
fat_length 973 calculated 973
set_FAT_info: name from BS used
Current partition structure:
 1 * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
 2 P Linux                   62  53 56   124 107 47     999424
 3 P Linux                  124 107 48   124 172 48       4096

search_part()
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 121602 255 63
FAT32 at 0/32/33
FAT1 : 32-1004
FAT2 : 1005-1977
start_rootdir : 1978 root cluster : 2
Data : 1978-997369
sectors : 997376
cluster_size : 8
no_of_cluster : 124424 (2 - 124425)
fat_length 973 calculated 973
set_FAT_info: name from BS used

FAT32 at 0/32/33
     FAT32                    0  32 33    62  53 55     997376 [NO NAME]
     FAT32, blocksize=4096, 510 MB / 487 MiB

recover_EXT2: s_block_group_nr=0/61, s_mnt_count=2/4294967295, s_blocks_per_group=8192, s_inodes_per_group=2048
recover_EXT2: s_blocksize=1024
recover_EXT2: s_blocks_count 499712
recover_EXT2: part_size 999424
     Linux                   62  53 56   124 107 47     999424
     ext2 blocksize=1024 Sparse_SB, 511 MB / 488 MiB

     Linux                  124 107 48   124 172 48       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB
Search for partition aborted

Results
   * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
     FAT32, blocksize=4096, 510 MB / 487 MiB
   P Linux                   62  53 56   124 107 47     999424
     ext2 blocksize=1024 Sparse_SB, 511 MB / 488 MiB
   P Linux                  124 107 48   124 172 48       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Hint for advanced users. dmsetup may be used if you prefer to avoid to rewrite the partition table for the moment:
echo "0 997376 linear /dev/sdc 2048" | dmsetup create test0
echo "0 999424 linear /dev/sdc 999424" | dmsetup create test1
echo "0 4096 linear /dev/sdc 1998848" | dmsetup create test2
Change partition type:
     Linux                  124 107 48 121601 254 63 1951537282

interface_write()
 1 * FAT32                    0  32 33    62  53 55     997376 [NO NAME]
 2 P Linux                   62  53 56   124 107 47     999424
 3 P Linux                  124 107 48 121601 254 63 1951537282
write!

write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
You will have to reboot for the change to take effect.

TestDisk exited normally.
After rebooting, this is the output I got from fdisk:

Code: Select all

# fdisk -l /dev/sdc
Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 244190646 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5c8295f6

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sdc1  *       2048     999423     997376  3.8G  b W95 FAT32
/dev/sdc2        999424    1998847     999424  3.8G 83 Linux
/dev/sdc3       1998848 1953536129 1951537282  7.3T 83 Linux
The sizes of the partitions are incorrect, about 8x the size they should be. (Note that 8x is equivalent to 4096 / 512). When I run fdisk with a sector size of 512, it lists partition sizes that appear more correct:

Code: Select all

# fdisk -b 512 -l /dev/sdc
Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5c8295f6

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sdc1  *       2048     999423     997376   487M  b W95 FAT32
/dev/sdc2        999424    1998847     999424   488M 83 Linux
/dev/sdc3       1998848 1953536129 1951537282 930.6G 83 Linux
Why is the new partition table showing incorrect partition sizes? What can I do to create a proper partition table?
Last edited by garderobe on 28 Feb 2018, 00:11, edited 1 time in total.

Sponsored links

User avatar
cgrenier
Site Admin
Posts: 4333
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: Recovering dm-crypt LUKS partition; sector size issues

#2 Post by cgrenier » 23 Feb 2018, 07:03

Can you run "testdisk -lu /dev/hdc" ?

garderobe
Posts: 4
Joined: 22 Feb 2018, 22:09

Re: Recovering dm-crypt LUKS partition; sector size issues

#3 Post by garderobe » 23 Feb 2018, 09:33

Hi cgrenier. Thanks for the prompt response.

Code: Select all

# testdisk -lu /dev/sdc
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Please wait...
Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63
Sector size:4096
Model: ST1000LM 014-SSHD-8GB

Disk /dev/sdc - 1000 GB / 931 GiB - CHS 15200 255 63
     Partition			Start        End    Size in sectors
 1 * FAT32                       2048     999423     997376
 2 P Linux                     999424    1998847     999424
 3 P Linux                    1998848 1953536129 1951537282

Code: Select all

# fdisk -lu /dev/sdc
Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 244190646 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5c8295f6

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sdc1  *       2048     999423     997376  3.8G  b W95 FAT32
/dev/sdc2        999424    1998847     999424  3.8G 83 Linux
/dev/sdc3       1998848 1953536129 1951537282  7.3T 83 Linux

Code: Select all

# fdisk -lb 512 /dev/sdc
Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5c8295f6

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sdc1  *       2048     999423     997376   487M  b W95 FAT32
/dev/sdc2        999424    1998847     999424   488M 83 Linux
/dev/sdc3       1998848 1953536129 1951537282 930.6G 83 Linux
Also, here is some SMART data from the drive.

Code: Select all

# smartctl --all /dev/sdc
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.9.0-5-amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Laptop SSHD
Device Model:     ST1000LM014-SSHD-8GB
Serial Number:    W3815KTB
LU WWN Device Id: 5 000c50 072b4435a
Firmware Version: LVD3
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2, ACS-3 T13/2161-D revision 3b
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is:    Thu Feb 22 14:05:52 2018 PST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00)	Offline data collection activity
					was never started.
					Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection: 		(  139) seconds.
Offline data collection
capabilities: 			 (0x73) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					No Offline surface scan supported.
					Self-test supported.
					Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:        (0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 ( 189) minutes.
Conveyance self-test routine
recommended polling time: 	 (   2) minutes.
SCT capabilities: 	       (0x1081)	SCT Status supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   090   080   006    Pre-fail  Always       -       212762070
  3 Spin_Up_Time            0x0003   097   097   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   098   098   020    Old_age   Always       -       2895
  5 Reallocated_Sector_Ct   0x0033   089   089   010    Pre-fail  Always       -       13032
  7 Seek_Error_Rate         0x000f   073   060   030    Pre-fail  Always       -       12959053312
  9 Power_On_Hours          0x0032   082   082   000    Old_age   Always       -       16382
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   099   099   020    Old_age   Always       -       1915
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       5523
188 Command_Timeout         0x0032   100   098   000    Old_age   Always       -       12885098514
189 High_Fly_Writes         0x003a   055   055   000    Old_age   Always       -       45
190 Airflow_Temperature_Cel 0x0022   072   047   045    Old_age   Always       -       28 (Min/Max 26/28)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       297
193 Load_Cycle_Count        0x0032   070   070   000    Old_age   Always       -       61885
194 Temperature_Celsius     0x0022   028   053   000    Old_age   Always       -       28 (0 9 0 0 0)
197 Current_Pending_Sector  0x0012   053   053   000    Old_age   Always       -       7760
198 Offline_Uncorrectable   0x0010   053   053   000    Old_age   Offline      -       7760
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
254 Free_Fall_Sensor        0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
ATA Error Count: 5529 (device log contains only the most recent five errors)
	CR = Command Register [HEX]
	FR = Features Register [HEX]
	SC = Sector Count Register [HEX]
	SN = Sector Number Register [HEX]
	CL = Cylinder Low Register [HEX]
	CH = Cylinder High Register [HEX]
	DH = Device/Head Register [HEX]
	DC = Device Command Register [HEX]
	ER = Error register [HEX]
	ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 5529 occurred at disk power-on lifetime: 16380 hours (682 days + 12 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 08 ff ff ff ef 00      00:07:40.594  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:40.591  SET FEATURES [Set transfer mode]
  00 00 00 00 00 00 00 04      00:07:40.406  NOP [Abort queued commands]
  25 00 08 ff ff ff ef 00      00:07:36.059  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:36.057  SET FEATURES [Set transfer mode]

Error 5528 occurred at disk power-on lifetime: 16380 hours (682 days + 12 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 08 ff ff ff ef 00      00:07:36.059  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:36.057  SET FEATURES [Set transfer mode]
  00 00 00 00 00 00 00 04      00:07:36.017  NOP [Abort queued commands]
  25 00 08 ff ff ff ef 00      00:07:31.322  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:30.955  READ DMA EXT

Error 5527 occurred at disk power-on lifetime: 16380 hours (682 days + 12 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 08 ff ff ff ef 00      00:07:31.322  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:30.955  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:30.917  SET FEATURES [Set transfer mode]
  00 00 00 00 00 00 00 04      00:07:30.757  NOP [Abort queued commands]
  25 00 08 ff ff ff ef 00      00:07:25.736  READ DMA EXT

Error 5526 occurred at disk power-on lifetime: 16380 hours (682 days + 12 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 08 ff ff ff ef 00      00:07:25.736  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:25.650  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:25.591  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:25.520  READ DMA EXT
  25 00 08 ff ff ff ef 00      00:07:23.878  READ DMA EXT

Error 5525 occurred at disk power-on lifetime: 16380 hours (682 days + 12 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 08 ff ff ff ef 00      00:07:17.886  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:17.884  SET FEATURES [Set transfer mode]
  00 00 00 00 00 00 00 04      00:07:17.853  NOP [Abort queued commands]
  25 00 08 ff ff ff ef 00      00:07:13.268  READ DMA EXT
  ef 03 46 00 00 00 a0 00      00:07:13.233  SET FEATURES [Set transfer mode]

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
Note that the SMART information shows sector sizes of 512 bytes logical, 4096 bytes physical, while Linux is treating sector sizes as 4096 across the board:

Code: Select all

# cat /sys/block/sdc/queue/logical_block_size 
4096
# cat /sys/block/sdc/queue/physical_block_size 
4096
# cat /sys/block/sdc/queue/hw_sector_size 
4096
# cat /sys/block/sdc/queue/minimum_io_size 
4096

garderobe
Posts: 4
Joined: 22 Feb 2018, 22:09

Re: Recovering dm-crypt LUKS partition; sector size issues

#4 Post by garderobe » 27 Feb 2018, 23:02

cgrenier, what did you hope to learn from the output of the command you suggested? Knowing your reasoning here might help me move forward in my own attempt to recover the partition.

garderobe
Posts: 4
Joined: 22 Feb 2018, 22:09

Re: Recovering dm-crypt LUKS partition; sector size issues

#5 Post by garderobe » 28 Feb 2018, 00:11

I was able to recover the data.

The source of the sector size problem was the SATA to USB adapter. Upon installing the drive into another machine with a free SATA port, the sector size was represented correctly, and I was able to decrypt and mount the partition.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest