4

My laptop is unable to boot. So, I run Ubuntu 18.04 live from a bootable USB. It didn't automatically mount the 500 GB hard disk /dev/sda, which uses GPT.

lsblk shows only the disk, not the partitions; fdisk is instead able to show them.

gdisk shows the same error as in this page (Section "Semi-Automated Recovery"):

# gdisk /dev/sda
GPT fdisk (gdisk) version 0.7.2

Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Then, the linked page shows a list of options for the recovery/transformation command, in Section "Manual Recovery Procedures", specifying that:

You can experiment with all of the options just described (except for w); none of the data-recovery tools causes immediate writes to the disk.

I didn't understand how can one verify if these options will work or not, before making permanent modifications.

With gdisk, is it possible to temporarily use the backup partition table, so that Ubuntu can mount the /dev/sda disk partitions, and then leave the disk unchanged when Ubuntu is shut down?

1

You don't need your OS to recognize the partition. You can (try to) mount the entire device with proper offset. E.g. if you suspect (or if any tool tells you) the partition started at sector 2048 (quite a common value with 512-byte logical sectors), then try:

sudo mount -o ro,offset=$((2048*512)) /dev/sda /some/mountpoint

(ro just in case; without it it would be -o offset=$((2048*512))). If it mounts and the content looks sane, the starting sector is right.

It may be sector number 256 for 4096-byte logical sectors. Note $((256*4096)) and $((2048*512)) are the same number.

And if any tool tells you to start from sector 14649344, you use offset=$((14649344*512)) (assuming 512-byte sectors).

Microsoft used to like to start from 63 (because of the common value of 63 sectors per track in CHS, I guess), but this was before GPT. If you ever need to guess where any XP-era Windows C:\ starts, try offset=$((63*512)).


You said fdisk is able to show some sane partition structure. This should be your starting point.

If fdisk didn't help, testdisk would be the next tool to run. I believe it can search for lost partitions and display their starting sectors without altering the drive. This should give you offsets to try.

3
  • Thank you so much! Guessing the right partition start, this way a single (but whole) partition can be mounted. Also fdisk -l can determine the Logical sector size and also the beginning of the relevant partitions. Then, I multiplied the two values as suggested in your answer: it worked. – BowPark Jun 7 '19 at 11:14
  • @BowPark I admit I missed what you had mentioned about fdisk. I integrated your approach with my answer so the answer is more useful for future users. – Kamil Maciorowski Jun 7 '19 at 11:23
  • No problem. Yes, this way is even more coherent with the question. – BowPark Jun 7 '19 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.