From 41a7b5485ffe55d402e53f61965c6edd51e40c3e Mon Sep 17 00:00:00 2001 From: superconvert <48017165+superconvert@users.noreply.github.com> Date: Mon, 25 Jul 2022 07:26:06 +0800 Subject: [PATCH] Update 03_build_disk.sh --- 03_build_disk.sh | 53 +++--------------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/03_build_disk.sh b/03_build_disk.sh index 02da7ab..d2e7593 100644 --- a/03_build_disk.sh +++ b/03_build_disk.sh @@ -48,33 +48,11 @@ mount -t ext3 ${loop_dev} ${diskfs} # 安装grub 引导 grub-install --boot-directory=${diskfs}/boot/ --target=i386-pc --modules=part_msdos disk.img -#---------------------------------------------- -# -# 下载源码 -# -#---------------------------------------------- -mkdir -pv source -cd source - -#KERNEL_SOURCE_URL=https://kernel.org/pub/linux/kernel/v4.x/linux-4.14.9.tar.xz -KERNEL_SOURCE_URL=https://mirror.bjtu.edu.cn/kernel/linux/kernel/v4.x/linux-4.14.9.tar.xz -if [ ! -f "linux-4.14.9.tar.xz" ]; then - wget $KERNEL_SOURCE_URL -fi - -BUSYBOX_SOURCE_URL=https://busybox.net/downloads/busybox-1.34.1.tar.bz2 -if [ ! -f "busybox-1.34.1.tar.bz2" ]; then - wget $BUSYBOX_SOURCE_URL -fi - -cd .. - #--------------------------------------------- # # 制作内核和 rootfs # #--------------------------------------------- -mkdir -pv work mkdir -pv rootfs mkdir -pv rootfs/dev mkdir -pv rootfs/etc @@ -88,37 +66,12 @@ mkdir -pv rootfs/root mkdir -pv rootfs/lib64 mkdir -pv rootfs/lib/modules -if [ ! -d "./work/linux-4.14.9" ]; then - tar xvf source/linux-4.14.9.tar.xz -C work/ -fi - -if [ ! -d "./work/busybox-1.34.1" ]; then - tar xvf source/busybox-1.34.1.tar.bz2 -C work/ -fi - -cd work - -# 编译内核, 最终所有模块都装到目录 /lib/modules/4.14.9 -if [ ! -f "./linux-4.14.9/arch/x86_64/boot/bzImage" ]; then - # Enable the VESA framebuffer for graphics support. - # 网络需要 TUN/TAP 驱动 [ Device Drivers ] ---> [ Network device support ] ---> [ Universal TUN/TAP device driver support ] - cd linux-4.14.9 && make x86_64_defconfig && sed -i "s/.*CONFIG_FB_VESA.*/CONFIG_FB_VESA=y/" .config && make bzImage -j8 && cd .. - #cd linux-4.14.9 && make x86_64_defconfig && make bzImage -j8 && make modules && make modules_install && cd .. -fi - # 拷贝内核镜像 -cp linux-4.14.9/arch/x86_64/boot/bzImage ../${diskfs}/boot/bzImage - -# 编译 busybox -if [ ! -d "./busybox-1.34.1/_install" ]; then - # 静态编译 sed -i "s/# CONFIG_STATIC is not set/CONFIG_STATIC=y/g" .config - cd busybox-1.34.1 && make defconfig && make -j8 && make install && cd .. -fi +cp work/linux-4.14.9/arch/x86_64/boot/bzImage ../${diskfs}/boot/bzImage # 拷贝 busybox 到 rootfs echo "${CYAN}开始制作rootfs...${NC}" -cp busybox-1.34.1/_install/* ../rootfs/ -r -cd .. +cp work/busybox-1.34.1/_install/* ../rootfs/ -r #----------------------------------------------- # @@ -279,4 +232,4 @@ echo ".........................................................." # 卸载映射 umount ${loop_dev} -losetup -d ${loop_dev} \ No newline at end of file +losetup -d ${loop_dev}