请注意,该脚本可以生成非常小的实时Linux操作系统,仅支持shell,不支持网络。
![004e5ed756afec352d69bb4255628a68.png](https://i-blog.csdnimg.cn/blog_migrate/5e0ec28d04a14d5caa86d20a5112c7f1.jpeg)
如果你用的系统是Ubuntu或是Linux Mint,可以通过运行下面的命令来解决构建环境搭建。
1.更新包索引。
sudo apt update
2.安装构建环境。
sudo apt install wget make gawk gcc bc bison flex xorriso libelf-dev libssl-dev vim
3.写入脚本,然后运行脚本。
vim $HOME/build_live.sh
#!/bin/bash
wget http://kernel.org/pub/linux/kernel/v4.x/linux-4.19.12.tar.xz
wget http://busybox.net/downloads/busybox-1.29.3.tar.bz2
wget http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
mkdir isoimage
tar -xvf linux-4.19.12.tar.xz
tar -xvf busybox-1.29.3.tar.bz2
tar -xvf syslinux-6.03.tar.xz
cd busybox-1.29.3
make distclean defconfig
sed -i "s|.*CONFIG_STATIC.*|CONFIG_STATIC=y|" .config
make busybox install
cd _install
rm -f linuxrc
mkdir dev proc sys
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-4.19.12
make mrproper defconfig bzImage
cp arch/x86/boot/bzImage ../isoimage/kernel.gz
cd ../isoimage
cp ../syslinux-6.03/bios/core/isolinux.bin .
cp ../syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 .
echo 'default kernel.gz initrd=rootfs.gz' > ./isolinux.cfg
xorriso
-as mkisofs
-o ../LinG218_live.iso
-b isolinux.bin
-c boot.cat
-no-emul-boot
-boot-load-size 4
-boot-info-table
./
cd ..
4.保存退出,运行命令。
chmod 755 build_live.shbash build_live.sh
最后,在执行脚本的同一目录中发现LinG218_live.iso,具有可引导的ISO映像。
上面的shell脚本使用Linux内核4.19.12,BusyBox 1.29.3和Syslinux 6.03。源包将自动下载和编译。
这是Minimal Linux Live的第一个发布版本构建脚本。
有兴趣想做自己的Linux发行版,可以在下方留言讨论。欢迎收藏、转发、点赞、留言。