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:
What these do should be pretty obvious once you have entered them.
Now, lets create a new mbr table:
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:
- An Ubuntu live cd iso
- About 700MB free space on your fat partition
2.1 - The Files
Do this:
- Mount your fat partition
- Copy the iso to the root of your fat partition
- Name the iso "Ubuntu.iso"
We now have the iso copied to the fat partition. Brilliant.
2.2 - The Bootloader
Do this now:
- Mount your 4MB ext2 partition
- Check if you have write permissions for the partition. If not, run the next step as superuser
- Run "gedit" in terminal
- 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
} - Save this file as <mountpoint>/boot/grub/grub.cfg
Step 3 - USB Linux for Macs
You will need:
- Access to Mac OS 10.4.6 or later with elevated permissions
- To format your flash drive with an additional partition at the end (16MB should do)
Here are the steps to make the flash drive bootable on EFI Macs
- Download rEFIt from here. You should grab the one packaged as a gzip
- Format that third partition on your flash drive as hfs+. This can be done in disk utility by formatting it as "Mac OS Extended". You can pretty much choose any of those, but I would recommend not choosing a case sensitive file system.
- Copy the "efi" folder you just downloaded into the hfs+ partition (it's inside the refit-bin-x.xx folder you downloaded from the above link)
- Open up a terminal
- Execute the efi/refit/enable.sh file. This needs to be the one on the flash drive, not the one on the disk. What this does is blesses rEFIt so the Mac's equivalent of a BIOS can find it.
- Reboot your computer holding the option key. You should know what to do then.
Once in the rEFIt menu:
- You will need to boot linux from HD (it will have the red/orange flash drive icon)
- IMPORTANT: if you have a non-default MBR on your internal HD #1, the last step will fail. There is no way around it. The only way it will not fail is if your MBR is default of if you already have grub installed on the internal HD. For example: if you have windows installed on the internal HD and push boot from HD (flash drive), windows will boot. Yes, I know, Apple did a ****** job emulating a BIOS.
Bookmarks