BT5 USB flash drive persistent install

Sony 16GB flashThanks to the computer systems security class I am taking for my masters program, I’ve been messing around with Linux for about a month now trying out different distros and figuring out the tools in Backtrack. BT is really useful but it’s annoying to always have to start from scratch with the live image, especially if you need drivers that aren’t included on the iso. A persistent installation is the way to go but I couldn’t get any of the methods I found on the web to work. I figured out an easy way that worked for me so I thought I would post it.

First download the BT5 iso. Then install UNetbootin if your system doesn’t already have it:

sudo apt-get install unetbootin

You will also need a big USB flash drive, I used a 16GB.The first part of these instructions comes from the persistent USB wiki, and the rest I figured out myself. When I followed the directions in the wiki, the PC would wipe sdb1 for some reason and fail to boot. I used UNetbootin to get things working.

Now to format the drive. Plug in the flash drive and use the fdisk command to list the flash drive:

sudo fdisk -l

It will probably show up as /dev/sdb. Make note of how many partitions there are, because you will need to delete them in a minute. Obviously, you will also loose the existing data on the drive. Start the partitioning process on the drive by typing

sudo fdisk /dev/sdb

This starts fdisk on the flash drive. Delete any partitions on the drive by typing ‘d’ and then the partition number until there are no partitions. Now create a new partition by typing ‘n’, then ‘p’ for a primary partition, then type ‘1’ to create partition 1. Select the default start sector, and then ‘+2500M’ for the last sector.

(UPDATE: For BT5 R2 use +3000M. It got bigger.)

sudo fdisk /dev/sdb

Command (m for help): d
Selected partition 1

 

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-15523839, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15523839, default 15523839): +2500M

Now change the system ID for the new partition:

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Make it bootable:

Command (m for help): a
Partition number (1-4): 1

Create the second partition, use the default values for sectors so that the second partition fills the rest of the drive:

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4, default 2):
Using default value 2
First sector (5122048-15523839, default 5122048):
Using default value 5122048
Last sector, +sectors or +size{K,M,G} (5122048-15523839, default 15523839):
Using default value 15523839

Now change partition 2’s system ID to linux:

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 83

Finally write the changes to disk with the ‘w’ command.

Command (m for help): w
The partition table has been altered!

Now to format the partitions.

sudo mkfs.vfat -F 32 -n BT5 /dev/sdb1

 

sudo mkfs.ext3 -b 4096 -L casper-rw /dev/sdb2

Once formatting is complete, you will need to mount the drive. Either unplug/plug the drive and click on it in the file explorer, or type:

mkdir /mnt/sdb1

 

mount /dev/sdb1

Now start UNetbootin and point the Diskimage box to the location of the iso on your computer. At the bottom select USB Drive and /dev/sdb1 from the dropdown box. Click OK and wait for the files to be copied.

Once that is done, use the following commands to edit the startup config file. First navigate into sdb1, depending on where it is mounted on your system (use ‘mount’ to find out). Then start the editor.

cd /mnt/sdb1

 

nano syslinux.cfg

Edit the default option to be persistent. Here is what my text file looks like after I edited it to reflect the persistent option:

default menu.c32
prompt 0
menu title UNetbootin
timeout 100

label unetbootindefault
menu label Default - Persistent
kernel /ubnkern
append initrd=/ubninit file=/cdrom/preseed/custom.seed boot=casper persistent text splash vga=791--

label ubnentry0
menu label BackTrack Text – Default Boot Text Mode
kernel /casper/vmlinuz
append initrd=/casper/initrd.gz file=/cdrom/preseed/custom.seed boot=casper text splash vga=791–

label ubnentry1
menu label BackTrack Stealth – No Networking enabled
kernel /casper/vmlinuz
append initrd=/casper/initrds.gz file=/cdrom/preseed/custom.seed boot=casper  text splash staticip vga=791–

label ubnentry2
menu label BackTrack Forensics – No Drive or Swap Mount
kernel /casper/vmlinuz
append initrd=/casper/initrdf.gz file=/cdrom/preseed/custom.seed boot=casper  text splash vga=791–

label ubnentry3
menu label BackTrack noDRM – No DRM Drivers
kernel /casper/vmlinuz
append initrd=/casper/initrd.gz file=/cdrom/preseed/custom.seed boot=casper  text splash nomodeset vga=791–

label ubnentry4
menu label BackTrack Debug – Safe Mode
kernel /casper/vmlinuz
append initrd=/casper/initrd.gz file=/cdrom/preseed/custom.seed boot=casper  text–

label ubnentry5
menu label BackTrack Memtest – Run memtest
kernel /isolinux/memtest
append initrd=/ubninit –

 

label ubnentry6
menu label Hard Drive Boot - boot the first hard disk
kernel /ubnkern
append initrd=/ubninit -

When you are done editing the file save it. At this point, you can unmount your drive and boot it. Select persistent at the boot menu, and once BT has loaded, change some things and restart. If it worked, the changes will be saved. The casper-rw partition holds all of your data when using the flash drive, so BT is essentially now “installed” there.

Tags: ,

Thursday, March 1st, 2012 Uncategorized

Leave a Reply