Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue]: "Error message: <MBR check failed>" for manually created GPT partitions + restored Ventoy GPT partition images #2606

Open
2 tasks done
davidhedlund opened this issue Oct 12, 2023 · 11 comments

Comments

@davidhedlund
Copy link

davidhedlund commented Oct 12, 2023

Official FAQ

  • I have checked the official FAQ.

Ventoy Version

1.0.95

What about latest release

Yes. I have tried the latest release, but the bug still exist.

Try alternative boot mode

Yes. I have tried them, but the bug still exist.

BIOS Mode

Legacy BIOS Mode

Partition Style

GPT

Disk Capacity

16GB

Disk Manufacturer

Kingston

Image file checksum (if applicable)

Yes.

Image file download link (if applicable)

No response

What happened?

Official FAQ

  • I have checked the official FAQ.

Ventoy Version

1.0.95

What about latest release

Yes. I have tried the latest release, but the bug still exist.

Try alternative boot mode

Yes. I have tried them, but the bug still exist.

BIOS Mode

UEFI Mode

Partition Style

GPT

Disk Capacity

16GB

Disk Manufacturer

Kingston

Image file checksum (if applicable)

Yes.

Image file download link (if applicable)

No response

Test case

Before you post comments, please read about the proposed solution at:

Note: What I learned from steve6375 in the comment discussion after I filed this issue:

  • All GPT disks contain an MBR sector at LBA0 as do all legacy MBR disks.

USB Flash Drive 1

Let's call this device: /dev/sdb

Install Ventoy on a USB drive with the following settings:

  • Options -> Partition Style -> GPT
  • "Option -> Partition Configuration". Check "Preserve some space at the end of the disk" and add as little space over as possible in order to quickly export a disk image, and partition images later.
  • Install Ventoy.
  • In gnome-disk: 1) Export the disk image (ventoy.img) 2) export both partitions (partition_1.img, partition_2.img).
sudo fdisk /dev/sdb

Command (m for help): p
Disk /dev/sdb: 14,41 GiB, 15472047104 bytes, 30218842 sectors
Disk model: DataTraveler 3.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DD517BF7-A42B-134B-14CC-EB8291548F88

Device     Start    End Sectors  Size Type
/dev/sdb1   2048  66103   64056 31,3M Microsoft basic data
/dev/sdb2  66104 131639   65536   32M Microsoft basic data

Note, this is just an example, you must generate a table for your own device!

USB Flash Drive 2

Let's call this device: /dev/sdc

Test the disk image (working)

  • In gnome-disk, "Drive Options -> Restore Disk Image...", select ventoy.img
  • Shut down the computer
  • Configure the BIOS to boot the USB Flash Drive 2, save and exit
  • Ventoy is working, fine!

Test the partition images (does not working)

  • Format the drive as GPT. To do it in gnome-disk: Drive Options -> Format Disk... -> Partitioning. GPT

Create two new partitions are identical to the partitions in /dev/sdb:

Property Partition number: 1 Partition number: 2
Flags msftdata hidden, msftdata
Partition label Ventoy VTOYEFI
Partition signature Microsoft basic data (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7) Microsoft basic data (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7)
  • Sectors: Start, and end sectors (see sudo fdisk /dev/sdb then type "p" like stated in the previous section).
  • Partition 1: Restore partition_1.img
  • Partition 2: Restore partition_2.img
  • Shut down the computer
  • Configure the BIOS to boot the USB Flash Drive 2, save and exit
  • Ventoy does not boot. This screen is shown:
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!

This is not a standard Ventoy device and is NOT supported (12).
"Error message: <MBR check failed>"

image

Proposed solution

Avoid MBR check if Ventoy is booting GPT.

@davidhedlund
Copy link
Author

davidhedlund commented Oct 12, 2023

@steve6375 Surprisingly, even if I use GPT, I get: "Error message: <MBR check failed>"

@davidhedlund davidhedlund changed the title [issue]: Cannot use Ventoy partition images for manually created GPT partitions [issue]: "Error message: <MBR check failed>" for manually created GPT partitions + restored Ventoy GPT partition images Oct 12, 2023
@steve6375
Copy link

Ventoy checks for special signature bytes in MBR sector LBA 0 - otherwise it is not recognised as a Ventoy drive
P.S. when I said size of ptn2 should be 64 sectors, I should have said 64K sectors!

@davidhedlund
Copy link
Author

davidhedlund commented Oct 12, 2023

Ventoy checks for special signature bytes in MBR sector LBA 0 - otherwise it is not recognised as a Ventoy drive

Thank you.

  • I only get "Error message: <MBR check failed>" when I'm restoring partition images, why don't I get this error when I'm restoring a disk image?

  • Do you know how to modify the GPT partitions that has been restored from the partition images to bypass this error?

P.S. when I said size of ptn2 should be 64 sectors, I should have said 64K sectors!

Thank you for updating your comments about this in #2605

@steve6375
Copy link

steve6375 commented Oct 12, 2023

Device Start End Sectors Size Type
/dev/sdb1 2048 66103 64056 31,3M Microsoft basic data
/dev/sdb2 66104 131639 65536 32M Microsoft basic data

You can see from the partition table that ptn1 starts at LBA 2048 (must start here) and ptn2 starts as 66104.
So when you restore partition images, LBA 0 (the first sector) is not touched.
Ventoy checks the bytes in LBA 0 for specific values which identifies it a Ventoy drive with grub2 boot code.

A disk image will restore all sectors from 0 to the end of the disk (or end of last partition?).

A GPT disk contains an LBA 0 MBR which is there for compatibility. It also contains a sort of pseudo-partition table in that LBA 0 first sector. Normally a GPT MBR partition table just points to a large 'partition' which is actually the whole GPT 'area' (that may itself contain one or more GPT partitions).

As I said before - you need to modify the bytes in LBA 0 to match those used by ventoy (from byte 0 to byte 0x1BD).

P.S. I think I said ptn 1 should start at 1024 before - I should have said LBA 2048 (sorry, getting old!).

@davidhedlund
Copy link
Author

davidhedlund commented Oct 12, 2023

P.S. I think I said ptn 1 should start at 1024 before - I should have said LBA 2048 (sorry, getting old!).

Thank you for updating #2605 (comment)

@davidhedlund
Copy link
Author

Device Start End Sectors Size Type /dev/sdb1 2048 66103 64056 31,3M Microsoft basic data /dev/sdb2 66104 131639 65536 32M Microsoft basic data

You can see from the partition table that ptn1 starts at LBA 2048 (must start here) and ptn2 starts as 66104. So when you restore partition images, LBA 0 (the first sector) is not touched. Ventoy checks the bytes in LBA 0 for specific values which identifies it a Ventoy drive with grub2 boot code.

A disk image will restore all sectors from 0 to the end of the disk (or end of last partition?).

A GPT disk contains an LBA 0 MBR which is there for compatibility. It also contains a sort of pseudo-partition table in that LBA 0 first sector. Normally a GPT MBR partition table just points to a large 'partition' which is actually the whole GPT 'area' (that may itself contain one or more GPT partitions).

As I said before - you need to modify the bytes in LBA 0 to match those used by ventoy (from byte 0 to byte 0x1BD).

Alright. I'll try to find out how to do that.

  • I don't know why the Ventoy making program is naming partition 2 to VTOYEFI even if you choose "Options -> Partition Style -> GPT", because GPT does not use EFI. Is this an issue that should be raised separately?

  • Don't you think it would be useful if Ventoy just skipped MBR check if it is booting GPT partitions?

@steve6375
Copy link

steve6375 commented Oct 12, 2023

The MBR is short for the master boot record, the MBR can still be present on a GPT disk for legacy booting.
In fact you can have a hybrid disk which contains MBR partitions and a gpt area containing GPT partitions.
Gpt is a type of partition structure on a disk.
Efi is a type of firmware. You can uefi boot from both legacy MBR disks and GPT disks.

So I don't understand your last post.
All gpt disks contain an MBR sector at LBA0 as do all legacy MBR disks. A GPT disk may or may not contain boot code in the MBR area as it is only needed for legacy booting
Ventoy checks the boot code in lba 0 to see if it is a Ventoy disk.

@davidhedlund
Copy link
Author

davidhedlund commented Oct 13, 2023

Device Start End Sectors Size Type /dev/sdb1 2048 66103 64056 31,3M Microsoft basic data /dev/sdb2 66104 131639 65536 32M Microsoft basic data

You can see from the partition table that ptn1 starts at LBA 2048 (must start here) and ptn2 starts as 66104. So when you restore partition images, LBA 0 (the first sector) is not touched. Ventoy checks the bytes in LBA 0 for specific values which identifies it a Ventoy drive with grub2 boot code.

A disk image will restore all sectors from 0 to the end of the disk (or end of last partition?).

A GPT disk contains an LBA 0 MBR which is there for compatibility. It also contains a sort of pseudo-partition table in that LBA 0 first sector. Normally a GPT MBR partition table just points to a large 'partition' which is actually the whole GPT 'area' (that may itself contain one or more GPT partitions).

As I said before - you need to modify the bytes in LBA 0 to match those used by ventoy (from byte 0 to byte 0x1BD).

P.S. I think I said ptn 1 should start at 1024 before - I should have said LBA 2048 (sorry, getting old!).

Thanks for a thorough explanation! Now I really understand what it's all about. I wouldn't have asked my question if I knew all this.

@davidhedlund
Copy link
Author

The MBR is short for the master boot record, the MBR can still be present on a GPT disk for legacy booting. In fact you can have a hybrid disk which contains MBR partitions and a gpt area containing GPT partitions. Gpt is a type of partition structure on a disk. Efi is a type of firmware. You can uefi boot from both legacy MBR disks and GPT disks.

So I don't understand your last post. All gpt disks contain an MBR sector at LBA0 as do all legacy MBR disks. A GPT disk may or may not contain boot code in the MBR area as it is only needed for legacy booting Ventoy checks the boot code in lba 0 to see if it is a Ventoy disk.

Very useful information, I'm lucky to get help from you. Where did you learn all this? Are you a Ventoy developer?

@davidhedlund
Copy link
Author

All gpt disks contain an MBR sector at LBA0 as do all legacy MBR disks.

I added this to the top post.

@steve6375
Copy link

I am the author of Easy2Boot (my icon kind of gives you a clue!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants