前言
iKuai 系统镜像解包,下载地址:https://www.ikuai8.com/component/download
下载依赖
apt install p7zip-full
apt install binwalk
apt install qemu-utils
解压 iso 文件
7z x iKuai8_x64_3.7.1_Build202304060952.iso -oiKuai
cp iKuai/boot/rootfs ./
分析 rootfs 文件
binwalk rootfs
输出结果:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
24917484 0x17C35EC QEMU QCOW Image
34312044 0x20B8F6C gzip compressed data, from Unix, last modified: 2023-04-06 01:53:28
分割数据
binwalk -e -C . rootfs
- 得到
_rootfs.extracted/20B8F6C文件和_rootfs.extracted/20B8F6C.gz文件
解包头部
把头部转 raw
qemu-img convert -O raw _rootfs.extracted/20B8F6C rootfs_head.raw
查看 raw 文件类型
file -s rootfs_head.raw
rootfs_head.raw: POSIX tar archive (GNU)
解包归档文件
mkdir -p /mnt/rootfs_head
tar -xf rootfs_head.raw -C /mnt/rootfs_head
得到的是启动介质根目录
tree /mnt/rootfs_head
输出结果:
/mnt/rootfs_head
└── root.grub
├── boot
│ ├── grub
│ │ ├── grub.cfg
│ │ ├── grub-disk.cfg
│ │ ├── grub-disk.img
│ │ ├── grub-efi.img
│ │ ├── grub-gpt-boot.img
│ │ ├── grub-gpt-core.img
│ │ ├── grub-iso.img
│ │ ├── i386-pc
│ │ │ ├── loopback.mod
│ │ │ └── probe.mod
│ │ └── x86_64-efi
│ │ ├── loopback.mod
│ │ └── probe.mod
│ └── vmlinuz
└── EFI
└── BOOT
├── BOOTX64.EFI
└── grub.cfg
解包尾部
把尾部转 raw
qemu-img convert -O raw _rootfs.extracted/20B8F6C.gz rootfs_tail.raw
查看 raw 文件类型
file -s rootfs_tail.raw
rootfs_tail.raw: gzip compressed data, last modified: Thu Apr 6 01:53:28 2023, from Unix, original size modulo 2^32 0
解包归档文件
mkdir -p /mnt/rootfs_tail
tar -xf rootfs_tail.raw -C /mnt/rootfs_tail
得到的还是启动介质根目录
tree /mnt/rootfs_tail
输出内容:
/mnt/rootfs_tail
└── root.grub
├── boot
│ ├── grub
│ │ ├── grub.cfg
│ │ ├── grub-disk.cfg
│ │ ├── grub-disk.img
│ │ ├── grub-efi.img
│ │ ├── grub-gpt-boot.img
│ │ ├── grub-gpt-core.img
│ │ ├── grub-iso.img
│ │ ├── i386-pc
│ │ │ ├── loopback.mod
│ │ │ └── probe.mod
│ │ └── x86_64-efi
│ │ ├── loopback.mod
│ │ └── probe.mod
│ └── vmlinuz
└── EFI
└── BOOT
├── BOOTX64.EFI
└── grub.cfg
重新解包头部
分割头部数据
dd if=rootfs of=qcow2.bin bs=1 skip=24917484 count=$((34312044-24917484))
查看文件类型
file qcow2.bin
输出内容:
qcow2.bin: QEMU QCOW2 Image
把头部转为 raw
qemu-img convert -O raw qcow2.bin qcow.raw
修改文件内容
卸载
umount /mnt/r
losetup -d /dev/loopN
合并新 rootfs 文件
提取原 rootfs 头部
dd if=rootfs bs=1 count=24917484 of=rootfs.head
压缩新 QCOW2 文件
qemu-img convert -O qcow2 -c rootfs.raw rootfs.qcow2.new
合并新 rootfs 文件
cat rootfs.head rootfs.qcow2.new > rootfs.mod
重新打包 iso 文件
替换新 roofs 文件
cp rootfs.mod ikuai/boot/rootfs
重新打包 iso 文件
7z a iKuai8.iso iKuai
完成