Flash Drive Ubuntu 9.04 on MacBook 3,1
Tuesday, 30. June 2009, 05:03:43
For the past two days I have been looking into installing Ubuntu on a USB flash drive. I also watched an absolutely awful news article last night, where they did a study where they gave one group of kids bottles of carbonated high sugar drinks and bags of lollies, and another group fresh fruit. They ate their respective piles of food, and for some reason the kids with the piles of sugar in them got hyper active and the ones eating fruit didn't. That's fine, it's what you would expect. But then they claimed that it was the colouring in the food that caused their hyperactivity. Least. Scientific. Study. Ever.
I could complain all day about that, but I'd rather write a post that would cater to more people. So this one will be about installing Ubuntu 9.04 on a Flash drive to be bootable by a MacBook 3,1 (though it may work for others too). It also requires Windows, since the technique I used was for Windows (I couldn't find anyone who had managed it and written down what they did, so I had to use Windows instructions). This will also leave the flash drive persistent, rather than a live boot which is much easier to set up. A persistent install means that when you install something, change a setting or create a file, it will remain the next time you reboot. A live install wipes each time it is booted (changes are stored in RAM).
I could complain all day about that, but I'd rather write a post that would cater to more people. So this one will be about installing Ubuntu 9.04 on a Flash drive to be bootable by a MacBook 3,1 (though it may work for others too). It also requires Windows, since the technique I used was for Windows (I couldn't find anyone who had managed it and written down what they did, so I had to use Windows instructions). This will also leave the flash drive persistent, rather than a live boot which is much easier to set up. A persistent install means that when you install something, change a setting or create a file, it will remain the next time you reboot. A live install wipes each time it is booted (changes are stored in RAM).
First of all, you should be aware that booting from a flash drive is not good for it. Flash drives are not meant for this purpose, and have only a limited number of write-erase cycles. If your data is important, install to your hard drive. If you have a spare flash drive and want to try this for the hell of it (like me), then by all means read on.
Because MacBooks do not support booting from USB natively (which I can only assume is because it's deemed bad), we need a boot CD. We will boot from this CD and then in turn this CD will boot the USB drive. Usually when triple booting a Mac, we would install a third party EFI manager like rEFIt. Because we will be booting from a CD (as far as the EFI manager is concerned) we do not need this.
The steps for the install are as follows:
1. Create boot disk
2. Unpack Ubuntu iso onto flash drive
3. Boot flash drive via boot disk
4. Make stuff work proper
Sounds easy, right? Well it shouldn't be too hard. Although it took me two days, I did a lot of trial and error to get it to work. You shouldn't have to. By the way, don't boot the Ubuntu disk, choose install and then choose your flash drive as the target disk. That destroyed my windows MBR, which I then had to fix. Bad Ubuntu.
If possible, view these instructions from another computer (I didn't, but you can).
1.1
For this, we require an Ubuntu Live CD. Download the Ubuntu iso version of your choice from Ubuntu.com (I chose 9.04, which is an iso I had lying around on my hard drive, but it is still the most recent somehow). Burn it to a disk (not the file, the image). I used the Mac OS disk utility for this.
1.2
Boot from this disk. To do this, insert the disk and hold the Option key while rebooting, just as you do to start Windows. You will be given two or three options. Mac, possibly Windows if you have it installed, and finally the CD. Choose the CD. Then choose "Try Ubuntu without making changes to my computer", aka a Live Boot.
1.3
These instructions are based on the guide at pendrivelinux.com. If my instructions don't work, try theirs.
1.3.1
Wait for Ubuntu to boot. When presented with the desktop, click Applications (top left hand corner of screen), Accessories, then Terminal.
1.3.2
Type each of these lines and press enter before moving onto the next.
mkdir -p ubcd/boot/grub
cp /usr/lib/grub/i386-pc/stage2_eltorito ubcd/boot/grub
gedit ubcd/boot/grub/menu.lst
1.3.3
Now a window will open with a blank text document. Add this to it, then save and close:
title Run Ubuntu 9.04 from USB DISK
root (cd)
kernel /boot/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper noprompt cdrom-detect/try-usb=true persistent
initrd /boot/initrd.gz
boot
1.3.4
Type each of these lines, and press enter before moving onto the next:
cp /cdrom/casper/initrd.gz ~/ubcd/boot
cp /cdrom/casper/vmlinuz ~/ubcd/boot
sudo gedit /etc/initramfs-tools/modules
1.3.5
Another text document will open. Add this to it, save and close:
usbcore
usb-storage
uhci_hcd
ohci_hcd
ehci_hcd
sd_mod
scsi_mod
1.3.6
Type into terminal:
sudo gedit /etc/initramfs-tools/initramfs.conf
Add the following line to the bottom of the file and click save:
WAIT=8
1.3.7
Type into terminal:
sudo mkinitramfs -o ubcd/boot/initrd.gz 2.6.2*
Replacing 2.6.2* with your actual kernel version.
Type uname -r to find your kernel version. I.E. initrd.gz 2.6.28-11-generic
For example, sudo mkinitramfs -o ubcd/boot/initrd.gz 2.6.2.28-11-generic
1.3.8
Type into terminal:
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o usbcd.iso ubcd
1.4
That last command creates an iso file in the home folder, click the Places menu at the top of the screen, then Home Folder.
1.5
Burn this file to disk. I stuck it on my flash drive, rebooted to Mac OS X and used disk utility (because I'm pretty new to Linux so don't know how to do it from there).
You now have a boot disk
Next step, set up the flash drive. For this step you need Windows
Instructions based on another pendrivelinux.com article.
2.1
Download and launch u904p.exe (hotlinked, in fear of breaking a don't distribute clause in an unfound licence) or my mirror at this place (mirrored, in fear of do not hotlink clause in a license I couldn't find), extracting to your PC. A U904p folder is automatically created.
2.2
In this new folder, place the iso image of the Ubuntu version you downloaded.
2.3
A casper-rw file is used to store your changes. In can be found in your U904p folder. The default is only 1GB, if you require more, you need to switch out this file with a larger one. Some prebuilt ones are available near the bottom of this article. The largest is just 4GB, so I have chosen to use this one on my 8GB flash drive.
2.4
In the U904p folder, there will be a batch file called U904.bat (or just U904 if extensions are hidden). Double click it. Follow the on screen instructions. Once started, this could take 5-10 minutes. If you are using Windows Vista or Seven, be sure to read the instructions at the end to make your flash drive bootable.
3.1
Time to boot from the flash drive! Put your boot CD in the drive, make sure your flash drive is inserted, and reboot while holding Option.
3.2
Select your boot CD, then you will be given a selection screen. It only has one option, so hit enter. This will boot from your flash drive! If you are used to Mac OS or Seven, this may take a while to start up. If you are used to Vista, then it will probably take a normal amount of time to start up.
4.1
Most things should work straight away. Dispite what you may think, multifinger use of the touch pad is enabled. It's just different from Mac OS/Windows. One finger is left click, two is middle click, and three is right click. But if, like me, you hate that (although it does make more sense than 1=left, 2=right and 3=middle), then we can fix it. While we are there, we will fix the wireless probem, should you encounter the same one I did:
sudo gedit /usr/local/bin/fix_script
Then in the document that pops up:
#!/bin/sh
#This one for the mouse
xmodmap -e "pointer = 1 3 2"
#These two for the wireless. Leave out if you don't have a problem.
sudo rmmod wl ssb
sudo modprobe wl
Then in terminal:
sudo chmod a+x /usr/local/bin/keyboard
That makes the file executable. Now click system → preferences → startup applications. Click Add, enter a name, and then click browse. Navigate to /usr/local/bin/ and choose keyboard.
Now on restart the wireless should work, and two fingers should perform a right click (with three being a middle click).
4.2
If you are an Opera user, a sideways two finger scroll will make you go back/forward a page. It's far too sensitive for my liking, so I disabled it. To do this, first run this command in terminal:
sudo gedit /usr/share/opera/ui/standard_mouse.ini
Then when the file opens, scroll down to where it has Button6 and Button7 listed on the left hand side. Place a ; on the left to comment out those lines, ie:
;Button6 = back
;Button7 = forward
This assumes you have already downloaded and installed Opera.
4.3
Depending on your version of Ubuntu, desktop effect may have already been enabled. If not, to enable them, right click on the desktop and select Change Desktop Background. Then choose the desktop effects tab. Choose a setting other than None. If it fails, you may need to update your drivers (this fixed it for me). Click System → Administration → Update manager, and download and install your updates. Desktop effects should now work.
Hopefully you have most things working. If you don't, check out https://help.ubuntu.com/community/MacBook3-1/Jaunty. That should help you with any problem you have. Good luck
Longest. Post. Ever.


Anonymous # 19. September 2009, 11:42
Genial tutorial!, pero al hacer el mkisofs -R -b ... me da un error "geniso: Missing pathspec" se te ocurre como solucionarlo¿?
Dangerous Dave # 19. September 2009, 12:13
Anonymous # 29. November 2009, 20:31
Thank you SO MUCH for the part about opera! I was at the point of uninstalling it, losing my place every time I tried to scroll was driving me insane. They need to make it possible to switch off graphically, that's just bad forethought. Thank you so much!
Anonymous # 23. December 2009, 22:55
i cant find stage2_eltorito, it seem that doesnt exist ?