本来一开始我有两个8G U盘的,想着一个用来启动,然后再安装界面装到另一个U盘里,但是读卡器坏了一个,只有转向虚拟机。这里以Kali为例子,利用虚拟机实现安装kali。注:2.0的U还是别装了,会慢得怀疑人生的 :(

需要工具:

  • Kali镜像文件 下载
  • U盘 8G+
  • 读卡器*1
  • VMware

首先配置好VMware,选择Kali镜像,移除分配的虚拟硬盘,一路顺风。开启虚拟机后,进行以下操作:[虚拟机]-[可移动设备]-找到U盘-[连接],即可把U盘接入虚拟主机,这时候电脑可能会提醒拔出U盘,不用理会。然后在虚拟机中进行照常设置,在选择硬盘的时候应该只有U盘,选择后进行分区,默认即可。

关于文件系统ext4换ext2的问题,可以在安装完系统后关闭日志,不必因为害怕ext4 / ext3日志的频繁读写对U盘换成损坏而更换ext2;且swap区一般在物理内存不够用时才会排上用场,所以在物理内存足够的情况下可以删除swap区。

最后经过漫长的等待,终于在U盘上装好了kali(自我安慰ING)还是进persistence好一点。。

附:

# 关闭EXT3/4日志功能:
[root@localhost ext4]# umount /dev/sdd1
[root@localhost ext4]# tune2fs -O ^has_journal /dev/sdd1
tune2fs 1.42 (29-Nov-2011)
[root@localhost ext4]# dumpe2fs /dev/sdd1 | grep 'Filesystem features' | grep 'has_journal'
dumpe2fs 1.42 (29-Nov-2011)

# 开启EXT日志功能:
[root@localhost ext4]# tune2fs -O has_journal /dev/sdd1
tune2fs 1.42 (29-Nov-2011)
Creating journal inode: done
[root@localhost ext4]# dumpe2fs /dev/sdd1 | grep 'Filesystem features' | grep 'has_journal'
dumpe2fs 1.42 (29-Nov-2011)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

# 动态关闭和打开日志功能后可能需要对文件系统进行fsck检查,避免出错:
[root@localhost ext4]# fsck.ext4 -f /dev/sdd1
e2fsck 1.42 (29-Nov-2011)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdd1: 11/262144 files (0.0% non-contiguous), 18510/1048233 blocks

若安装过程中提示无法分区,则用DiskGenius进行手动分区一下再连接虚拟机即可。本人亲测安装失败... 还是进persistence吧。

为U盘添加Persistence功能:

就是给U盘创建ext3分区,然后弄个persistence.conf啦。官方手册大半部分在搞ext3分区,最后一框才是重点,可以使用其他分区工具进行分区。
官方手册 (2016.2版):
First, begin by imaging the latest Kali Linux ISO (currently 2016.2) to your USB drive as described in this article. We’re going to assume that the two partitions created by the imaging are /dev/sdb1 and /dev/sdb2. This can be verified with the command "fdisk -l".

Create and format an additional partition on the USB drive.
First, let’s create the new partition in the empty space above our Kali Live partitions.

end=7gb
read start _ < <(du -bcm kali-linux-2016.2-amd64.iso | tail -1); echo $start
parted /dev/sdb mkpart primary $start $end

The parted command may advise you that it can’t use the exact start values you specified; if so, accept the suggested value instead. If advised that the partition isn’t placed at an optimal location, “ignore” it. When parted completes, the new partition should have been created at /dev/sdb3; again, this can be verified with the command "fdisk -l".

Next, create an ext3 file system in the partition and label it “persistence”.

mkfs.ext3 -L persistence /dev/sdb3
e2label /dev/sdb3 persistence

上边是分区,下边才是正题

Create a mount point, mount the new partition there, and then create the configuration file to enable persistence. Finally, unmount the partition.

mkdir -p /mnt/my_usb
mount /dev/sdb3 /mnt/my_usb
echo "/ union" > /mnt/my_usb/persistence.conf
umount /dev/sdb3

按照以上步骤进行,再重启即可,以后开机选择persistence模式即可。