How to fix corrupt primary GPT table?

Got problems with your B2 or B3? Share and get helped!
Post Reply
robinhat
Posts: 3
Joined: 21 Jun 2014, 15:56

How to fix corrupt primary GPT table?

Post by robinhat » 21 Jun 2014, 16:06

After experiencing a power outage today, my B3 won't boot anymore. I have managed to create a recovery USB stick, boot up the B3 with this stick (not reinstalling, just "rescue mode"), and SSH into the B3.

Running parted shows me something is wrong with the disk's partitioning. It tells me that the primary GPT table is corrupt. It also tells me that the backup seems fine, and if I choose ok to use the backup I can list the partitions on the disk (and everything seems correct).

How do I recover the corrupt primary GPT table? I have the impression that tools like gparted and gdisk may be able to do this, but I don't have access to these tools in the recovery stick's basic rescue mode. And I haven't found a way to use parted to fix the problem.

Do I really need to take out the disk of my B3 and put it in a system with more advanced disk/partitioning tools to address this issue?

I have pasted the output from parted below.


# parted /dev/sda
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
print
Error: Input/output error during read on /dev/sda
Retry/Ignore/Cancel? c
c
Error: The primary GPT table is corrupt, but the backup appears OK, so that will
be used.
OK/Cancel? o
o
Model: ATA WDC WD20EFRX-68A (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 17.4kB 10.7GB 10.7GB root
2 10.7GB 1999GB 1989GB home lvm
3 1999GB 2000GB 1074MB linux-swap(v1) swap

Ubi
Posts: 1547
Joined: 17 Jul 2007, 09:01

Re: How to fix corrupt primary GPT table?

Post by Ubi » 22 Jun 2014, 10:19

Wont entering 'save settings' just overwrite the prmary gpt from backup and you're done? Strange

robinhat
Posts: 3
Joined: 21 Jun 2014, 15:56

Re: How to fix corrupt primary GPT table?

Post by robinhat » 25 Jun 2014, 17:31

I am not able to find a "save settings" command in parted. Or a "write" command.

I have tried the "rescue" command in parted, but to no avail. I think "rescue" tries to search the disk for partitions but it doesn't seem to find any.

Cheeseboy
Posts: 789
Joined: 08 Apr 2007, 12:16

Re: How to fix corrupt primary GPT table?

Post by Cheeseboy » 28 Jun 2014, 13:14

Do I really need to take out the disk of my B3 and put it in a system with more advanced disk/partitioning tools to address this issue?
I'm afraid in my experience the answer is "yes"...

EDIT:
Minor spelling mistake.

Cheeseboy
Posts: 789
Joined: 08 Apr 2007, 12:16

Re: How to fix corrupt primary GPT table?

Post by Cheeseboy » 24 Jul 2014, 12:37

This started as an edit, but I made it a new reply instead, so you would get a notification:

What you can also do is boot with the rescue-stick, create a folder like /temphome, create symlinks from the (now empty) /home mount point that the /dev/mapper normally is mounted on.
Just make sure that your own user and admin has reasonably adequate fake home directories under this "temphome". Then modify /etc/fstab and comment out the line that normally mounts the LVM system on /home.
Now if you reboot, you will have access to all the tools you need, and /dev/mapper/bubba-storage will not be mounted. You might be able to save it that way, unless /dev/sda1 is also damaged.

robinhat
Posts: 3
Joined: 21 Jun 2014, 15:56

Re: How to fix corrupt primary GPT table?

Post by robinhat » 11 Aug 2014, 15:51

Thanks for the advice.

I managed to save my data from the disk. What I did was:

1. Take the disk out of the B3 and attach it externally to my laptop via a harddisk bay.
2. Boot my laptop in Ubuntu.
3. Use a recovery tool (testdisk, I believe) to make an image of the LVM partition with all the data on to another externally connected disk that I bought for the purpose.
4. Mount the LVM image and copy the data.

It could probably have been done more elegantly. I am just happy that I saved my data.

Post Reply