Blog

Kali Rolling on Pi 2 with external FS

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

In this guide, I'm going to walk you through the process of setting up Kali Rolling on your Raspberry Pi 2, while using an external hard drive / USB falsh drive to contain the root FS.  Why you ask... Becuase the full install of Kali is around 30GB and this means a large micro sd card is required.

If you're anything like us, you're looking to fully embrace the Pi expirience and instead of heading out and taking the easy option - a class 10 64GB micro SD, you'd much rather find another solution.  I found myself in a similar sitation while looking for to purpose my spare Pi with; I mention above it's a Pi 2 although this will work for any Pi model you own.

 

Setting up Pi

This is pretty straightforward, we simply need to get our Pi up and running with the basic distro of Kali.  Unlike the X64 images, the ARM will come as a .img file and is only the basic operating sysem - that is none of the included tools have been installed yet.  This is actually a good things as it allows us to get Kali working with our Pi while being able to configure the ideal environment before proceeding,

First, head over to https://www.offensive-security.com/kali-linux-arm-images/ and download the relevant ARM image file.  The file itself is somewhere between 1.1 and 1.5 GB so it shouldn't take too long on a fairly good connection.  It's worth taking the time here to look over any other images they provide as new ones do pop up from time to time.

Once you have this downloaded, you will need to use your tool of preference to extract the image to your microSD card.  I personally used Win32DiskImager as it's incredibly simple and I had the exe lying around in the download folder.  You can get this from https://sourceforge.net/projects/win32diskimager/ - please note I have not checked this site, eneter at your own risk!

Once the image has been extracted, time to boot up the Pi and make sure we have a desktop.  I used a USB mouse and keyboard along with a HDMI monitor for first use although we can the configure the Pi for SSH access if needed.

 

Preparing the Environment

Now we have Kali up and running, we need to prepare the environent and make a few small changes.  Before we go any further, it is always recomended to update and upgrade - open up a terminal and enter the following:

apt-get update && apt-get upgrade -y

I generally recommend this approach anyway due to scalability, but we are going to use an external USB HDD to hold our root file system instead of a USB thumb drive.  This means we can occupy as much space as we like although we do need another source of power for the drive.  Please also note, you will need to use an empty drive or one who's contents can be erased without worry.

We're going to use a script called Adafruit-pi-Externalroot-Helper; this was designed to do the entire process automatically on the Rasparian OS.  As we're using Kali which works a little different, we are going to need to make a few extra steps first (when I get time, I plan on re-writing the script a little to work correctly with Kali).

We first need to plug the HDD or USB Drive into the Pi and find out how Kali see's it.  Attach the drive, open a terminal and run the following command:

fdisk -l

You are looking for your USB drive (it may not be named so look at the file sizes to give an indication).  If you struggle to find it, remove the drive and compare the outputs of the two commands.  Once you've identified it, you need to make a note of the Device attribute (it will almost certainly be /dev/sda but good practice to check).  Now, we need to donwload the Adafruit-pi-Externalroot-Helper script:

git clone https://github.com/adafruit/Adafruit-Pi-ExternalRoot-Helper.git

Running the script is straightforward, the script will be contained in a folder called Adafruit-Pi-ExternalRoot-Helper:

./Adafruit-Pi-ExternalRoot-Helper/adafruit-pi-externalroot-helper -d /dev/sda

After a little while, it will most likely complain that /boot/cmdline.txt cannot be found.  We have simply used the script at this point to conveniently mount the HDD and sync the root file system to it on a fresh Ext4 partition.  Next, we need to tell the Pi to actually boot from this partition.  Before we go any further, you are going to need something called the PARTUUID of the drive you are wanting to use.  To find this, enter this into the terminal:

blkid

Look for the entry that contains 'LABEL="root fs"'.  At the end of this string will be the PARTUUID attribute (make sure it is PARTUUID and not UUID) which you will need to make a copy of.

Next, we need to edit the cmdline.txt file the script above could not access.  To do this, enter the following into the terminal:

mount /dev/mmcblk0p1 /boot
nano /boot/cmdline.txt

The first line tells the Pi to mound the boot partition and link that to /boot.  The second command will open the required file in the Nano editor.

Locate the section of the string that states "root=/dev/mmcblk0P2" and replace this with "root=<PARTUUID>=<your_PARTUUID_from_step_above>".  This tells the Pi that the root file system can be found on this device instead of the usual MicroSD card partition - to save and exit, press 'CTRL + O' then 'Y' then 'CTRL + X'.  Next, we need to edit /etc/fstab so enter the following into the terminal:

nano /etc/fstab

You will need to replace the "/dev/mmcblk0p2" around the third line with "PARTUUID=your_PARTUUID_from_step_above" and save & Exit.  We are finally ok to reboot the Pi - just make sure your USB drive is attached or it will not boot.

reboot

Finally, we now have the root FS running on the attached USB device which will give you far more room to play around with.  At this point, give the full Kali a try with the following command:

apt-get install kali-linux-full

 

About TSSec

We are Digger and Odskee, a small information security research team based in the UK.  We love breaking and fixing things and enjoy getting our hands dirty in the field of infoSec.

Odskee tends to focus on the theoretical, software based aspects while Digger finds himself at home with the raw electronics.  We both have a number of years of experience within a number of similar roles and think these work best as a team.

Latest News

©2018 TSSec

Search