So I finally went out and got a usb pen with more than 2Gb worth of space on it, and I did this really just for one reason: I wanted to try out this thing I’d seen over at hak5 a long time ago. This thing that I wanted to try out is the ultimate hacker tool, the multipass.

It’s time to put our white hats on. Go ahead and make yourself a good cup of coffee to enjoy before reading ahead. It isn’t a very difficult process, but coffee and hacking go well together 🙂
To put it simply, the concept is that you want one usb stick with many different tools on it. Usually, if you want to put a tool like Ubuntu on a usb stick what you do is use unetbootin, or a linux tool like dd, and write the entire disk image to your stick, and that’s it, you’ve got a live usb stick, and you can use it just fine, but it’s really not that versatile, and it’s not a very efficient use of 16Gb of space. If you want to try a different system you have to start all over again, and you lose any customizations you’ve made to your live system. So, hak5 ran this episode where they showed how to get around this using GRUB, the standard linux bootloader. Now, they used legacy GRUB, which is ancient technology, so I opted to try doing it with the newer GRUB2 which is a beautiful modular replacement. Later on I found that on the hak5 forums they’ve got guides for using GRUB2, but most of it is still centered around the old GRUB. This might be because doing it with GRUB2 is really easy, especially if you’re already familiar with GRUB. So how do you do it?

I will assume from this point on that you’re working from a linux environment, but most of this can easily be done from Windows as well, just google it!

  • Format your usb stick.

Fire up your favorite partitioning tool, preferably one with support for linux filesystems, though fat32 should work as well. I recommend Gparted. You want to format your usb stick with an MBR table, and one partition formatted to ext4. For good measure you can also add boot to the partition flags. You can have another partition for storing data, but it’s not necessary, you can store that on your primary partition.

  • Install GRUB

The first thing you need to do is figure out what your disk identifier is, and mount that disk. After that you will do the actual install of GRUB. This will write to the boot sector of your usb stick and add a boot folder with modules for file systems and graphics, nifty stuff! So, here’s how you do it:

sudo fdisk -l

You’ll get some output showing information about your disks. You’ll probably have a few partitions that start with /dev/sda, and then your usb will be /dev/sdb or /dev/sdc if you have more than one usb connected. Based on the information you will be able to tell which is your multipass. The entries with numbers on the end are partitions, so you want both /dev/sdX and /dev/sdXY where X is the letter and Y is the number. Once you know that you’re ready to move on.

sudo mkdir /mnt/usb 
sudo mount /dev/sdXY /mnt/usb 
sudo grub-install /dev/sdX --root-directory=/mnt/usb 

And that’s basically it!

  • Write grub.cfg

So we’ve got GRUB installed, but we still haven’t got any operating systems on there yet, so go ahead and download your favorite tool. Just for simplicity I’m going to be using ubuntu as an example, but the options are virtually limitless. Once we have our Ubuntu.iso we’re going to make a folder on the usb stick called iso, and copy the iso file into it. Afterwards you go into /mnt/usb/boot/grub and create a new file called grub.cfg. This is where you add boot entries and a lot of other good stuff. For now I’ll show you how to do a basic boot entry, and in a later entry I’ll show you how to theme it to your liking. So about that grub.cfg file:

menuentry "Ubuntu ISO"{
	root (hda0,msdos1)
 	loopback loop /iso/Ubuntu.iso
	linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/Ubuntu.iso quiet splash
	initrd (loop)/casper/initrd.lz

And that’s all there is to it! You’re ready to boot!

The different commands here are:

root (hda0,msdos1): We’re telling grub to use the first partition on our usb. It’s hda0 now, instead of sdX.
loopback loop /iso/Ubuntu.iso: Loop is a handy tool familiar to many linux users, it mounts an image as if it were a partition.
linux (loop)/.../vmlinuz: This is the kernel line, telling grub where the linux kernel is within the mounted (loop) system. Different tools put this in different places, but for all ubuntu based live tools it’s always under casper. The stuff after vmlinuz is options passed to the kernel, and will also be different for different tools.
initrd (loop)/casper/initrd.lz: The filesystem to be loaded into RAM and passed to the kernel for startup.

The options after the linux kernel line will vary somewhat from tool to tool, but not by a whole lot. Again, the guys over at the hak5 are pretty much the authority on this stuff, so if you’re having trouble getting a specific tool to work, just head over there and someone is likely to have a working config there. If you want to add another tool to your multipass all you have to do is move the iso to your iso directory on the multipass and add a menuentry to grub.cfg. In most linux systems updating grub.cfg is done with automated tools, but for multipass you want to edit it yourself.

Fun fact, this blog was written on a lubuntu live from my multipass. I went back into my primary OS in order to grab this screenshot of my bootloader though. As you can see I’ve kinda messed up the font and hightlights, but you get the gist of what’s possible 🙂
GRUB2 in action


Song of the blog: Write in C
BRB, admin

Share Button