-
-
Save bahamat/029629aa7aa1cabb096cd28bde164a74 to your computer and use it in GitHub Desktop.
How to create a bootable disk image that works with bios and uefi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# apt install gdisk syslinux syslinux-efi mtools | |
IMG=boot-image.img | |
SIZE=300 | |
KERNEL=vmlinz | |
INITRAMFS=initrd.img | |
MD="mmd -i ${IMG}@@1M" | |
CP="mcopy -i ${IMG}@@1M" | |
RN="mren -i ${IMG}@@1M" | |
dd if=/dev/zero bs=1M count=$SIZE of=$IMG | |
sgdisk -n 1::+$(($SIZE-2))M -c 1:EFI-SYSTEM -t 1:ef00 --hybrid=1 --attributes=1:set:2 ${IMG} | |
mkfs.fat -S 512 --offset 2048 ${IMG} -n EFI-SYSTEM | |
$MD ::efi | |
$MD ::efi/boot | |
$CP /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi ::efi/boot/bootx64.efi | |
$CP /usr/lib/syslinux/modules/efi64/ldlinux.e64 ::efi/boot/ldlinux.e64 | |
$MD ::system | |
$CP $INITRAMFS $KERNEL ::system | |
dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of=${IMG} | |
syslinux --offset $((1024*1024)) --install ${IMG} | |
$CP syslinux.cfg ::syslinux.cfg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFAULT linux | |
LABEL linux | |
SAY Now booting the kernel from SYSLINUX... | |
KERNEL /system/vmlinuz | |
APPEND initrd=/system/initrd.img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment