Hey all, I just wanted to share the process I went through to somehow put together a working USB that can dual boot BackTrack 5 and Ubuntu 12.04, with ubuntu being persistent as well.
This IS a manual procedure since tools like Unetbootin and the provided usb creator on ubuntu cannot dual boot systems, and they use syslinux. I used GRUB to get mine working.
I don't really know what goes on behind the scenes in GRUB, or ubuntu's boot up process. I pretty much made this by pulling info from different guides and forums on the web, including A better way to create a customized USB drive with Ubuntu Live on it (and the comments at the bottom), this thread, and this for reference.
This is what I started with:
- Ubuntu 12.04 iso
- BT5 R2 iso
- 16 GB flash drive
- GRUB2 for the booting stuff
Here's what I came up with...
Drawing from the info in the first link (which is slightly outdated but still mostly works except for an old version of GRUB), here's the general layout of my stick:
first partition:
- ~4 GB (or any size so that you have ~730 MB left afterward works),
- FAT32 (lba) (code 'c' in fdisk)
- this will become the partition with GRUB, BT5, some files needed by ubuntu to boot, and the casper-rw file that makes Ubuntu persistent
second partition:
- 730 MB
- ext4
- this will become the partition with the ubuntu cd's contents on it
You can partition/size the partitions from Gparted if you like.
In my specific case I made a third partition for storing my own files (so out of 16 GB I had 4.25 GB for first partition, 730 MB for ext4, and 10 GB for data)
MOST of the command line instructions require superuser privileges, it's easier just to execute them as root, which is what I did.
According to the first link again, I called my first partition UbuntuLive, and mounted it as USBDRIVE (in /media)
Code:
mkdir /media/USBDRIVE
mount /dev/sdc1 /media/USBDRIVE
Note that this is when my USB drive is recognized as /dev/sdc. This is what I assume it to be for the entire tutorial
Here's a very important step: install GRUB onto the first partition (remember I have it mounted as /media/USBDRIVE)
Code:
grub-install --no-floppy --root-directory=/media/USBDRIVE /dev/sdc
Next I mounted the Ubuntu ISO, copied two files (initrd.lz and vmlinuz) into the first partition.
Code:
mkdir /media/iso
mount -o loop /path/to/ubuntu/image.iso /media/iso
cp /media/iso/casper/{vmlinuz,initrd.lz} /media/USBDRIVE/boot/
umount /media/iso
Be sure to replace /path/to/ubuntu/image.iso with the location of the ubuntu iso.
Once again following the first link's instructions, I did a byte by byte copy of the ubuntu ISO to the second, ext4 partition:
Code:
sudo dd if=/path/to/ubuntu/image.iso of=/dev/sdc2
CAREFUL with the dd command! You could overwrite your whole hard drive!
I then created a folder in USBDRIVE (first partition) I called BT5, mounted the BackTrack 5 ISO, and copied all the files into the new folder:
Code:
mkdir /media/USBDRIVE/boot/BT5
mount -o loop /path/to/Backtrack/image.iso /media/iso
cp -R /media/iso/* /media/USBDRIVE/boot/BT5
umount /media/iso
Ok: so now we've got our partitions, we've got grub installed, ubuntu and BT5 files are in place. Now we just need to add persistence and edit GRUB's menu.
First Persistence:
Make a file that will be where Ubuntu saves changes etc. I made it the maximum size allowed in the first partition after BT5 and GRUB files (~2.5 GB) were in place.
Code:
dd if=/dev/zero of=/media/USBDRIVE/casper-rw bs=1M count=1500
Making it a 1.5 GB casper-rw persistence file.
Then make it the right type of file. I'm not really sure what this step does, but it seems to me like it turns the file into a sort of ext4 filesystem that is theoretically mountable (?). Just guessing.
Code:
mkfs.ext4 -F /media/USBDRIVE/casper-rw
Finally, we need to edit grub's configuration files to recognize the changes we made. Use whatever editor you want, just create a file /media/USBDRIVE/boot/grub/grub.cfg
Here's what I put in mine:
set default=0
set timeout=5
menuentry "Ubuntu Persistent 12.04" {
search --set -f /boot/vmlinuz
linux /boot/vmlinuz boot=casper file=/preseed/distro.seed quiet splash noprompt -- persistent
initrd /boot/initrd.lz
}
menuentry "BackTrack 5" {
set gfxpayload=1024x768x16
linux /boot/BT5/casper/vmlinuz boot=casper live-media-path=/boot/BT5/casper/ text splash
initrd /boot/BT5/casper/initrd.gz
}
Unmount, reboot, and hopefully everything's working!
Please check the commands I wrote up for errors before using them. I was in a bit of a rush and tired when I wrote this.
Let me know how it goes! I'll come back later to see if someone alerted me to a missing step or wrong command
Good Luck!
One last thing:
If you run our of room in the casper-rw file or something else happens, the first link (here ) has a section called "Care and Feeding of your USB drive" which has some useful bits of information.
Bookmarks