0

I'm trying to access an external SSD (USB 3.0). But Ubuntu is not able to mount it.

It shows on Nautilus, but when I click on it, I get the message "an operation is already pending".

enter image description here

enter image description here

When I do fdisk -l, it takes a lot, but eventually finds it:

The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Disk /dev/sdb: 238,49 GiB, 256060514304 bytes, 500118192 sectors
Disk model: RTL9210 NVME    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 16384 bytes
I/O size (minimum/optimal): 16384 bytes / 16384 bytes
Disklabel type: gpt
Disk identifier: #########

Device Start End Sectors Size Type /dev/sdb1 2048 1050623 1048576 512M EFI System /dev/sdb2 1050624 500117503 499066880 238G Linux filesystem

When I do sudo mount -t ext4 /dev/sdb2 /media/mydisk, it keeps hanging for a lot of time and finally gives the message can’t read superblock.

If I try parted, here's what happens:

$ sudo parted /dev/sdb
Warning: Error fsyncing/closing /dev/sdb1: Input/output error
Retry/Ignore? i                                                           
Warning: Error fsyncing/closing /dev/sdb2: Input/output error
Retry/Ignore? i                                                           
Error: Error initialising SCSI device /dev/sdb - No such device
Ignore/Cancel? i                                                          
Error: Could not stat device /dev/sdb - No such file or directory.
Retry/Cancel? c                                                           
Warning: Error fsyncing/closing /dev/sdb: Input/output error
Retry/Ignore? i 

and all the USB ports stop working.

Here's what happens when I try gdisk:

$ sudo gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.5

Warning! Read error 5; strange behavior now likely! Caution: invalid backup GPT header, but valid main header; regenerating backup header from main header.

Warning! Error 5 reading partition table for CRC check! Warning! One or more CRCs don't match. You should repair the disk! Main header: OK Backup header: ERROR Main partition table: OK Backup partition table: ERROR

Partition table scan: MBR: protective BSD: not present APM: not present GPT: damaged


Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk verification and recovery are STRONGLY recommended.


Command (? for help): p Disk /dev/sdc: 500118192 sectors, 238.5 GiB Model: RTL9210 NVME
Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): ######## Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 500118158 Partitions will be aligned on 2048-sector boundaries Total free space is 2669 sectors (1.3 MiB)

Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB EF00 EFI System Partition 2 1050624 500117503 238.0 GiB 8300

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sdc. Unable to save backup partition table! Perhaps the 'e' option on the experts' menu will resolve this problem. Warning! An error was reported when writing the partition table! This error MIGHT be harmless, or the disk might be damaged! Checking it is advisable.

Command (? for help):

and the disk still doesn't work.

When I try to clone the partition with dd, I get:

$ time sudo dd if=/dev/sdc1 of=/media/N/ssd.img
dd: error reading '/dev/sdc1': Input/output error
176680+0 records in
176680+0 records out
90460160 bytes (90 MB, 86 MiB) copied, 9,92451 s, 9,1 MB/s

real 0m12,017s user 0m0,237s sys 0m1,429s

and all of the USB ports stop working.

When trying to mount on Windows (with speciall tools for ext4), I was able to see my files, so I guess the hardware is okay.

Raphael
  • 169
  • 2
    "The backup GPT table is corrupt" You have to fix the gpt partition tables. https://askubuntu.com/questions/386752/fixing-corrupt-backup-gpt-table/386802#386802 Best not to use Windows to access ext4, that may be what is causing issue in first place. – oldfred Feb 17 '22 at 02:48

1 Answers1

0

I wasn't able to recover the hardware, but I was able to copy all the data. Here's what I did:

  1. On Windows, I installed a program called Linux Reader.
  2. I opened Linux Reader, located my partition and created an image of it in an external HD (right click on the partition to see this options).
  3. Back to Linux, I was able to recover the image with gdisk:

(Advice on steps 1 and 2: if you are able to make the image with dd on Linux, do that instead).

First, I tried to mount the image. Listing the partitions gave:

$ sudo sfdisk -d SSD.img
label: gpt
label-id: ####
device: SSD.img
unit: sectors
first-lba: 34
last-lba: 500118158

SSD.img : start= 2048, size= 1048576, (...) SSD.img : start= 1050624, size= 499066880, (...)

The partition I want to mount starts at 1050624, so I have to give an offset of 1050624*512=537919488:

$ sudo mount -o loop,offset=537919488 SSD.img /media/ssd
mount: /media/us: wrong fs type, bad option, bad superblock on /dev/loop19, missing codepage or helper program, or other error.

That didn't work, so I proceeded to try to recover the disk image.

I made a backup of the partition table (just in case):

$ sudo sfdisk -d SSD.img > pt.txt

Then, I ran gdisk and pressed p:

$ sudo gdisk SSD.img
GPT fdisk (gdisk) version 1.0.5

Partition table scan: MBR: protective BSD: not present APM: not present GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p Disk SSD.img: 500118192 sectors, 238.5 GiB Sector size (logical): 512 bytes Disk identifier (GUID): ########## Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 500118158 Partitions will be aligned on 2048-sector boundaries Total free space is 2669 sectors (1.3 MiB)

Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB EF00 EFI System Partition 2 1050624 500117503 238.0 GiB 8300

Since everything looked okay, I pressed w (please refer to gdisk manual to understand these options):

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to SSD.img. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully.

Then I was able to mount the image.

ADVICE: Don't do anything unless you know what you are doing. Take some time to study or call a professional. Always back up all your important data.

Raphael
  • 169