Compare commits

...

3 Commits

Author SHA1 Message Date
4lDO2 3611013c7c Merge branch 'master' into 'master'
Change the format of harddrive-efi.bin to GPT.

See merge request redox-os/redox!1226
2020-01-08 06:58:00 +00:00
4lDO2 fd52641dbe Update bootloader-efi. 2020-01-07 09:35:35 +11:00
4lDO2 455dc29bc9 Change the format of harddrive-efi.bin to GPT. 2020-01-06 18:33:22 +11:00
2 changed files with 27 additions and 2 deletions

@ -1 +1 @@
Subproject commit 023b748093b6944250f50e63a62f19b87be77b75 Subproject commit 3c1377f0f7d30db28b7b65165ff10f2df24e92f4

View File

@ -34,7 +34,7 @@ build/bootloader.efi: bootloader-efi/build/$(EFI_TARGET)/boot.efi
mkdir -p build mkdir -p build
cp -v $< $@ cp -v $< $@
build/harddrive-efi.bin: build/bootloader.efi build/filesystem.bin build/harddrive-efi-old.bin: build/bootloader.efi build/filesystem.bin
dd if=/dev/zero of=$@.partial bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 1) dd if=/dev/zero of=$@.partial bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 1)
mkfs.vfat $@.partial mkfs.vfat $@.partial
mmd -i $@.partial efi mmd -i $@.partial efi
@ -42,6 +42,31 @@ build/harddrive-efi.bin: build/bootloader.efi build/filesystem.bin
mcopy -i $@.partial $< ::efi/boot/bootx64.efi mcopy -i $@.partial $< ::efi/boot/bootx64.efi
cat $@.partial build/filesystem.bin > $@ cat $@.partial build/filesystem.bin > $@
.ONESHELL:
build/harddrive-efi.bin: build/bootloader.efi build/filesystem.bin
# TODO: Validate the correctness of this
# Populate an EFI system partition
dd if=/dev/zero of=$@.esp bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 1)
mkfs.vfat $@.esp
mmd -i $@.esp efi
mmd -i $@.esp efi/boot
mcopy -i $@.esp $< ::efi/boot/bootx64.efi
# Create the disk
dd if=/dev/zero of=$@ bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 2 + $$(du -m build/filesystem.bin | cut -f1))
# Create partition table
parted -s -a minimal $@ mklabel gpt
efi_disk_size=$$(du -m $< | cut -f1) efi_disk_blkcount=$$(expr $$efi_disk_size \* $$(expr 1048576 / 512))
efi_end=$$(expr 2048 + $$efi_disk_blkcount)
efi_last=$$(expr $$efi_end - 1)
parted -s -a minimal $@ mkpart EFI fat32 2048s "$${efi_last}s"
fs_disk_size=$$(du -m build/filesystem.bin | cut -f1) fs_disk_blkcount=$$(expr $$fs_disk_size \* $$(expr 1048576 / 512))
parted -s -a minimal $@ mkpart redox ext4 "$${efi_end}s" $$(expr $$efi_end + $$fs_disk_blkcount)s
parted -s -a minimal $@ set 1 boot on
parted -s -a minimal $@ set 1 esp on
# Write the partitions
dd if=$@.esp bs=512 seek=2048 conv=notrunc count=$$efi_disk_blkcount of=$@
dd if=build/filesystem.bin seek=$$efi_end bs=512 conv=notrunc of=$@ count=$$fs_disk_blkcount
build/livedisk-efi.iso: build/bootloader.efi build/kernel_live build/livedisk-efi.iso: build/bootloader.efi build/kernel_live
dd if=/dev/zero of=$@.partial bs=1048576 count=$$(expr $$(du -mc $^ | grep 'total$$' | cut -f1) + 1) dd if=/dev/zero of=$@.partial bs=1048576 count=$$(expr $$(du -mc $^ | grep 'total$$' | cut -f1) + 1)
mkfs.vfat $@.partial mkfs.vfat $@.partial