前文 脱离了广大机械硬盘和 USB 2.0 群众的实际状况,是不得人心的。下面介绍一种更加符合科学发展观的定制方法。linux
启动时,GRUB 或 extlinux 引导 /live/vmlinuz 和 /live/initrd.img, initrd.img 初始化以后会寻找 /live 目录下以 squashfs ext2 ext3 ext4 xfs jffs2 后缀的文件和以 .dir 为后缀的目录,而后将它们 union mount 成根目录。union filesystem,联合文件系统是将多个文件夹联合挂载在一个文件夹下,对联合目录的读写做用在指定为 rw 的分支目录上。bash
#initrd.img/bin/boot/9990-overlay.sh: 69 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ] 70 then 71 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir 72 do 73 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}" 74 do 75 if [ -e "${IMAGE}" ] 76 then 77 image_string="${image_string} ${IMAGE}" 78 fi 79 done 80 done 81 fi
这里使用工具 unionfs-fuse,相对于 aufs,unionfs 支持在用户层上,兼容性较好。 Debian 安装: apt-get install unionfs-fuse
,接着执行:工具
cd /tmp mkdir custom mkdir union mount /path/to/live/filesystem.squashfs /mnt unionfs-fuse -o cow,max_files=32768 -o allow_other,use_ino,suid,dev,nonempty /tmp/custom=RW:/mnt=RO /tmp/union/ #1 cd union mount -o bind /proc proc/ #2 chroot . #3
-o cow,max_files=32768 -o allow_other,use_ino,suid,dev,nonempty
是必需的,要否则文件读写方面会出问题。进去了以后,咱们就能够上下其手,随心所欲了。操做完成以后,删除 /tmp/custom 内多余的目录和文件,打包:测试
cd /tmp mksquashfs custom/ custom.squashfs cp custom.squashfs /path/to/live/
重启以后便可看到效果。ui
直接复制 Kali ISO 的内容到U盘的某一分区后,假设是 /dev/sdb2,目录名是 kaliLive,安装 extlinux.net
extlinux -i /path/to/kaliLive/
这时 /dev/sdb2 的首 512 字节是 extlinux 的 bootloader。若是你在 /dev/sdb 安装了 GRUB 2 能够以:code
set root=(hd0,msdos2) chainloader +1 boot
引导 extlinux。blog
复制+手动安装 bootloader
的方法会在 kali 1.0.1 下没法使用 persistence 功能。dd 的方法没测试过。