bootable usb disk for Mac and PC

Nobody say this isn't possible because I will shoot you. After writing two somewhat-wrong guides, I have finally corrected my process. In this post is the instructions to create a linux USB drive and boot Ubuntu from it (and also refit on macs).

Step 1 - USB Linux
This is the step where we make a usb drive that we can run linux off of. In order to boot your usb drive, your pc bios must support it. Mac's bios (not the efi) doesn't support this, however mac users can use refit, which is discussed later.

Get yourself some of these:

  1. A USB key (at least 1GB if you want to run Ubuntu)
  2. Fdisk (this comes with ubuntu, but not debian)
  3. grub-pc (this is also a default ubuntu package)
  4. The tools necessary to create fat filesystems (this comes with ubuntu but not debian)

1.1 - Formatting

This will delete all your USB data.

 

Firstly, unmount all partitions on your USB drive.

 

Open your terminal and:

Code:
sudo -s
fdisk <usb name>

Now you will be at the fdisk prompt, about to edit the partition map on your usb drive. Now enter these commands:

Code:
c
u

What these do should be pretty obvious once you have entered them.

 

Now, lets create a new mbr table:

Code:
o

Next, let's make some partitions. 4MB for grub and the rest for ubuntu and other things:

Code:
n
p
1
<enter>
+4M
n
p
2
<enter>
<enter>
w

Now we need to create the filesystems. Open up your favorite disk manager and format the 4MB partition as ext2 and the other one as fat32. Then mount them both.

1.2 - Linux on USB

Note: Grub may not run correctly when used with computers with grub installed on the internal hard drive, especially mac computers.

 

Now we need to install grub onto the usb drive. Use this command:

Code:
cd <mountpoint>
sudo grub-install --root-directory=. <usb device, mine is /dev/sdc>

Now open up that disk manager again and set the bootable flag on the 4MB partition.

Step 2 - Ubuntu on your USB Drive

Now we will add ubuntu to your flash drive. This will allow you to boot into ubuntu live from your flash drive. Grab the following:

 

  1. An Ubuntu live cd iso
  2. About 700MB free space on your fat partition

2.1 - The Files

Do this:

 

  1. Mount your fat partition
  2. Copy the iso to the root of your fat partition
  3. Name the iso "Ubuntu.iso"

We now have the iso copied to the fat partition. Brilliant.

2.2 - The Bootloader

Do this now:

 

  1. Mount your 4MB ext2 partition
  2. Check if you have write permissions for the partition. If not, run the next step as superuser
  3. Run "gedit" in terminal
  4. Enter the following:
    menuentry "Ubuntu Live from ISO" {
    insmod fat
    search.file /Ubuntu.iso root
    loopback loop /Ubuntu.iso
    linux /casper/vmlinuz boot=casper iso-scan/filename=/Ubuntu.iso
    initrd /casper/initrd.lz
    }
  5. Save this file as <mountpoint>/boot/grub/grub.cfg

Coming soon - refit for efi machines (macs)

Link:
http://ubuntuforums.org/showthread.php?t=1683062

© 2002-2012 Jeroen Diederen. Drupal theme by Kiwi Themes.