I accidentally messed up my luks partition with Testdisk

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
Locked
Message
Author
beardstack
Posts: 2
Joined: 03 Nov 2020, 16:23

I accidentally messed up my luks partition with Testdisk

#1 Post by beardstack »

So I had a script that caused an issue with my partitions mounting at boot, however I wrongly assumed a problem with the disks. I have a 1TB drive which was encrypted using luks and after running Testdisk I may have wrecked the partition. Can you assist? Here is my log

Added by recuperation from your second double posting:
Please delete if duplicate, I tried posting earlier but the post somehow vanished and is not visible in my posts. I had a whole disk encrypted using luks, a script caused the drives not to show but I erroneously thought that there was a problem with the disk. I tried using testdisk but now the partition is detected as 2.2 MB and I cannot access my partition anymore. I have attached the log below.

Code: Select all

Sun Nov  1 13:20:04 2020
Command line: TestDisk

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
OS: Linux, kernel 5.7.19-2-MANJARO (#1 SMP PREEMPT Fri Aug 28 20:22:12 UTC 2020) x86_64
Compiler: GCC 10.1
ext2fs lib: 1.45.6, ntfs lib: libntfs-3g, reiserfs lib: 0.3.0.5, ewf lib: none, curses lib: ncurses 6.2
User is not root!
Hard disk list
Disk /dev/sr0 - 1493 MB / 1424 MiB - 729392 sectors (RO), sector size=2048 - PLDS DVD-RW DH16ACSH, S/N:S0A68694ZVJ6YD01FZ4D, FW:JL3B


TestDisk exited normally.
Using locale 'LC_CTYPE=en_CA.utf8;LC_NUMERIC=en_CA.UTF-8;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.utf8;LC_MONETARY=en_CA.UTF-8;LC_MESSAGES=en_CA.utf8;LC_PAPER=en_CA.UTF-8;LC_NAME=en_CA.UTF-8;LC_ADDRESS=en_CA.UTF-8;LC_TELEPHONE=en_CA.UTF-8;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=en_CA.UTF-8'.


Sun Nov  1 13:20:15 2020
Command line: TestDisk /debug

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
OS: Linux, kernel 5.7.19-2-MANJARO (#1 SMP PREEMPT Fri Aug 28 20:22:12 UTC 2020) x86_64
Compiler: GCC 10.1
ext2fs lib: 1.45.6, ntfs lib: libntfs-3g, reiserfs lib: 0.3.0.5, ewf lib: none, curses lib: ncurses 6.2
/dev/sda: LBA, HPA, LBA48 support
/dev/sda: size       234441648 sectors
/dev/sda: user_max   234441648 sectors
/dev/sda: native_max 234441648 sectors
/dev/sdb: LBA, HPA, LBA48 support
/dev/sdb: size       468862128 sectors
/dev/sdb: user_max   468862128 sectors
/dev/sdb: native_max 468862128 sectors
/dev/sdc: LBA, HPA, LBA48 support
/dev/sdc: size       468862128 sectors
/dev/sdc: user_max   468862128 sectors
/dev/sdc: native_max 468862128 sectors
/dev/sdd: LBA, HPA, LBA48, DCO support
/dev/sdd: size       1953525168 sectors
/dev/sdd: user_max   1953525168 sectors
/dev/sdd: native_max 1953525168 sectors
/dev/sdd: dco        1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
/dev/sr0 is not an ATA disk
Warning: can't get size for Disk /dev/loop13 - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63, sector size=512 - FM-25S2S-120GBP1, S/N:GS08104511080004, FW:3.1
Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63, sector size=512 - INTEL SSDSC2BW240H6, S/N:CVTR610507E1240CGN, FW:RG21
Disk /dev/sdc - 240 GB / 223 GiB - CHS 29185 255 63, sector size=512 - INTEL SSDSC2BW240H6, S/N:CVTR610602YM240CGN, FW:RG21
Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - ST1000NM0011, S/N:Z1N0FSCT, FW:PA03
Disk /dev/sdg - 128 GB / 119 GiB - CHS 15583 255 63, sector size=512 - Generic- SD/MMC, FW:1.00
Disk /dev/sr0 - 1493 MB / 1424 MiB - 729392 sectors (RO), sector size=2048 - PLDS DVD-RW DH16ACSH, S/N:S0A68694ZVJ6YD01FZ4D, FW:JL3B
Disk /dev/loop0 - 58 MB / 55 MiB - 113296 sectors (RO), sector size=512
Disk /dev/loop1 - 58 MB / 55 MiB - 113384 sectors (RO), sector size=512
Disk /dev/loop10 - 237 MB / 226 MiB - 464216 sectors (RO), sector size=512
Disk /dev/loop11 - 32 MB / 30 MiB - 63344 sectors (RO), sector size=512
Disk /dev/loop12 - 215 MB / 205 MiB - 421576 sectors (RO), sector size=512
Disk /dev/loop2 - 169 MB / 161 MiB - 330576 sectors (RO), sector size=512
Disk /dev/loop3 - 170 MB / 162 MiB - 333552 sectors (RO), sector size=512
Disk /dev/loop4 - 57 MB / 54 MiB - 112264 sectors (RO), sector size=512
Disk /dev/loop5 - 215 MB / 205 MiB - 421584 sectors (RO), sector size=512
Disk /dev/loop6 - 77 MB / 73 MiB - 151496 sectors (RO), sector size=512
Disk /dev/loop7 - 65 MB / 62 MiB - 127160 sectors (RO), sector size=512
Disk /dev/loop8 - 32 MB / 30 MiB - 63360 sectors (RO), sector size=512
Disk /dev/loop9 - 242 MB / 231 MiB - 473880 sectors (RO), sector size=512

Partition table type (auto): Intel
Disk /dev/sdb - 240 GB / 223 GiB - INTEL SSDSC2BW240H6
Partition table type: Intel

Analyse Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63
Geometry from i386 MBR: head=255 sector=2
BAD_RS LBA=2048 64512
Current partition structure:
 1 P Linux                    0  32 33 29185  61 60  468858880

Bad relative sector.
No partition is bootable

search_part()
Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63

recover_btrfs: part_size 468858880
     Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Results
   * Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 468858880 linear /dev/sdb 2048" | dmsetup create test0

interface_write()
 1 * Linux                    0  32 33 29185  61 60  468858880

search_part()
Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63

recover_btrfs: part_size 468858880
     Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Results
   * Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 468858880 linear /dev/sdb 2048" | dmsetup create test0

interface_write()
 1 * Linux                    0  32 33 29185  61 60  468858880

interface_write()
 1 * Linux                    0  32 33 29185  61 60  468858880
write!

write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
You will have to reboot for the change to take effect.
Partition table type (auto): Intel
Disk /dev/sdd - 1000 GB / 931 GiB - ST1000NM0011
Partition table type: Intel

Interface Advanced
Geometry from i386 MBR: head=255 sector=63
check_part_i386 1 type E8: no test
 1 P Sys=E8                   0  32 33 121601  57 56 1953521664

Analyse Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63
Geometry from i386 MBR: head=255 sector=63
check_part_i386 1 type E8: no test
Current partition structure:
 1 P Sys=E8                   0  32 33 121601  57 56 1953521664
No partition is bootable

search_part()
Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63

     Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Results
   * Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 4096 linear /dev/sdd 2048" | dmsetup create test0

interface_write()
 1 * Linux                    0  32 33     0  97 33       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.
Partition table type (auto): Intel
Disk /dev/sdb - 240 GB / 223 GiB - INTEL SSDSC2BW240H6
Partition table type: Intel

Analyse Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63
Geometry from i386 MBR: head=255 sector=63
Current partition structure:
 1 * Linux                    0  32 33 29185  61 60  468858880

search_part()
Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63

recover_btrfs: part_size 468858880
     Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Results
   * Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 468858880 linear /dev/sdb 2048" | dmsetup create test0

interface_write()
 1 * Linux                    0  32 33 29185  61 60  468858880
Couldn't open reiser filesystem

   * Linux                    0  32 33 29185  61 60  468858880
     btrfs blocksize=4096 Backup superblock, 240 GB / 223 GiB
Can't open filesystem. Filesystem seems damaged.

interface_write()
 1 * Linux                    0  32 33 29185  61 60  468858880
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.


Sun Nov  1 17:55:20 2020
Command line: TestDisk

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
OS: Linux, kernel 5.7.19-2-MANJARO (#1 SMP PREEMPT Fri Aug 28 20:22:12 UTC 2020) x86_64
Compiler: GCC 10.1
ext2fs lib: 1.45.6, ntfs lib: libntfs-3g, reiserfs lib: 0.3.0.5, ewf lib: none, curses lib: ncurses 6.2
User is not root!
Hard disk list
Disk /dev/sr0 - 1493 MB / 1424 MiB - 729392 sectors (RO), sector size=2048 - PLDS DVD-RW DH16ACSH, S/N:S0A68694ZVJ6YD01FZ4D, FW:JL3B


TestDisk exited normally.
Using locale 'LC_CTYPE=en_CA.utf8;LC_NUMERIC=en_CA.UTF-8;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.utf8;LC_MONETARY=en_CA.UTF-8;LC_MESSAGES=en_CA.utf8;LC_PAPER=en_CA.UTF-8;LC_NAME=en_CA.UTF-8;LC_ADDRESS=en_CA.UTF-8;LC_TELEPHONE=en_CA.UTF-8;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=en_CA.UTF-8'.


Sun Nov  1 17:55:35 2020
Command line: TestDisk /debug

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
OS: Linux, kernel 5.7.19-2-MANJARO (#1 SMP PREEMPT Fri Aug 28 20:22:12 UTC 2020) x86_64
Compiler: GCC 10.1
ext2fs lib: 1.45.6, ntfs lib: libntfs-3g, reiserfs lib: 0.3.0.5, ewf lib: none, curses lib: ncurses 6.2
/dev/sda: LBA, HPA, LBA48 support
/dev/sda: size       234441648 sectors
/dev/sda: user_max   234441648 sectors
/dev/sda: native_max 234441648 sectors
/dev/sdb: LBA, HPA, LBA48 support
/dev/sdb: size       468862128 sectors
/dev/sdb: user_max   468862128 sectors
/dev/sdb: native_max 468862128 sectors
/dev/sdc: LBA, HPA, LBA48 support
/dev/sdc: size       468862128 sectors
/dev/sdc: user_max   468862128 sectors
/dev/sdc: native_max 468862128 sectors
/dev/sdd: LBA, HPA, LBA48, DCO support
/dev/sdd: size       1953525168 sectors
/dev/sdd: user_max   1953525168 sectors
/dev/sdd: native_max 1953525168 sectors
/dev/sdd: dco        1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
/dev/sr0 is not an ATA disk
Warning: can't get size for Disk /dev/loop13 - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63, sector size=512 - FM-25S2S-120GBP1, S/N:GS08104511080004, FW:3.1
Disk /dev/sdb - 240 GB / 223 GiB - CHS 29185 255 63, sector size=512 - INTEL SSDSC2BW240H6, S/N:CVTR610507E1240CGN, FW:RG21
Disk /dev/sdc - 240 GB / 223 GiB - CHS 29185 255 63, sector size=512 - INTEL SSDSC2BW240H6, S/N:CVTR610602YM240CGN, FW:RG21
Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - ST1000NM0011, S/N:Z1N0FSCT, FW:PA03
Disk /dev/sdg - 128 GB / 119 GiB - CHS 15583 255 63, sector size=512 - Generic- SD/MMC, FW:1.00
Disk /dev/sr0 - 1493 MB / 1424 MiB - 729392 sectors (RO), sector size=2048 - PLDS DVD-RW DH16ACSH, S/N:S0A68694ZVJ6YD01FZ4D, FW:JL3B
Disk /dev/loop0 - 58 MB / 55 MiB - 113296 sectors (RO), sector size=512
Disk /dev/loop1 - 58 MB / 55 MiB - 113384 sectors (RO), sector size=512
Disk /dev/loop10 - 77 MB / 73 MiB - 151496 sectors (RO), sector size=512
Disk /dev/loop11 - 237 MB / 226 MiB - 464216 sectors (RO), sector size=512
Disk /dev/loop12 - 242 MB / 231 MiB - 473880 sectors (RO), sector size=512
Disk /dev/loop2 - 169 MB / 161 MiB - 330576 sectors (RO), sector size=512
Disk /dev/loop3 - 57 MB / 54 MiB - 112264 sectors (RO), sector size=512
Disk /dev/loop4 - 170 MB / 162 MiB - 333552 sectors (RO), sector size=512
Disk /dev/loop5 - 215 MB / 205 MiB - 421584 sectors (RO), sector size=512
Disk /dev/loop6 - 65 MB / 62 MiB - 127160 sectors (RO), sector size=512
Disk /dev/loop7 - 215 MB / 205 MiB - 421576 sectors (RO), sector size=512
Disk /dev/loop8 - 32 MB / 30 MiB - 63360 sectors (RO), sector size=512
Disk /dev/loop9 - 32 MB / 30 MiB - 63344 sectors (RO), sector size=512

Partition table type (auto): Intel
Disk /dev/sdd - 1000 GB / 931 GiB - ST1000NM0011
Partition table type: Intel

Interface Advanced
Geometry from i386 MBR: head=98 sector=33
 1 * Linux                    0  32 33     0  97 33       4096
     LUKS 1, 2097 KB / 2048 KiB
search_superblock
Couldn't open reiser filesystem

 1 * Linux                    0  32 33     0  97 33       4096
     LUKS 1, 2097 KB / 2048 KiB
Can't open filesystem. Filesystem seems damaged.
Change partition type:
 1 * Linux                    0  32 33     0  97 33       4096
     LUKS 1, 2097 KB / 2048 KiB

Analyse Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63
Geometry from i386 MBR: head=98 sector=33
Current partition structure:
 1 * Linux                    0  32 33     0  97 33       4096

search_part()
Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63

     Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Results
   * Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 4096 linear /dev/sdd 2048" | dmsetup create test0
Couldn't open reiser filesystem

   * Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB
Can't open filesystem. Filesystem seems damaged.
Can't open backup.log file: No such file or directory
interface_load

interface_write()
 1 * Linux                    0  32 33     0  97 33       4096

search_part()
Disk /dev/sdd - 1000 GB / 931 GiB - CHS 121601 255 63

     Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Results
   * Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 4096 linear /dev/sdd 2048" | dmsetup create test0
Couldn't open reiser filesystem

   * Linux                    0  32 33     0  97 33       4096
     LUKS 1 (Data size unknown), 2097 KB / 2048 KiB
Can't open filesystem. Filesystem seems damaged.

interface_write()
 1 * Linux                    0  32 33     0  97 33       4096
simulate write!

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

Interface Advanced
Geometry from i386 MBR: head=98 sector=33
 1 * Linux                    0  32 33     0  97 33       4096
     LUKS 1, 2097 KB / 2048 KiB
Couldn't open reiser filesystem

 1 * Linux                    0  32 33     0  97 33       4096
     LUKS 1, 2097 KB / 2048 KiB
Can't open filesystem. Filesystem seems damaged.

TestDisk exited normally.

Locked