diff --git a/create_linux_template.sh b/create_linux_template.sh new file mode 100644 index 0000000..0f276fc --- /dev/null +++ b/create_linux_template.sh @@ -0,0 +1,50 @@ +# setup +apt update +apt-get install bzip2 git vim make gcc libncurses-dev flex bison bc cpio libelf-dev libssl-dev syslinux dosfstools + +git clone --depth 1 https://github.com/torvalds/linux.git + +cd linux + +make menuconfig +# no change needed, just make sure 64bit is enabled + +# check num of cores using nproc +make -j 4 + +mkdir /boot-files +cp arch/x86/boot/bzImage /boot-files/ +cd .. + +git clone --depth 1 https://git.busybox.net/busybox +cd busybox + +# static build to keep it minimal +make menuconfig + +make -j 4 + +mkdir /boot-files/initramfs +make CONFIG_PREFIX=/boot-files/initramfs install + +cd /boot-files/initramfs/ + +echo -e '#!/bin/sh\n/bin/sh' > init +chmod +x init + +rm linuxrc + +find . | cpio -o -H newc > ../init.cpio +cd .. + +dd if=/dev/zero of=boot bs=1M count=50 + +mkfs -t fat boot + +syslinux boot + +mkdir m +mount boot m +cp bzImage init.cpio m + +umount m