squashfs 是一个常见于嵌入式设备的只读文件系统格式。其只读的特性,使得我在与其打交道的过程中遇到了不少麻烦(如不支持 fanotify 内核接口、直接模拟固件时不可写入)。
对 squashfs 进行操作,少不了的工具肯定是 squashfs-tools。这里是它的 GitHub 地址:https://github.com/plougher/squashfs-toolsarrow-up-right
正经人直接 make、 make install。魔道人可以在软件源里搜索安装(应该不会没有):
make
make install
▶ pacman -Ss squashfs extra/squashfuse 0.1.104-2 FUSE filesystem to mount squashfs archives community/squashfs-tools 4.4_git.1-1 [已安装] Tools for squashfs, a highly compressed read-only filesystem for Linux.
关于 squashfs-tools 的使用方式,记录在了原仓库里的 USAGE 文件中:https://github.com/plougher/squashfs-tools/blob/master/USAGEarrow-up-right
其中的主要命令行工具就是:
mksquashfs 用于打包 squashfs 格式的文件系统
unsquashfs 用于解包 squashfs 格式的文件系统镜像文件
假设要解压的文件是LJD2440-II.cramfs
将 LJD2440-II.cramfs 拷贝到任意目录下
在该目录下建立两个文件:mkdir roms mkdir tmp
mkdir roms mkdir tmp
将LJD2440-II.cramfs 挂接到 roms 目录:mount LJD2440-II.cramfs roms –o loop
mount LJD2440-II.cramfs roms –o loop
将 roms 目录下的内容压缩tar –cvf 1.tar roms这样将在 roms 的上一级目录产生一个 1.tar 的包
tar –cvf 1.tar roms
将包解压到 tmp 目录下
umount roms卸载挂载
umount roms
cd ..进入上一级目录
cd .
mv 1.tar tmp ; cd tmp ; tar –xvf 1.tar ;将打包的根文件系统里的内容解压
mv 1.tar tmp ; cd tmp ; tar –xvf 1.tar ;
rm 1.tar
挂载读取
使用 jeffersonarrow-up-right 解包
使用 jefferson 速度要远慢于直接挂载(60MB的jffs2文件直接跑炸了我的vultr皇帝机),且解出来的结果和挂载得到的结果不同,比较诡异,暂不明白原因。
最后更新于4年前
root@tater-VirtualBox:~/tmp# cat /proc/filesystems | grep jffs2 root@tater-VirtualBox:~/tmp# modprobe jffs2 root@tater-VirtualBox:~/tmp# modprobe mtdblock root@tater-VirtualBox:~/tmp# modprobe mtdram total_size=122880 root@tater-VirtualBox:~/tmp# ls /dev/mtdblock? /dev/mtdblock0 root@tater-VirtualBox:~/tmp# dd if=mtd8.bin of=/dev/mtdblock0 9984+0 records in 9984+0 records out 5111808 bytes (5.1 MB, 4.9 MiB) copied, 0.0123768 s, 413 MB/s root@tater-VirtualBox:~/tmp# mkdir mtd8_mnt root@tater-VirtualBox:~/tmp# mount -t jffs2 /dev/mtdblock0 mtd8_mnt/ root@tater-VirtualBox:~/tmp# ls mtd8_mnt/ etc www root@tater-VirtualBox:~/tmp#
jefferson filesystem.img -d outdir