Kali Linux Live USB Persistence
Adding Persistence to a Kali Live USB
As of Kali Linux 1.0.7, USB persistent options have been added to the default boot menu. These options require additional setup on your USB storage to function properly and are described in the following article.
Adding persistence (the ability to save files and changes across live boots) to your Kali Linux image can be very useful in certain situations. To make your Kali Linux USB stick persistent, follow these steps as the root user. In this example, we assume our USB drive is /dev/sdb and that we’ve downloaded kali-linux-1.0.7-amd64.iso. Make sure you’re using a large enough USB stick (at least 8GB).
Image the Kali Linux ISO to your USB stick. We used the “Linux Method” and dd.
dd if=kali-linux-1.0.7-amd64.iso of=/dev/sdb bs=1MCreate and format an additional partition on the USB stick. In our example, we create a 5 GB persistent partition and create a persistence.conf file on it.
size=5gb
read bytes _ < <(du -bcm kali-linux-1.0.7-amd64.iso |tail -1); echo $bytes
parted /dev/sdb mkpart primary $bytes $size
mkfs.ext3 -L persistence /dev/sdb2
e2label /dev/sdb2 persistence
mkdir -p /mnt/my_usb
mount /dev/sdb2 /mnt/my_usb
echo "/ union" > /mnt/my_usb/persistence.conf
umount /dev/sdb2
Adding USB Persistence with LUKS Encryption
As of Kali Linux 1.0.7, there is also the option of using a LUKS encrypted persistent storage space. This adds an extra layer of security to your sensitive files when traveling with Kali on USB devices.
Image the Kali Linux ISO to your USB stick. We used the “Linux Method” and dd.
dd if=kali-linux-1.0.7-amd64.iso of=/dev/sdb bs=1MCreate and format an additional LUKS encrypted partition on the USB stick. In our example, we create a 5 GB persistent partition and create a persistence.conf file on it.
size=5gb
read bytes _ < <(du -bcm kali-linux-1.0.7-amd64.iso |tail -1); echo $bytes
parted /dev/sdb mkpart primary $bytes $size
cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb2
cryptsetup luksOpen /dev/sdb2 my_usb
mkfs.ext3 -L persistence /dev/mapper/my_usb
e2label /dev/mapper/my_usb persistence
mkdir -p /mnt/my_usb
mount /dev/mapper/my_usb /mnt/my_usb
echo "/ union" > /mnt/my_usb/persistence.conf
umount /dev/mapper/my_usb
cryptsetup luksClose /dev/mapper/my_usb
That’s it! Plug the USB stick into the computer you want to boot up. Make sure your BIOS is set to boot from your USB device. When the Kali Linux boot screen is displayed, you can now choose the persistent option (either normal or encrypted, whichever you set up).