GRUB2 Command Explanation or Example needed

I again hit a wall in a manual. Even if you really take the time to read a manual, that might still sometimes be useless or not as useful as it should be.

This apparently does not happen to me only.

I need an example of gptsync usage.

NOT this gptsync!

I need an example for the one from GRUB2.

The manual tells me, I can provide up to 3 partitions as arguments to the command. How are the partitions identified? By location? By name? By label? By UUID? How?

At least, there won’t be some Linux hardcore C programmer coming here, telling me to read the manual instead of asking… :laughing: Because I am literally reading the manual!!!


I found the second ambiguity. It is also regarding on how to denote a partition.

How would the partition argument look like, when given as an argument to this command?

2 Likes

I suppose what we have to remember that even though we read a manual, does not mean we are going to understand it. No matter how much we think we know, there is always something new to learn. Because of the engineer thinking of the author’s mind, it isn’t made simple for someone like me who wants it to be put in plain English and actually have pictures or diagrams, of the subject being explained. There was only a few things I managed to understand, but only because I have used them before. Like pushing shift to get into Grub before the Grub activates. Wish they could put these manuals into easy to follow guides. I would like to see these manuals written as a children’s book.

Once upon a time there was Grub, it wasn’t an insect but a written one in computer language. The sole purpose of this Grub is to say hello, after hearing an hello, from it’s best friend BIOS. BIOS lives on the spaceship called Motherboard. No not bored as in boring, but board like wooden board. :grin:

2 Likes

It’s the same as just Google it :grin:

1 Like

If the partition names are being used by grub2 (ie if they are not just names being passed on to some other command), then grub identifies partitions by things like (hd0,1)… disk zero, partition 1.

I have not tested it with gptsync, but that is what you use at the grub> command prompt.

Neville

This command populates the legacy MBR with the specified partition entries on device. Up to three partitions may be used.

If I define a partition like hd0,1, then why do I need to provide a device? The disk number is already part of this notation.

Besides that, I didn’t find a single example on the internet, displaying usage of this command.

I wish, there were real life examples of GRUB2’s gptsync usages. Then, we would not need to guess or re-interpret the manual. Just a look at the example would most likely make things clear or at least help in understanding the case further.

The device identifies the MBR location

Am I reading it right? gptsync copies the gpt partition table to the mbr?
So it doesnt put grub in the mbr, just the partition table?
But it would not be correct as copied? The gpt partition table is different to the msdos partition table. Does it convert it or something?

I thought a gpt partitioned disk did not have a real mbr? It has a protective mbr (pmbr) which is just a space which is there to save you if you accidentslly try to treat it as an msdos partitioned disk.

So I dont understand what you are trying to do… are you trying to copy gpt information from some file onto the first sector of the device?
If so there are other ways eg use dd
and I dont understand gptsync either
so I am not much help
Neville

It’s about the backup MBR of GPT.

GPT has a backup MBR to allow BIOS support, when booting a GPT disk.

I’m trying to understand the command. Not trying to use it. I just want to know how it is supposed to be used.

There are 2 copies of the gpt, one in the first sector, and one in the last.
There is also a protective mbr (Pmbr) which I though was just a null space. That is for a uefi boot. It doesnt need an mbr for uefi boot, all the boot info is in the EFI System partition.

Yes you can legacy boot a gpt disk… I do it all the time. In a legacy boot the bios needs to find a legacy mbr with grub and everything on it?
So you are talking about that MBR used for a legacy boot.?

Well I think the gptsync command might be for restoring the gpt partition table from a file.
Yes the gpt partition table info is in the same first sector as a legacy mbr, but I think the grub manual has a terminology problem calling it the mbr… it should refer to it as the first sector.

Then all the confusion which I displayed above would be avoided.
They should talk about copying the gpt to the disk first sector… not to the mbr.

Clonezilla can restore gpt info. We might look at how it does it.

Neville

The device identifies the MBR location

Am I reading it right? gptsync copies the gpt partition table to the mbr?
So it doesnt put grub in the mbr, just the partition table?
But it would not be correct as copied? The gpt partition table is different to the msdos partition table. Does it convert it or something?

Why would you want to do that?

THIS REPLY SHOULD HAVE BEEN BEFORE THE PREVIOUS ONE

Disks using the GUID Partition Table (GPT) also have a legacy Master Boot Record (MBR) partition table for compatibility with the BIOS and with older operating systems. The legacy MBR can only represent a limited subset of GPT partition entries.

This command populates the legacy MBR with the specified partition entries on device. Up to three partitions may be used.

type is an MBR partition type code; prefix with ‘0x’ if you want to enter this in hexadecimal. The separator between partition and type may be ‘+’ to make the partition active, or ‘-’ to make it inactive; only one partition may be active. If both the separator and type are omitted, then the partition will be inactive.

@Akito
The source code is here

One comment in the code says

/* Make sure the MBR is a protective MBR and not a normal MBR. */

I want to go and study the source code.
That should clarify… Open source does have its merits

Neville

I had found it, as well, but didn’t have the time to look into it, yet.

That said, it shouldn’t be required to read the source code to understand…

Please, go ahead.

Indeed!

I found the second ambiguity. Check out the original post, which I extended.

Well I think the `gptsync` grub command might be for restoring the gpt partition table from a file.

That is wrong.
It makes an msdos partition table (the same as if you had done an msdos partition table in gparted). except it gets the entries for the msdos table from the entries in your gpt table.

Why would you want to do that? How would a disk with 2 partition tables behave?

No wonder there is no example. No-one can think of a use for it.

Neville

If I understand the manual correctly, it is supposed to populate the backup MBR of the GPT disk to the specified partitions.

Yes, that is how I read it now too. My guess above was a mistake.

So maybe it would still be seen as a GPT disk by the OS, but there would be junk in the PMBR… For what purpose ? The PMBR is only there to protect you, if you make a mistake and write stuff to what you mistakedly think is an MBR disk.

It makes no sense

If I understand correctly, it just applies the backup MBR. So, in case it is missing or something is wrong with it, for whatever reason, it gets populated again. That’s how I read it.

There is this rather confusing document

https://www.wensley.org.uk/gpt

As I read it, it seems to say that you would only use gptsync if you wanted to setup,a gpt disc to boot with grub1

Apparently grub1 can only handle msdos partition tables, not gpt

With grub2 it would be unnecessary , as it can handle either gpt or msdos partition tables.

So it is a legacy command, an hangover from grub1

Do you agree?

It’s more confusing than you think.

Yes I understand you dont want the Ubuntu gptsync command

It is irrelevant to grub 2… it is for legacy bootloaders

an mbr partition table is required to use legacy bootloaders (lilo, grub) on efi-based (extensible firmware interface) machines like the intel-based macs. gptsync is usually used in combination with the refit boot menu on such machines.

That came from a mint website.

OK you might need an example of grub > gptsync
but there will not be one
because users of grub2 do not need to do this.