TinyCore是一个非常小的linux发行版,拿来做迷你工具包很合适,但是默认的iso缺少功能,例如SCSI驱动之类的功能,需要整合一下。
下载ISO
http://tinycorelinux.net/10.x/x86/release/
默认选择了x86的iso
选择一个源下载软件包
http://wiki.tinycorelinux.net/wiki:mirrors
下载scsi-4.19.10-tinycore.tcz驱动包,及bash相关包
解压ISO及内核

cp TinyCore-10.0.iso tinycore.iso
sudo rm /mnt/tmp -rf
sudo rm /tmp/boot -rf
sudo rm /tmp/cde -rf
sudo rm /tmp/extract -rf
sudo mkdir /mnt/tmp
sudo mount tinycore.iso /mnt/tmp -o loop,ro
sudo cp -r /mnt/tmp/* /tmp
sudo mv /tmp/boot/core.gz /tmp
sudo umount /mnt/tmp
mkdir /tmp/extract
cd /tmp/extract
zcat /tmp/core.gz | sudo cpio -i -H newc -d
cd /tmp

解压软件包

rm ex -rf
unsquashfs -f -d ./ex scsi-4.19.10-tinycore.tcz
unsquashfs -f -d ./ex ncursesw.tcz
unsquashfs -f -d ./ex readline.tcz
unsquashfs -f -d ./ex bash.tcz

sudo复制解压后的文件夹squashfs-root内的文件到/tmp/extract/,覆盖文件夹
非驱动包可以复制到cde\optional里自动加载(包、dep、md5),需要修改onboot.lst加载,依赖包放进去即可不需要配置。
我需要bash的命令补全,但是bash由于需要提前加载,需要整合进系统

sudo cp -r ex/* /tmp/extract/
sudo chroot /tmp/extract /sbin/depmod -a 4.19.10-tinycore
sudo chroot /tmp/extract /sbin/ldconfig
sudo sed -i 's/\/home\/tc:\/bin\/sh/\/home\/tc:\/bin\/bash/g' /tmp/extract/etc/passwd

执行chroot进行处理

sudo chroot /tmp/extract /bin/sh

手动处理bash安装命令

TCHOME=`tc`
/bin/cp -p /usr/local/share/bash/.bashrc /etc/skel/
/bin/mkdir -p /usr/local/etc
/bin/ln -s /usr/local/bin/bash /bin/bash
/bin/cp -p /usr/local/share/bash/.bashrc /root/.bashrc
/bin/cp -p /usr/local/share/bash/bashrc /usr/local/etc/
/bin/cp -p /usr/local/share/bash/.bashrc /home/"$TCHOME"/.bashrc
/bin/chown $TCHOME:staff /home/"$TCHOME"/.bashrc

退出删除命令历史记录

sudo rm /tmp/extract/root/.ash_history

然后进行打包

sudo rm /tmp/core.gz
cd /tmp/extract
sudo find | sudo cpio -o -H newc | gzip -2 > ../core.gz
cd /tmp
advdef -z4 core.gz

生成ISO

cd /tmp
sudo mv core.gz boot
mkdir newiso
sudo mv boot newiso
sudo mv cde newiso
sudo mkisofs -l -J -R -V TC-custom -no-emul-boot -boot-load-size 4 \
-boot-info-table -b boot/isolinux/isolinux.bin \
-c boot/isolinux/boot.cat -o TC-remastered.iso newiso
sudo rm -rf newiso

完成
参考:https://wiki.tinycorelinux.net/wiki:remastering