Install Kali Linux live USB with persistence using macOS

Get setup using Terminal and your Kali live environment

Keith Myers
Mac O’Clock
5 min readJul 1, 2020

--

I have an interest in security. Recently I wanted to investigate the security of my home network and knew that Kali would be the best tool for this. With VirtualBox and my USB WiFi adapter, I thought I was ready to go; but alas no.

After wasting hours trying to get my Wifi adapter working, I soon realized that a live USB instance of Kali would be a lot easier to work with. I downloaded Kali Live, copied the image to my USB drive and was able to boot to Kali and access my Wifi adapter. The only issue I had was that I was unable to save any data or system changes.

After more research, I found out that I need to boot Kali in persistence mode. I then spent hours trying to get this setup on my Mac. I found countless guides to do this in Windows but no step by step instructions for those people who primarily use a Mac. If like me, you use a Mac and you want to run Kali Live either on that Mac or on another machine, here are the steps to getting Kali setup on the USB drive and getting everything configured so that persistence mode works.

Equipment

You will need:

  1. USB thumb drive of at least 16GB. I bought a 32GB Scandisk for less than $10. Here is the exact one that I used. however these are so cheap I’d recommend one of these instead

2. A Mac

3. (optional) a Second machine for using the USB Drive on and booting to Kali, but you can do this all on the same Mac

Download and validate Kali

Go to www.kali.org and download the Live USB 64bit version of Kali (or use the 32 bit if you are using an older machine)

Once you have the file, you need to verify its integrity. Run the command below in terminal and you will see the SHA once it has completed.

shasum -a 256 /Users/keith/Downloads/kali-linux-2020.2-live-amd64.iso

e90e0cfb4bc8fc640219dba66c9fe4308c9502164e432c47a30af50ce9cb3ba2 /Users/keith/Downloads/kali-linux-2020.2-live-amd64.iso

As you can see from the output, the SHA matches the one from the Kali site. You may think this step is necessary, but this is VERY good practice. If they do not match, then do not use the file.

Prepare and write the Kali image to your USB Drive

Before writing the image to the USB Drive, we need to create 2 partitions; one for the Kali OS and another for the persistence data. Insert the USB into your MAC and then run this command in terminal.

diskutil list

diskutil list

You can see that my USB drive is /dev/disk2 (yours may be different)

Now we need to create 2 partitions on to the drive. I’ve chosen 15% for the OS called KALIOS and to use the remainder for the data called KALIDATA (but you can specify to use a minimum of 4GB Partition for the OS.)

sudo diskutil partitionDisk /dev/disk2 2 GPT FAT32 KALIOS 15% FAT32 KALIDATA R

USB Drive Partitioned

The identifier in the above is the location of where we need to write the ISO image to. Before we can do that, we need to unmount the KALIOS partition. Sometimes this gives errors saying that the disk is in use, so I prefer to force the unmount.

sudo umount -f /dev/disk2s2

Now we are ready to write the image to the KALIOS partition. I’ve specified the partition identifier and the iso file from my downloads below. When this command is running, there is no feedback displayed to the screen and it may take some time to run (It took 35 minutes on my Mac). If you do want to see the status, you can hit control and T.

sudo dd if=/Users/keith/Downloads/kali-linux-2020.2-live-amd64.iso of=/dev/disk2s2

Adding persistence to Kali in Kali

You now have a USB drive that can boot Kali Live, but to allow you to save changes, we need to setup persistence. Eject and remove the USB Drive and boot to Kali on your Mac or spare machine.

When the menu is displayed, just choose Live System

Open a Terminal window and run gparted

sudo gparted

Select your USB drive and then remove the KALIDATA partition

Highlight the unallocated space and create a new partition. Label it as persistence and set the file system as ext3

Apply the changes and make a note of the persistence partition; mine is /dev/sda3 and then close out of gparted

We now need to create a mount point and mount the persistence partition using these commands in the terminal.

sudo mkdir -p /mnt/kaliusb

sudo mount /dev/sda3 /mnt/kaliusb

Now we will create a persistence.conf file and edit the file using nano.

sudo nano /mnt/kaliusb/persistence.conf

This will open Nano, where you will type / union

Then save and exit the file by typing

ctrl + x

y

Enter

Unmount the partition

sudo umount /dev/sda3

Reboot and run Kali Live with persistence

Now reboot Kali and this time select Live System Persistence

Kali Live Persistence

From now on the changes that you make in kali will be saved to the USB.

--

--

Keith Myers
Mac O’Clock

British Tech guy living in LA. Tech, Crypto and security evangelist, occasional nerd and fitness freak. I also sometimes write about tech for parents.