Add create_linux_template.sh

This commit is contained in:
Raj 2024-03-13 23:51:10 +05:30
parent d4f946dbc9
commit 52cb2e58e6
1 changed files with 50 additions and 0 deletions

50
create_linux_template.sh Normal file
View File

@ -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