Protective MBR | GPT Disk Image | UEFI Dev (in C)
Вставка
- Опубліковано 3 лип 2024
- Starting a C program to write valid GPT disk images to later load & boot EFI applications for an OS bootloader.
This video goes over writing LBA 0/CHS sector 1 of the disk image for a protective MBR, as a lighter intro.
The following videos will be a bit longer for adding GPT headers & tables, the EFI System partition with FAT32 filesystem, and adding various command line options. It gets sloppier after the next couple videos as I wasn't as experienced and tried new stuff and had to debug things for a while. But hopefully these next few videos are educational or interesting enough to show how someone could make a tool by reading different specs and a few web pages, as a mostly weekend-scoped project.
Notes:
- Going to use a separate variable for the image size in lbas when writing the mbr, as that value can/will be used elsewhere and won't be clamped to a 32 bit limit.
Links:
uefi.org/specifications (GPT & MBR covered in spec 2.10 chapter 5)
en.wikipedia.org/wiki/Master_...
www.rodsbooks.com/gdisk/
sourceforge.net/projects/gptf...
UEFI Programming playlist:
• UEFI Programming in C
Git Repo:
github.com/queso-fuego/UEFI-G...
Repo state at the end of the video:
git clone -n github.com/queso-fuego/UEFI-G...
cd UEFI-GPT-image-creator
git checkout
8654aff6a29d09e8bfd8edaad0d7da701974004a
Repo state at the start of this video would be cloning the repo and starting from a new blank write_gpt.c file & makefile
Next video:
- Writing GPT headers and partition tables, including GUIDs & CRC32s.
Join the Community Discord: / discord
Contact:
queso_fuego.srht.site/contact.html
- Let me know if there's anything specific you'd like to see!
Questions about setup/software/etc.?
Check the FAQ: queso_fuego.srht.site/about.html
Outline:
0:00 intro & disk image overview
7:29 grab repo, add makefile
10:24 start writing program
15:50 look at UEFI spec for MBR info
22:10 write MBR
Music credits:
Winter Night by Sakura Girl | / sakuragirl_official
Music promoted by www.chosic.com/free-music/all/
Creative Commons CC BY 3.0
creativecommons.org/licenses/...
#mbr #diskimage #cprogramming - Наука та технологія
Man thank you so much, such a nice video series! Ultimate geek juice XD. And please do digress more!
Thank you for being thorough with this tutorial, and the links that you provide are extremely helpful.
Just to make sure everyone caught what he said, which I say in my tutorials too. You MUST use HDD if you want it working with all software. IMG will not work with everything. Example : VirtualBox uses IMG for floppies only. Which is only 1.44 meg files. However HDD is a raw format. Even RUFUS will work with HDD if you choose the dropdown and choose * . * as a way to get the file loaded. This is why VHD will be something to look forward too in his future videos, because VHD works with everything without any modifications. Even Rufus will work directly with VHD. Bottom line, save yourself hassel if you use his current code from this video by changing the IMG to HDD for now, until he adds in the ability of VHD.
SIDE NOTE : This GPT creator only makes a 36(correction, I meant 32), Meg file to begin with. That is the minimum for a FAT32 EFI setup. If you want to add an install, you need more space. Example, I use 40 megs for my setup. This allows enough room for a bootable BOOTX64.EFI file as well as other files that might be needed. Eventually leading to your creating a separate partition for your actual OS. All within the HDD / VHD file. (Or in the case of this video, IMG.)
You'll have ~32MB for files in the efi partition to work with, as I'm going to align the data region for the FAT filesystem on a 1MB boundary. But if you need a lot of files or ones larger than that, there will be an option to set the size of the esp and data partitions later
Such a legend!
amazing
Thanks!
Thank you! Appreciate it!
When calculating bytes to LBAs it could be better to use
(bytes + (512 - 1)) / 512
instead of
bytes / 512 + bytes % 512 ? 1 : 0
to save on expensive modulo opetation, especially if the divisor is known only at runtime (4k block disks).
This is YT comment section used right. Thank you, gonna use that one.
I can code in UEFI too.
what us ur computer setup?
Case: Coolermaster NR200P MAX
CPU: AMD Ryzen 9 5950x
CPU Cooler: Incl. with case; 280mm AIO, replaced fans with Arctic P12 PWM PST
GPU: MSI Gaming Trio Z RTX 3080 12GB
RAM: Corsair Vengeance LPX 32GB 3200Mhz
SSDs: Samsung 980 pro nvme 1TB, Crucial MX500 2TB
PSU: Incl. with case; Coolermaster V850 SFX gold
Motherboard: Gigabyte X570SI Aorus Pro AX
Monitor: Gigabyte M32U
@@QuesoFuego So u have two systems right? one is linux another one is windows?
I use a Linux VM from a Windows host, they're both on the same system