Objective

Create a Kali Linux persistent USB.

Distributions

This will work from any distribution.

Requirements

A working Linux install with root privileges. You'll also need a USB drive with at least 8GB of space.

Difficulty

Easy

Conventions

  • # - requires given linux command to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - given linux command to be executed as a regular non-privileged user

Introduction

Kali Linux is an excellent distribution for penetration testing and conducting network security audits. While you can install Kali directly on your hard drive, that's not the best solution in every case. At the same time, sometimes you want to save data from your tests, and a live USB won't cut it. That's where the middle ground of a persistent USB comes in. A persistent USB is a live USB with a storage partition that lets you keep your data.

Get The Image

The first step in getting your persistent Kali USB set up is downloading a Kali live image. Thankfully, those are readily available from Offensive Security. Choose your image, and download it.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Flash The Image

Once you have your image, you can flash it to your USB drive. Before you do, clean any files that you want to save off of the drive. Everything on it will be permanently deleted. Run the following:
$ ls -lah /dev | grep -i sd
Plug the USB drive into your computer. Run ls again. The new entry is your USB drive. When you're absolutely sure that you have the right one, you can flash your image.
$ sudo dd if=kali-linux-XXXX.X-amd64.iso of=/dev/sdX bs=8M
It'll take a bit of time for the image to transfer over completely, so be patient.

Create The New Partition

You're going to need to make a partition to store your persistent information. You can create and resize your partitions however you choose, but cfdisk is probably going to be the simplest and most direct method.
Kali CFdisk Create Partition
Kali CFdisk Create Partition
Open up cfdisk on your USB with root privileges.
$ sudo cfdisk /dev/sdX
You should see free space at the end of your drive. Select that free space, and navigate to at the bottom. Select the partition size, and make it a primary partition.


Kali CFdisk New Partition
Kali CFdisk New Partition
When everything looks good, select from the menu, and type in . You can exit cfdisk by pressing the key. Next, you'll need to format your new partition. Since Kali is a Linux distribution, EXT4 works well.
$ sudo mkfs.ext4 -L persistence /dev/sdX3
It'll take a few seconds based on the size of your drive, but when you're done, you'll have a new EXT4 partition on your USB. When you open your file manager, you should see it there and ready to use.

Make It Persistent

Once you have your new partition, mount it with your file manager. Create a new file in the partition, called persistence.conf. Open up your new file, and put the following text in it to tell Kali to use the partition as persistent storage.
/ union
When you're done, save, exit, and unmount your USB.

Boot

To try out your USB drive, insert it into your computer and reboot. Select the USB drive as the boot device.
Kali Linux Install Boot Menu
Kali Linux Install Boot Menu
When Kali comes up, it'll give you a boot menu. One of the options available on that menu is . Select that one. Kali will boot up and mount your persistent partition for use.

Closing Thoughts

You now have a great way to conduct security tests from a portable Kali install without losing your files and data. You can now easily save test results and data from your work with Kali.
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions