Skip to content

Commit

Permalink
WIP: EFI boot support
Browse files Browse the repository at this point in the history
  • Loading branch information
NHellFire committed Jul 18, 2017
1 parent a435bfc commit b902769
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 7 deletions.
2 changes: 2 additions & 0 deletions custom/EFI-grub/.gitignore
@@ -0,0 +1,2 @@
grub-built
*.EFI
18 changes: 18 additions & 0 deletions custom/EFI-grub/build-grub.sh
@@ -0,0 +1,18 @@
#!/bin/sh
set -e
DIR="$(readlink -f .)"

# Dependencies: xfonts-unifont

cd git
./autogen.sh

./configure --prefix="$DIR/grub-built" --with-platform=efi --enable-grub-mkfont

make -j`nproc`

make install

# Install font
make unicode.pf2
cp -v unicode.pf2 ../
31 changes: 31 additions & 0 deletions custom/EFI-grub/efi-grub.sh
@@ -0,0 +1,31 @@
#!/bin/sh
set -e

PATH="./grub-built/bin:$PATH"

MODULES="normal"
MODULES="$MODULES part_gpt part_msdos" # Partition tables
MODULES="$MODULES fat ntfs exfat iso9660" # Filesystems
MODULES="$MODULES linux chain" # Boot targets
MODULES="$MODULES help reboot halt" # Utilities
MODULES="$MODULES ls search search_fs_file" # Utilities
MODULES="$MODULES usb_keyboard at_keyboard all_video" # Hardware support
MODULES="$MODULES gfxterm font" # Graphical terminal
MODULES="$MODULES configfile sleep" # TEMP - Debugging

grub-mkimage --format=x86_64-efi --output=BOOTX64.EFI --config=embed.cfg --prefix=/EFI/BOOT $MODULES

sizeMB=$(set -- $(du -m BOOTX64.EFI); echo $1)

dd if=/dev/zero of=efiboot.img bs=1M count=$sizeMB

mkdosfs -F 12 efiboot.img

mkdir -p efiboot
sudo mount -o loop efiboot.img efiboot

sudo mkdir -p efiboot/EFI/BOOT

sudo cp BOOTX64.EFI efiboot/EFI/BOOT/

sudo umount efiboot
Binary file added custom/EFI-grub/efiboot.img
Binary file not shown.
2 changes: 2 additions & 0 deletions custom/EFI-grub/embed.cfg
@@ -0,0 +1,2 @@
search --set=root --file /dban.bzi
set prefix=($root)
2 changes: 1 addition & 1 deletion custom/EFI-grub/git
Submodule git updated from 4e0f8f to e54c99
13 changes: 13 additions & 0 deletions custom/EFI-grub/grub.cfg
@@ -0,0 +1,13 @@
set timeout=-1

if loadfont ${prefix}/unicode.pf2
then
insmod gfxterm
set gfxmode=auto
set gfxpayload=keep
terminal_output gfxterm
fi

menuentry "DBAN (interactive)" {
linux /dban.bzi nuke="dwipe" silent
}
Binary file added custom/EFI-grub/unicode.pf2
Binary file not shown.
Binary file removed isohybrid
Binary file not shown.
2 changes: 2 additions & 0 deletions isoroot/i586/SOURCE
@@ -0,0 +1,2 @@
ISOLINUX source can be obtained here: http://www.syslinux.org/wiki/index.php?title=Download
We are currently using v6.03
Binary file added isoroot/i586/isohdpfx.bin
Binary file not shown.
19 changes: 13 additions & 6 deletions master.sh
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

BR2_CONFIG=buildroot/.config

Expand All @@ -14,10 +15,9 @@ OUTDIR=isoroot/${BR2_ARCH}/output
INDIR=isoroot/${BR2_ARCH}/input
VOLUME="DBAN v$DBAN_VERSION ($BR2_ARCH)"

ISOHYBRID=0
PRERELEASE=0

GIT_TAG=$(git describe --tags --exact-match 2>/dev/null)
GIT_TAG=$(git describe --tags --exact-match 2>/dev/null || true)
if [ -z "$GIT_TAG" -o "${GIT_TAG%/*}" = "nightly" ]; then
GIT_VERSION=$(git log -1 --date=format:"%Y%m%d" --pretty=format:"%cd-g%h")
VOLUME="DBAN $GIT_VERSION"
Expand All @@ -26,16 +26,24 @@ fi

BZIMAGE_DIR=

mkdir -p $OUTDIR

MKISOFS="xorriso -as mkisofs"
MKISOFS_ARGS=()
case "${BR2_ARCH}" in
i586)
test ! -r "$INDIR/isolinux.bin" && echo "$0: $INDIR/isolinux.bin is missing." && exit 3
MKISOFS_ARGS+=(-b isolinux.bin -c isolinux.cat -no-emul-boot -boot-load-size 4 -boot-info-table)
MKISOFS_ARGS+=(-V "$VOLUME")
ISOHYBRID=1
# Copy GRUB files
for file in efiboot.img grub.cfg unicode.pf2; do
cp -v "custom/EFI-grub/$file" "$OUTDIR/"
done
MKISOFS_ARGS+=(-isohybrid-mbr "$INDIR/../isohdpfx.bin" -isohybrid-gpt-basdat -eltorito-alt-boot -e efiboot.img -no-emul-boot)
;;
powerpc)
test ! -r "$INDIR/ppc/yaboot" && echo "$0: $INDIR/ppc/yaboot is missing." && exit 3
MKISOFS="mkisofs"
MKISOFS_ARGS+=(-chrp-boot -hfs -no-cache-inodes -no-desktop -part -r)
MKISOFS_ARGS+=(-map "$OUTDIR/ppc/map")
MKISOFS_ARGS+=(-hfs-bless "$OUTDIR/ppc")
Expand All @@ -56,9 +64,8 @@ else
OUTNAME="dban-${GIT_VERSION}_linux-${BR2_LINUX_KERNEL_VERSION}_${BR2_ARCH}.iso"
fi

mkdir -p $OUTDIR
cp -r isoroot/generic/* $OUTDIR/
cp -r $INDIR/* $OUTDIR/
mkisofs -o "$OUTNAME" "${MKISOFS_ARGS[@]}" "$OUTDIR"
[ "$ISOHYBRID" = "1" ] && ./isohybrid "$OUTNAME"
echo "> $MKISOFS -o $OUTNAME ${MKISOFS_ARGS[@]} $OUTDIR"
$MKISOFS -o "$OUTNAME" "${MKISOFS_ARGS[@]}" "$OUTDIR"
ls -ll "$OUTNAME"

0 comments on commit b902769

Please sign in to comment.