Skip to content

Commit 2b6a375

Browse files
committed
build first efi image
1 parent 65c861e commit 2b6a375

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

build_iso.sh

+55-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/sh
22

3+
me=` id -u `
4+
if [ "$me" -gt 0 ] ; then
5+
echo 'Please run this script with root privileges!'
6+
fi
7+
38
source stage0n_variables
49

510
mkdir -p ${CLFS}/iso-bios/boot/isolinux
611
mkdir -p ${CLFS}/iso-bios/boot/system
7-
mkdir -p ${CLFS}/iso-uefi/boot
12+
mkdir -p ${CLFS}/iso-uefi/boot/efi
13+
mkdir -p ${CLFS}/iso-uefi/boot/isolinux
14+
mkdir -p ${CLFS}/tmp/efi
815

916
# Copy libraries
1017
echo ${CLFS}/cross-tools/${CLFS_TARGET} ${CLFS}/targetfs
@@ -13,11 +20,11 @@ tar -C ${CLFS}/cross-tools/${CLFS_TARGET} --exclude='*.a' --exclude='pkgconfig'
1320
# Create the initramfs
1421
( cd ${CLFS}/targetfs ; find . | cpio -o -H newc | gzip -c > ../iso-bios/boot/system/initrd.gz )
1522

16-
# copy the kernel
23+
# Copy the kernel
1724
kern=` ls ${CLFS}/targetfs/boot/vmlinuz* | tail -n1 `
1825
install -m 0644 "$kern" ${CLFS}/iso-bios/boot/system/vmlinuz
1926

20-
# copy the bootloader
27+
# Copy the bootloader
2128
for f in bios/com32/menu/menu.c32 bios/com32/menu/vesamenu.c32 \
2229
bios/com32/modules/ifcpu64.c32 bios/com32/modules/ifcpu.c32 \
2330
bios/com32/modules/reboot.c32 bios/com32/chain/chain.c32 \
@@ -32,8 +39,52 @@ for f in isolinux.cfg help.txt ; do
3239
install -m 0644 patches/${f} ${CLFS}/iso-bios/boot/isolinux/
3340
done
3441

42+
# Build the ISO for BIOS
3543
${CLFS}/hosttools/bin/xorriso -as mkisofs -joliet -graft-points \
3644
-c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin \
3745
-no-emul-boot -boot-info-table -boot-load-size 4 \
3846
-isohybrid-mbr ${CLFS}/hosttools/share/syslinux/bios/mbr/isohdpfx.bin \
39-
-V CLFS -o ${CLFS}/tiny-cross-bios.iso -r ${CLFS}/iso-bios
47+
-V TINYCROSS -o ${CLFS}/tiny-cross-bios.iso -r ${CLFS}/iso-bios
48+
sync
49+
50+
# Calculate size of the system dir
51+
efisize=` du ${CLFS}/iso-bios/boot/system | tail -n1 | awk '{print $1}' `
52+
efisize=` expr $efisize '*' 105 / 100 + 1000 `
53+
efiblocks=` expr $efisize / 4096 + 1 `
54+
55+
# Create and format EFI image
56+
dd if=/dev/zero bs=4M count=$efiblocks of=${CLFS}/iso-uefi/boot/efi/efi.img
57+
freeloop=` losetup -f `
58+
losetup $freeloop ${CLFS}/iso-uefi/boot/efi/efi.img
59+
mkfs.msdos -n EFIBOOT $freeloop
60+
mount -t vfat -o noatime $freeloop ${CLFS}/tmp/efi
61+
# Copy files to EFI image
62+
cp -v ${CLFS}/iso-bios/boot/system/vmlinuz ${CLFS}/tmp/efi/VMLINUZ.EFI
63+
cp -v ${CLFS}/iso-bios/boot/system/initrd.gz ${CLFS}/tmp/efi/INITRD.GZ
64+
mkdir -p ${CLFS}/tmp/efi/EFI/BOOT
65+
mkdir -p ${CLFS}/tmp/efi/loader/entries
66+
cp -v ${CLFS}/hosttools/lib/gummiboot/gummibootx64.efi ${CLFS}/tmp/efi/EFI/BOOT/BOOTX64.EFI
67+
sync
68+
sleep 3
69+
umount ${CLFS}/tmp/efi
70+
cp -v patches/loader.conf ${CLFS}/tmp/efi/loader/loader.conf
71+
cp -v patches/tiny.conf ${CLFS}/tmp/efi/loader/entries/tiny.conf
72+
losetup -d $freeloop
73+
# We need a dummy isolinux, otherwise ISO will not boot
74+
install -m 0644 ${CLFS}/hosttools/share/syslinux/bios/core/isolinux.bin ${CLFS}/iso-uefi/boot/isolinux
75+
76+
# Build ISO containing the EFI image
77+
${CLFS}/hosttools/bin/xorriso -as mkisofs -joliet -graft-points \
78+
-c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin \
79+
-no-emul-boot -boot-info-table -boot-load-size 4 \
80+
-isohybrid-mbr ${CLFS}/hosttools/share/syslinux/bios/mbr/isohdpfx.bin \
81+
-eltorito-alt-boot \
82+
-e boot/efi/efi.img -no-emul-boot \
83+
-isohybrid-gpt-basdat \
84+
-V TINYCROSS -o ${CLFS}/tiny-cross-uefi.iso -r ${CLFS}/iso-uefi
85+
86+
#${CLFS}/hosttools/bin/xorriso -as mkisofs -joliet -graft-points \
87+
# -e boot/efi/efi.img -no-emul-boot \
88+
# -isohybrid-gpt-basdat \
89+
# -V CLFS -o ${CLFS}/tiny-cross-uefi.iso -r ${CLFS}/iso-uefi
90+

build_stage0n.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
me=` id -u `
4+
if [ "$me" -gt 0 ] ; then
5+
echo 'Please run this script with root privileges!'
6+
fi
7+
38
source stage0n_variables
49

510
mkdir -p ${CLFS}/build

patches/loader.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
timeout 30
2+
default tiny*

patches/tiny.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title TinyCrossLinux
2+
linux /VMLINUZ.EFI
3+
initrd /INITRD.GZ
4+
options dummy=0

stage02/0001_basefiles.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ install -m 0755 patches/etc-rc.d-0040-udhcpd.sh ${CLFS}/targetfs/etc/rc.d/0040-u
3636
# optional startup scripts
3737
install -m 0755 patches/etc-rc.d-0055-httpd.sh ${CLFS}/targetfs/etc/rc.d/0055-httpd.sh
3838
install -m 0755 patches/etc-rc.d-0060-tftpd.sh ${CLFS}/targetfs/etc/rc.d/0060-tftpd.sh
39-
install -m 0755 patches/etc-rc.d-0065-udhcpd.sh ${CLFS}/targetfs/etc/rc.d/0060-udhcpd.sh
39+
install -m 0755 patches/etc-rc.d-0065-udhcpd.sh ${CLFS}/targetfs/etc/rc.d/0065-udhcpd.sh

0 commit comments

Comments
 (0)