Page 1 of 1

[Solved]GPT partition size issue

PostPosted: Nov 23rd, '14, 12:56
by xboxboy
Hi all.
A bit of an interesting one. I have an image for an ARM device that I've dd'ed to a usb flash drive. It boots, but gets stuck during boot with the following:

Code: Select all
GPT:Primary header thinks Alt. header is not at the end of the disk.
GPT:31116287 !=31266815
GPT:Alternate GPT header not at the end of the disk
GPT:31116287 !=31266815
GPT: Use GNU Parted to correct GPT errors.
 sda: sda6 sda7
sd 0:0:0:0: [sda] Attached SCSI removable disk


Now, I've tried to run GUI gparted, but it wont run properly: I have to shutdown, and on shutdown it flashes some partition error quickly.

Next I run:
Code: Select all
[root@localhost Downloads]# gdisk /dev/sdj
GPT fdisk (gdisk) version 0.8.8

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

Found valid GPT with protective MBR; using GPT.

Command (? for help): v

Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.

Identified 1 problems!



So, I believe this is just an issue from dd'ing an image on to a different size drive: I just need to correct the GPT and it wil be fine. I'm unsure what/where to go to from here.

Many thanks

Re: GPT partition size issue

PostPosted: Nov 24th, '14, 00:43
by jiml8
Look at the tool gdisk.

Re: GPT partition size issue

PostPosted: Nov 24th, '14, 01:05
by doktor5000
That's what he used to query the disk :) - maybe he should press ? ...

Re: GPT partition size issue

PostPosted: Nov 24th, '14, 02:08
by xboxboy
Thanks for looking at this guys. GPT is totally new to me, and TBH, I can't make sense of it. Diskdrak can see the partitions fine. There are three partitions on the usb.

I've looked at:
http://www.rodsbooks.com/gdisk/
http://manpages.ubuntu.com/manpages/lucid/man8/gdisk.8.html

And, yes, pressing entering ? does bring up the same options. I just find the manual pages and descriptions very broad. ie. I don't understand how my situation fits the options available, and what the process is for repairing this header issue.

Re: GPT partition size issue

PostPosted: Nov 24th, '14, 21:53
by martinw
I think gdisk is suggesting the right option to use, but the message is a bit misleading. What it refers to as the experts' menu is probably this option:
Code: Select all
r   recovery and transformation options (experts only)

The 'e' option inside this menu is described as
Code: Select all
e   load main partition table from disk (rebuilding backup)

Rebuilding backup sounds like what you need to do (backup = alternate = secondary - would be nice if they used the same word everywhere!)

Try it. The worst that can happen is that you'll have to copy the image onto your flash drive again.

Re: GPT partition size issue

PostPosted: Nov 24th, '14, 23:48
by xboxboy
@martinw

Thanks, I will try that: I have a fresh copy on the USB to try: I'll have a go when I get home.

Re: GPT partition size issue

PostPosted: Nov 25th, '14, 12:01
by xboxboy
@MartinW

That worked perfect!

Code: Select all
Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.

Identified 1 problems!

Command (? for help): r

Recovery/transformation command (? for help): e
Warning! This will probably do weird things if you've converted an MBR to
GPT form and haven't yet saved the GPT! Proceed? (Y/N): y

Recovery/transformation command (? for help): w
Warning! Secondary header is placed too early on the disk! Do you want to
correct this problem? (Y/N): y
Have moved second header and partition table to correct location.

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/sdj.
The operation has completed successfully.


It didn't boot completely: But I've got another problem: I think the image is for a SD card, but I've got it on usb, so once the usb drive mounts it crashes.