Tuesday, November 5, 2013

Adding Persistence to Kali Linux on a USB Key

The official Kali Linux USB Live Install guide mentions how to partition your USB stick to add a persistence partition. The persistence partition is very useful because it give Kali state. The instructions are tell you how to do the procedure on a non-Kali Linux. What's the use in that.

Here's the procedure for adding persistence from within Kali Linux:

1. Figure out what the device your flash key is using. The 'df' command gave me this output:
root@kali:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
rootfs           2050320   39228   2011092   2% /
udev               10240       0     10240   0% /dev
tmpfs             410068     716    409352   1% /run
/dev/sdb1        2553376 2553376         0 100% /lib/live/mount/medium
/dev/loop0       2354304 2354304         0 100% /lib/live/mount/rootfs/filesystem.squashfs
tmpfs            2050320       0   2050320   0% /lib/live/mount/overlay
tmpfs            2050320       0   2050320   0% /lib/live/mount/overlay
aufs             2050320   39228   2011092   2% /
tmpfs               5120       0      5120   0% /run/lock
tmpfs             820120     224    819896   1% /run/shm
2. The flash device is /dev/sdb. Start gparted on /dev/sdb:
gparted /dev/sdb
 3. Your current partitioning scheme should look similar to this:



4. Proceed to format a new partition of your desired size to be used for persistence. In our example, we used all the remaining space available. Make sure the volume label of the newly created partition is persistence, and format it using the ext4 filesystem.

 
5. Once the process is complete, mount your persistence USB partition using the following commands:
mkdir /mnt/usb mount /dev/sdb2 /mnt/usb echo "/ union" >> /mnt/usb/persistence.conf umount /mnt/usb
 6. The default instructions make you add the "persistence" parameter to the kernel every time you want your persistent storage. That's cumbersome. Unfortunately we're stuck with that problem because the file that controls the bootup is on an ISO9660 filesystem, therefore it cannot be changed without re-imaging the key. Bummer.

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, select “Live boot” from the menu (don’t press enter), and press the tab button. This will allow you to edit the boot parameters. Add the word “persistence” to the end of the boot parameter line each time you want to mount your persistent storage.



Maybe I'll blog about how to fix that one day...

No comments:

Post a Comment