diff --git a/02_build_img.sh b/02_build_img.sh index 2b87c58..146f690 100755 --- a/02_build_img.sh +++ b/02_build_img.sh @@ -23,7 +23,7 @@ with_gcc=$1 # 进行目录瘦身 # #---------------------------------------------- -#./mk_strip.sh +./mk_strip.sh #---------------------------------------------- # @@ -33,9 +33,9 @@ with_gcc=$1 echo "${CYAN}--- build disk --- ${NC}" # 创建磁盘 64M if [ ! -n "${with_gcc}" ]; then - dd if=/dev/zero of=disk.img bs=1M count=256 + dd if=/dev/zero of=disk.img bs=1M count=128 else - dd if=/dev/zero of=disk.img bs=1M count=512 + dd if=/dev/zero of=disk.img bs=1M count=256 fi # 对磁盘进行分区一个主分区 fdisk disk.img << EOF @@ -86,16 +86,17 @@ cp work/kernel_install/bzImage ${diskfs}/boot/bzImage # 拷贝 glibc 到 rootfs cp work/glibc_install/* rootfs/ -r -rm -rf rootfs/lib/*.a -rm -rf rootfs/share rm -rf rootfs/var/db +rm -rf rootfs/share +rm -rf rootfs/usr/share +find rootfs/ -name "*.a" -exec rm -rf {} \; # 编译的镜像带有 gcc 编译器 if [ ! -n "${with_gcc}" ]; then echo "without-gcc tools." #rm -rf rootfs/include else echo "${RED} with-gcc tools --- you can build your world${NC}" - #cp work/glibc_install/lib/libc_nonshared.a rootfs/lib + cp work/glibc_install/usr/lib64/libc_nonshared.a rootfs/usr/lib64 fi #---------------------------------------------------------------------- @@ -194,9 +195,9 @@ cp rootfs/* ${diskfs} -r if [ "${with_gcc}" ]; then echo "${RED} with-gcc tools --- you can build your world${NC}" cp work/libgcc_install/* ${diskfs} -r - cp work/binutils_install/* ${diskfs} -r + cp work/binutils_install/usr/x86_64-pc-linux-gnu/* ${diskfs} -r fi -rm -rf ${diskfs}/init ${diskfs}/linuxrc ${diskfs}/lost+found +rm -rf ${diskfs}/init ${diskfs}/lost+found # 我们测试驱动, 制作的镜像启动后,我们进入此目录 insmod hello_world.ko 即可 ./mk_drv.sh $(pwd)/${diskfs}/lib/modules diff --git a/cat_img.sh b/cat_img.sh index 158ac31..2a31c8d 100755 --- a/cat_img.sh +++ b/cat_img.sh @@ -8,6 +8,8 @@ mkdir -p ./mnt1 mount -t ext3 ${loop_dev} ./mnt1 echo "/ ---------------------------------------" du ./mnt1 -h +echo "lib -------------------------------------" +find ./mnt1 -name "*.a" -exec du -h {} \; umount ./mnt1 rm -rf mnt1 losetup -d ${loop_dev} diff --git a/mk_strip.sh b/mk_strip.sh index 7f67cd1..8d2b68e 100755 --- a/mk_strip.sh +++ b/mk_strip.sh @@ -24,18 +24,18 @@ strip_dir() { } # strip glibc -rm -rf work/glibc_install/share +rm -rf work/glibc_install/usr/share strip_dir work/glibc_install # strip busybox +rm -rf work/busybox_install/linuxrc strip work/busybox_install/bin/busybox # strip gcc -rm -rf work/libgcc_install/share +#rm -rf work/libgcc_install/usr/share strip_dir work/libgcc_install # strip binutils -rm -rf work/binutils_install/share -rm -rf work/binutils_install/x86_64-pc-linux-gnu +#rm -rf work/binutils_install/usr/share strip_dir work/binutils_install