Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inspect: check presence of BIOS boot partition to handle BIOS+GPT setup
If the guest uses BIOS firmware but GPT partitioned disk, v2v inspection might fail to correctly detect the firmware being used by the source machine. Namely, consider the following GPT partition table: Number Start (sector) End (sector) Size Code Name 1 2048 4095 1024.0 KiB EF02 2 4096 528383 256.0 MiB EF00 3 528384 125827071 59.7 GiB 8300 4 125827072 134215679 4.0 GiB 8200 where partition 1 is a BIOS boot partition (code 0xEF02, GPT partition entry with GUID 21686148-6449-6E6F-744E-656564454649), and partition 2 is an EFI System partition (code 0xEF00, GPT partition entry with GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B). The former is commonly used to store the bootloader in BIOS+GPT machines. The latter is used by UEFI powered machines. Normally an OS installer wouldn't put those two together: if the disk is being partitioned in GPT, there's either BIOS boot partition (if BIOS firmware is used) or EFI System partition (if UEFI firmware is used). However, GRUB2 will deal with such "busted" layout just fine, so this configuration may exist. If it is the case, v2v inspection will detect the presence of an EFI system partition and mistakenly mark the system as UEFI. So let's prioritize Bios boot partition over ESP. As discussed in [1], this solution is not entirely bulletproof. It will work in case a GPT disk was first used in a UEFI machine, and then put into a BIOS machine with an ESP partition remaining on it. It won't work in the opposite case, i.e. when a GPT disk is moved from BIOS machine to UEFI machine with BIOS boot partition remaining on it. However, it's better to prioritize something, and the latter case is less probable than the former. [1] https://listman.redhat.com/archives/libguestfs/2022-December/030401.html Co-authored-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Message-Id: <20221221163831.423551-3-andrey.drobyshev@virtuozzo.com> [lersek@redhat.com: fix typos in the commit message]
- Loading branch information