Welcome! Log In Create A New Profile

Advanced

Schizophrenic GPT implementation in first generation Armada 370 u-boot

Posted by Mijzelf 
Schizophrenic GPT implementation in first generation Armada 370 u-boot
March 05, 2022 11:30AM
It appears u-boot in my Shuttle KS10 has a weird GPT implementation. When trying to boot from a 4TB disk, I get this:
Reset IDE: 
Marvell Serial ATA Adapter
Integrated Sata device found
  Device 0 @ 0 0:
Model: TOSHIBA HDWD240                          Firm: KQ000A   Ser#:         Z9J1S0I9S5HH
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1718295.8 MB = 1678.0 GB (-775897424 x 512)

GPT: last_usable_lba incorrect: 1D1C0BE8E > D1C0BEB0
get_partition_info_efi: *** ERROR: Invalid GPT ***
** Bad partition 1 **
So when detecting the disk it strips bit 32, yielding 0xD1C0BEB0 sectors. But when interpreting the GPT table, it uses the real size, and then complains they differ.
I tried a hybrid MBR, but u-boot is too smart to fall for that. It recognizes the protective MBR, and goes for the GPT table.
When providing both a valid GPT and a valid MBR only describing the boot partition, (the latter can be done by using fdisk -t mbr <device>) u-boot uses the MBR, and loads kernel + initramfs (jay!), but Linux freaks out and won't find any partitions, and so no rootfs.
Remedy: add a 'gpt' to the kernel commandline, to tell it to use GPT when both a valid MBR and a valid GPT table are found.
https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
March 05, 2022 05:04PM
Nice trick!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Hello,

First, thanks to all those who allow us to extend the life of our old linux devices.

I have a Goflex Home, I managed to boot a USB with debian following some of the posts find on the forum and now, I would like to boot on a HDD.
I put a 6TB disk and I have the same error message:
Reset IDE: Bus 0: OK Bus 1: not available
  Device 0: Model: ST6000VN0041-2EL11C  Firm: SC61 Ser#: ZA1676P0
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1528862.5 MB = 1493.0 GB (-1163856720 x 512)
GPT: last_usable_lba incorrect: 2BAA0F48E > BAA0F4B0
get_partition_info_efi: *** ERROR: Invalid GPT ***
** Invalid partition 1 **
GPT: last_usable_lba incorrect: 2BAA0F48E > BAA0F4B0
get_partition_info_efi: *** ERROR: Invalid GPT ***
** Invalid partition 1 **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
Your 'trick' might help me. Can you detail it for me because I'm a bit of a linux noob...

Thanks
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 14, 2022 08:04PM
Morbus,

With the GoFlex Home, there is no need for any trick. If you have installed the new u-boot (2017.07-tld-1), it will have no problem with the GPT 6TB disk.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 15, 2022 04:23AM
I did not install the new u-boot because I have bads blocks in my NAND. I will double check and, if true, I will ask for help in the relevant thread.

Thanks
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 16, 2022 06:38AM
The trick is simple. Use parted or fdisk to create a GPT partition table with a small boot partition (to contain the kernel and initamfs. 100MB or something like that) and further a rootfs partition and maybe a data partition, ... . The partition editor will automatically create a protective MBR table.
Then use 'fdisk -t mbr <device>' to let fdisk ignore the GPT table, remove the protective partition (type ee), and create a single, primary partition with the same start&size as the GPT boot partition. Without the protective partition u-boot (at least the one on my KS10) will not look further for the GPT table, and happily boot from the single partition it could find.
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 18, 2022 05:15AM
Thanks Mijzelf for this clever solution.

But, I did a test with a smaller capacity HDD and I still can't boot (No longer the GPT error message). I think I'm going to have to, as bodhi suggested, update my uboot. Once my uboot up to date and I am able to boot from a 500 GB HDD, I will try with my 6TB
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 18, 2022 11:17AM
It's probably worth mentioning that gdisk supports Hybrid GPT-MBR partitions and will do the hard bits for you.

It will also tell you useful things like the state of the secondary GPT table. In my experience a lot confusing uboot issues come from disks with invalid secondary GPT tables either because they aren't in the proper place after cloning a disk or just left over from being replaced with an MBR.
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 19, 2022 12:47PM
Unfortunately that doesn't work. U-boot recognizes the hybid partition table, reads the GPT and errors out. You could create a hybrid table, and then delete the 'ee' entry in MBR, but I suppose gdisk doesn't support that.
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 19, 2022 03:50PM
I think you're probably right, I've not looked that closely at the protective MBR in such cases.

Any chance you could post the output of gdisk -l /dev/sdx for one of your disks?
Re: Schizophrenic GPT implementation in first generation Armada 370 u-boot
October 21, 2022 12:47PM
# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.6

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

Found valid MBR and GPT. Which do you want to use?
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 1
Disk /dev/sda: 7814037168 sectors, 3.6 TiB
Model: TOSHIBA HDWD240 
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 446EE64A-8B66-4315-B510-37BF96729764
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 7814037134
Partitions will be aligned on 2048-sector boundaries
Total free space is 7813039725 sectors (3.6 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          999423   487.0 MiB   8300  Linux filesystem

<snip>

Your answer: 2
Using GPT and creating fresh protective MBR.
Disk /dev/sda: 7814037168 sectors, 3.6 TiB
Model: TOSHIBA HDWD240 
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 64633999-2B1D-204A-9E30-5D66D10D3D66
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 2048, last usable sector is 7814037134
Partitions will be aligned on 2048-sector boundaries
Total free space is 1679 sectors (839.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          999423   487.0 MiB   8300  
   2          999424        32249855   14.9 GiB    8300  
   3        32249856        34203647   954.0 MiB   8200  
   4        34203648      7814035455   3.6 TiB     8300  
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: