ventoy / Ventoy

A new bootable USB solution.
https://www.ventoy.net
GNU General Public License v3.0
62.73k stars 4.09k forks source link

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

Open davidhedlund opened 1 year ago

davidhedlund commented 1 year ago

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

MBR

Disk Capacity

16GB

Disk Manufacturer

Kingston

Image file checksum (if applicable)

Yes.

Image file download link (if applicable)

No response

What happened?

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

Why should it be possible to use Ventoy partition images formatted with MBR partition layout?

Test case

USB Flash Drive 1

Let's call this device: /dev/sdb

Install Ventoy on a USB drive with the following settings:

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: dos
Disk identifier: 0xbe854dad

Device     Boot Start    End Sectors  Size Id Type
/dev/sdb1  *     2048  66135   64088 31,3M  7 HPFS/NTFS/exFAT
/dev/sdb2       66136 131671   65536   32M ef EFI (FAT-12/16/32)

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)

Test the partition images (does not working)

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

Property Partition number: 1 Partition number: 2 Note
Flags boot esp  
Partition signature NTFS/exFAT/HPFS/ (0x07) EFI (FAT-12/16/32) (0xef)  
Partition type primary primary  
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!
!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!

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

image

On a final note, I have spent many hours (10-15 hours) to make sure that the manually created partitions in USB Flash Drive 2 are identical in every single aspect to the partitions installed by Ventoy in USB Flash Drive 1 1.

steve6375 commented 1 year ago

Ventoy writes special contents to sectors 0 to 1023. They are not standard MBR or boot code.

davidhedlund commented 1 year ago

Ventoy writes special contents to sectors 0 to 1023. They are not standard MBR or boot code.

Oh! Thank you very much, finally an explanation!

steve6375 commented 1 year ago

On an MBR disk (and maybe GPT?) You can try first restoring the bytes from 0 to 0x1BD in the MBR using dd for instance. There is a unique sequence of bytes/signature in the MBR boot code which is checked by Ventoy. The partition table starts a 1BE onwards, so don't overwrite that. Partition 2 must immediately follow Ptn 1 WITH NO GAP - not even 1 sector - i.e. first sector of ptn 2 = last sector of ptn1 + 1 Ptn2 must be 32MB (64k sectors) If I recall correctly (it was a while ago since I last looked!)

davidhedlund commented 1 year ago

On an MBR disk (and maybe GPT?) You can try first restoring the bytes from 0 to 0x1BD in the MBR using dd for instance. There is a unique sequence of bytes/signature in the MBR boot code which is checked by Ventoy. The partition table starts a 1BE onwards, so don't overwrite that. Partition 2 must immediately follow Ptn 1 WITH NO GAP - not even 1 sector - i.e. first sector of ptn 2 = last sector of ptn1 + 1 Ptn2 must be 32MB (64k sectors) If I recall correctly (it was a while ago since I last looked!)

I appreciate your help. There are many details, and I'm sure that I will get lost eventually. It took me 10-15 hours to evaluate the issue this far.

Do you mind writing a detailed tutorial that can be published if you have some time over later? Like, if you could test my setup, and verify that your solutions actually works, and exactly what you did by writing detailed steps in every program that you used.

Also, I'd be happy if you would like to submit a feature request. It would be great if Ventoy itself could update those values.

steve6375 commented 1 year ago

What exactly are you trying to do? Presumably you don't want to simply take a disk image and you don't want to just run the Ventoy disk making program?

davidhedlund commented 1 year ago

What exactly are you trying to do?

I'm trying to install Ventoy on a drive with existing OSes.

Presumably you don't want to simply take a disk image and you don't want to just run the Ventoy disk making program?

Both options will delete all the partitions (the OSes) on the drive.

I updated the top post with this use case. Thank you for bringing this up.

steve6375 commented 1 year ago

Ventoy requires an MBR, following sectors , ptn start at 2048 lba, ptn 2 exactly 64k sectors and immediately after ptn 1. You would have to move other os's to ptn3 and 4 They probably won't boot unless you boot to Ventoy first and then boot to each ptn. Do you really want to do that? Also you can't update those os's because the boot code and boot partition will be non standard and really confuse both windows and Linux . It is really not practical to have ventoy on an os boot disk because of os updates If efi disk then efi boot partition will be ventoy 32mb one for instance

davidhedlund commented 1 year ago

Ventoy requires MBR

The Ventoy making program has an option: Options -> Partition Style -> GPT. Do you know if Ventoy when installed with GPT, can use partition number 3-4 for example?

, ptn start at 2048 lba, ptn 2 exactly 64k sectors and immediately after ptn 1. You would have to move other os's to ptn3 and 4 They probably won't boot unless you boot to Ventoy first and then boot to each ptn. Do you really want to do that? Also you can't update those os's because the boot code and boot partition will be non standard and really confuse both windows and Linux . It is really not practical to have ventoy on an os boot disk because of os updates If efi disk then efi boot partition will be ventoy 32mb one for instance

Most GNU/Linux distros uses GPT too. Windows 11 requires GPT, and it works with both MBR and GPT. But I get your point: A lot of Windows versions require UEFI to use GPT (see the "Boot support" column in the table at https://en.wikipedia.org/wiki/GUID_Partition_Table#Windows:_64-bit_versions for comparison). So for older mainboards that comes with BIOS instead of UEFI, you have to use MBR instead.

It's way too much work to customize partitions in order to use Ventoy on the same drive that has existing OSes. I mainly opened this issue for development purposes, and to better understand how Ventoy works. In a distant future, it would be great if this issue would be fixed, so people would be able to easily install Ventoy on hard drives with existing OSes, because then people don't need to buy an extra NVMe hard drive just to run Ventoy as quickly as possible. These drives are expensive.

Thank you for important details once again.