forked from ivandavidov/minimal-linux-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimal.sh
More file actions
executable file
·57 lines (54 loc) · 1.65 KB
/
minimal.sh
File metadata and controls
executable file
·57 lines (54 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
set -ex
KERNEL_VERSION=4.19.71
BUSYBOX_VERSION=1.31.0
SYSLINUX_VERSION=6.03
CORES=$(grep -c ^processor /proc/cpuinfo)
CORES=$((CORES + 1))
wget -O kernel.tar.xz http://kernel.org/pub/linux/kernel/v4.x/linux-$KERNEL_VERSION.tar.xz
wget -O busybox.tar.bz2 http://busybox.net/downloads/busybox-$BUSYBOX_VERSION.tar.bz2
wget -O syslinux.tar.xz http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-$SYSLINUX_VERSION.tar.xz
tar -xvf kernel.tar.xz
tar -xvf busybox.tar.bz2
tar -xvf syslinux.tar.xz
mkdir isoimage
cd busybox-$BUSYBOX_VERSION
make distclean defconfig
sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config
make -j${CORES} busybox install
cd _install
rm -f linuxrc
mkdir dev proc sys mnt
echo '#!/bin/sh' > init
echo 'dmesg -n 1' >> init
echo 'mount -t devtmpfs none /dev' >> init
echo 'mount -t proc none /proc' >> init
echo 'mount -t sysfs none /sys' >> init
echo 'setsid cttyhack /bin/sh' >> init
chmod +x init
find . | cpio -R root:root -H newc -o | gzip > ../../isoimage/rootfs.gz
cd ../../linux-$KERNEL_VERSION
make mrproper defconfig
sed -i 's/.*CONFIG_USB_XHCI_HCD.*/'\
'CONFIG_USB_XHCI_HCD=y\n'\
'CONFIG_USB_XHCI_DBGCAP=n\n'\
'CONFIG_USB_XHCI_PLATFORM=n'\
'/' .config
make -j${CORES} bzImage
cp arch/x86/boot/bzImage ../isoimage/kernel.gz
cd ../isoimage
cp ../syslinux-$SYSLINUX_VERSION/bios/core/isolinux.bin .
cp ../syslinux-$SYSLINUX_VERSION/bios/com32/elflink/ldlinux/ldlinux.c32 .
echo 'default kernel.gz initrd=rootfs.gz' > ./isolinux.cfg
xorriso \
-as mkisofs \
-o ../minimal_linux_live.iso \
-b isolinux.bin \
-c boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
./
cd ..
isohybrid minimal_linux_live.iso
set +ex