Boot Linux from a USB flash drive on a Macbook

In order to install Linux on the replacement of a crashed hard-disc drive in a 2006 Macbook Core duo, I wanted to boot Linux from a USB flash drive in order to then install it. While this is trivial on most PCs, it turned out not to be on an old Macbook.

The problem

The white Core duo (without the 2) 32-bit Macbook was purchased in September 2006 and used to dual boot Gentoo Linux and Mac OSX using rEFIt. The original 100Mb hard disc was failing and I bought a 500Mb drive to replace it. Since OSX hadn’t been booted for some years, I decided to install Linux only. It turned out that booting Linux from a USB flash drive / USB pen drive / USB stick (or CD for that matter) is nearly impossible without rEFIt or its modern clone, rEFInd. Google found solutions that may work for more modern Macbooks (pro), but not for this machine. In addition, the original installation CD did not recognise the 500Mb disc (but reported it was 3.0Tb) and Disk Utility (luckily) refused to do anything. Hence, I needed a USB flash drive that booted on my Macbook without rEFIt/rEFInd, and I needed to prepare it on another Linux machine.

The reason?

The main reason for the problem is that while booting on UEFI (as opposed to BIOS) systems is well supported by Linux, Apple seems to be using their own, unique mix of features from different versions. As an aside, it is interesting to wonder why Apple would make it hard for their customers to install whatever operating system they wish on the hardware they purchased and hence own. The first reason that springs to my biased mind is that Apple stuff is shit and forbidding people to compare it with superior alternatives is a good way of keeping your iSheep uninformed, meek and obediently buying. Why did I get a Macbook in the first place? Because for my new job (back then), I could choose between a Mac and a Mac. Since I needed to work on it efficiently, and not stare at its shineniness, I gave up on the OS after a few months (it was harder to do that with the hardware) and installed Linux as a dual boot. Since I never want to boot MacOS again, I want to use this opportunity to turn the Macbook into a Linux-only machine (and change Linux flavours).

The solution!

The solution I found uses the ISO 2 USB EFI Booter for Mac (with unclear origin) to boot from the ISO image of a LiveCD, but with some small but important changes: use a FAT32 file system, place the EFI file in /efi/boot/ and rename it to boot.efi. The minimal working solution for me was:

Download

  • Download ISO 2 USB EFI Booter for Mac, and unzip the archive. You’ll find two (useful) files: bootIA32.efi and bootX64.efi. You’ll need only one of these, since your system is either 32 or 64 bit.
  • Download the ISO image of a Linux LiveCD or LiveDVD. The ISO image must have “support for loopback” in order to work. I succesfully booted from the Kubuntu 13.10 desktop ISO and Ubuntu 12.04 LTS desktop ISO. The latter is a 30% smaller download; later versions of Ubuntu allegedly don’t have loopback support. Linux Mint is said to work as well, but I didn’t try this. None of the Gentoo or Arch Linux ISOs I tried worked.

Installation

  • Ensure the ISO file will fit on your USB flash drive. Backup important content from your drive — it will be erased.
  • Make one large partition on your USB flash drive, using e.g. (g)parted, (c)gdisk, or (c)fdisk. You can use either a GUID partition table (GPT — unless you’re using (c)fdisk) or an MSDOS/MBR partition table, both will work. Use “Microsoft basic data” (code 0700) as the partition type.
  • Format the partition with FAT32. (g)parted can do this. Alternatively, you can type mkfs.vfat -F 32 /dev/sdX1 from the command line (after replacing the “X” with the correct letter for your USB drive). Formatting with HFS+, as some sources indicate, didn’t work for me.
  • Mount your drive and cd into it (as root: # mkdir /mnt/usb && mount /dev/sdX1 /mnt/usb && cd /mnt/usb).
  • Create the directory efi/boot/ in the current directory (# mkdir -p efi/boot/) — (i.e., the full path of this directory is /mnt/usb/efi/boot/ if your USB drive is mounted in /mnt/usb/).
  • Copy either bootIA32.efi or bootX64.efi to the new directory (depending on whether you have a 32 or 64-bit system), and rename the file to boot.efi.
  • Copy the downloaded LiveCD image to the new directory, and rename it to boot.iso.
  • That’s all. The USB drive now contains two directories and two files, and should boot. Make sure you used the file and directory names as provided here. For clarity, all that is now on your USB drive is (relative to the root directory of that drive):
    1. /efi/boot/boot.iso
    2. /efi/boot/boot.efi

In order to install Linux, I booted Kubuntu using the method described above, installed rEFInd from there, which then allowed me to boot from a normal Live USB flash drive. I ended up installing Arch Linux. The details and non-trivialities of the Linux installation will be described in a future post. I didn’t manage to install Linux without installing rEFInd though, so in retrospect I might as well have installed rEFInd on my new disc, mounted as an external disc to my other Linux computer.

Advertisement
This entry was posted in All, Software and tagged , , , , , . Bookmark the permalink.

52 Responses to Boot Linux from a USB flash drive on a Macbook

  1. Pingback: Linux-only installation on a 2006 Macbook using rEFInd | AstroFloyd's blog

  2. Aario says:

    Thanks. But this and all other solutions only work with ubuntu based distro’s. Any idea for non-ubuntu ones?

    • AstroFloyd says:

      As I explain in the last paragraph, I only used (K)Ubuntu to install rEFInd. After that, you can boot from any USB drive. I installed Arch Linux in this case.

  3. Thomas says:

    Did you end up installing Arch Linux to another partition on your thumb drive or the internal hard drive? That’s the route I’m attempting to go (thumb drive). I would like to have a self-contained linux installation (actually a couple) with a boot loader menu (like GRUB), but I find myself stitching together several tutorials with no success. Basically create a livecd-like installation with persistent storage so I can move between systems easily (like a VM, but native).

    So far based on my experience with MicroZed, I should create a partition table like:
    [4 MB empty]
    [?? MB Fat32 for boot/efi, etc. recovery/install partition]
    [ ?? GB Ext4 Linux Distro 1 root]
    [ ?? GB Ext4 Linux Distro 2 root]
    [ ?? GB Extra shared space, EXT4, HFS+, etc. who cares]

    • AstroFloyd says:

      The goal of this exercise for me was to install Arch Linux on the internal hard disc, not to create a permanent USB thumb drive. So after installing rEFInd, I wiped the thumb drive and created an Arch live system for installation. No multi-flavour thumb drives here.

  4. Anthony says:

    wait wait…
    just to clarify: do I make the folders like
    efi > boot > (boot.efi , boot.iso)
    so that everything’s in boot?
    or efi in efi and boot in boot?

  5. Pingback: Linux Boot Stick für das Macbook

  6. davep says:

    Hey I did this. It works great! Alot easier then described. Forget all this refit and refind stuff. I downloaded iso and burned dvd on another pc. Installed new ssd in mac, loaded the burned dvd, let mint do the install. Easy. Boots in seconds, runs fast. Used Mint 17 xfc 32 bit version.

    Earlier, I tried Mint 17.1 Mate installed along side OS 10.6. Works great too. Don’t follow youtube video, it doesn’t work. Use disk utility in mac os, shrink install to leave blank space for mint. DO NOT FORMAT BLANK SPACE! Mint will find it and do its install. Easy again. Installed Cairo Dock, looks better than Mac OS. Used refit in this install to boot either Mint or OS. The efi in this mac is different then other Macs’,refind will not work on hard drive or usb. Good luck.

    • AstroFloyd says:

      The point of this post is that this doesn’t work for all Macbook models. Which model did you use here?

      • nitrofurano says:

        didn’t work for me, it’s a Macbook 2,1 (bought in february ’07, came with osx .4.x “tiger” ) – i don’t know if it’s a firmware issue – i’m a bit concerned about this because the internal cd driver is damaged for years, and this might difficult when i might need to replace the hard disk or doing some fresh-install on some operating systems and distros – (anyway, rEFInd is really awesome, far better than rEFIt, i lost grub, and rEFInd found all distros and kernels i had installed! 🙂 )

  7. It didn’t worked to me. FAT32 created by Disk Utility.app and OSX Yosemite in a MacbookAir5,2. Tried both efi files (32 and 64 bits) neither worked.

  8. ankushnarula says:

    I am also having a problem. Here’s what I did:

    On a 64GB USB3 Flash Drive I created the following partitions (0) Yosemite Installer (1) rEFIt (2) blank 5GB fat32 (3) blank 5GB fat32 partition. I followed the above instructions to populate partitions 2 and 3 with Ubuntu desktop and server (amd6+mac versions). When I boot to rEFIt via the EFI boot menu, I see both partitions 2 and 3. However, when I select either of them it takes me to the GRUB prompt and I sit there like an idiot. My hope was that it would just run the standard setup for either Ubuntu edition. Any hints? Thanks

    • ankushnarula says:

      I figured it out I think. The Ubuntu partitions 2 and 3 want to be partitions 0 and 1. I reconfigured my USB Flash Drive and repeated the above process. Looks like it’s working! Thanks @AstroFloyd!

  9. hpjohn says:

    This worked great and saved me taking the drive out for a reinstall! I used OSX Disk Utility to partition and format the USB drive, with GPT partition type. Thanks for the write up. 🙂

  10. Ade says:

    Thanks for the great tutorial! Everything I tried before was more shooting in the dark.

    That said – doesn’t work for me (yet). I am trying to install Linux Mint 17 (64 bit) on a 2006 Macbook White (“2 GHz Intel Core 2 Duo”, so it should be the 64 bit-system). Atm, Snow Leopard is installed on one partition, and I would like to keep it that way; but depending on how desperate I become, will not insist on it.

    When choosing where to boot from, it won’t show the USB stick. Any ideas where the problem could be?
    Thanks a lot.

    • AstroFloyd says:

      Did you try to install rEFInd on MacOS? In my case (back in 2006, when MacOS was still installed) it helped recognise the Live CD I used back then to install a dual-boot system. This would be my first shot if OSX is still running.

      The other aspects that may be important are the bootable flag for the boot partition, whether you use an MBR/msdos or GPT partitioning system and the FAT32 filesystem.

      • Ade says:

        Alright, installed rEFInd, seems to work correctly, but does not yet recognize the USB.
        But, I put Mint on a DVD, and that rEFInd will recognize. Trying to boot from that, I get the following:”
        1.
        2.
        Select CD-ROM Boot Type:”
        At which point I can’t make any inputs, the system is responsive though (as in, the courser is blinking).
        Any thoughts on that?
        Thanks!

        p.s.: Not sure whether it matters anymore, but the USB drive is FAT formated and uses a Master Boot Record partitioning (hope I got you correctly there). Am not sure about the “bootable flag for the boot partition”, could you clarify that?

  11. bradnic says:

    Thanks for documenting this a bit more thoroughly than some of the others out there.

    Just tried this on a late 2006 mbp 2.33 core 2 duo with EFI32. you can’t rename the 32 bit boot loader EFI file with this laptop. leaving it as “bootIA32.efi” got it listed as a boot option when you hold the alt key. gets to the loads screen, “Loading Linux” completes, “Loading RAMdisk” completes, and then the system hangs at the “booting the kernel”. option.

    Tried this with Mint 17 Cinnamin. Will try another distro.

  12. AstroFloyd says:

    I apologise, but I don’t think I can add anything useful here. I didn’t try Mint myself, so you could try one of the (older) (K)Ubuntu versions I tried and boot them from DVD. Sorry…

    • Ade says:

      Yeah no problem, thanks for all the clarification anyways. Just to clear that up: Are you suggesting to leave Mint and go with one of the older (K)Ubuntu distributions, as those worked for you (I have been considering that anyways); or just install (K)Ubuntu first to have a platform from where to install Mint?

      • AstroFloyd says:

        Yes, but I realise now that that is nonsense – I used it to get a command prompt and install rEFInd manually, which you don’t need to do.

        What I should have answered instead is to try a recent version of another Live CD/DVD and see whether that does boot. If so it’s a Mint issue – if not, there’s no conclusion (try another?) and I’m afraid I can’t help… Good luck!

  13. AstroFloyd says:

    There is a lot of detailed information on UEFI available on Rod Smith’s website:
    http://www.rodsbooks.com/efi-bootloaders/

  14. Paulo says:

    not working for me – rEFIt says “Starting boot.efi” and “Error: Unsupported while loading boot.efi” – and when i tried to install rEFInd 0.7.7 (from OSX .4.11, on a Macbook 2,0), it says

    guests-computer:/efi/refind_install/refind-bin-0.7.7 guest$ ./install.sh
    ./install.sh: line 1015: unexpected EOF while looking for matching “’
    ./install.sh: line 1064: syntax error: unexpected end of file
    guests-computer:/efi/refind_install/refind-bin-0.7.7 guest$

    (the same happens when i try to install rEFInd 0.8.6 )
    what should i try?

  15. Paulo says:

    (the situation is that i lost grub (having Lubuntu and Crunchbang installed in other partitions, and some important files there i didn’t backup yet… :S ), and the superdrive is busted from years ago – i guess the only choice i have is to run gnu/linux live-cds like boot-repair-disk, and it seems i’m very dependent of booting this live-cd via usb… :S )

  16. Altoidnerd says:

    Apple’s support is the worst. I’m with a macbook pro from 2010-11 whose owner gave up on it because apple wont allow installation of osx lion without a firmware update.

  17. smboko says:

    “In order to install Linux, I booted Kubuntu using the method described above, installed rEFInd from there, which then allowed me to boot from a normal Live USB flash drive…”
    Ok, how did you install rEFInd from there? I have refind installed on mac osx, comes up at boot up prompt – not much of use unless the usb flash goes into action . The usb flash drive does show up –
    but doesnt do much yet -but havent used this tutorial yet.
    I Have similar mac like yours ( still works ok ). Understand everything else on tutorial but the install rEFInd part. Im on a mac 10.6.8 and have a spot for linux.
    Seem to have an issue with firmware problem / booting / communicating with the usb flash drive. Its just that there are so many tutorials out there and they are all different – some the same – not working for me.
    Thanks

    • smboko says:

      Horay! Got it going and thank you for the info. Didnt install it yet but got to the nice screen and it ask if you want to install . Can see why people like it so much – eye candy. Know how to install rEFInd.
      On the startup when booting up mac i hold down the alt – options key and presents boot options. In my flash drive just have the directory /efi/boot/boot.iso and /efi/boot/bootIA32.efi . I went with Kubuntu 13.10 desktop ISO and ISO 2 USB EFI Booter for Mac.

      • Tommy says:

        Thank you! This did the trick for me on a 2007 2,1. Could not make it work with boot.efi, bootIA32.efi worked.

  18. Pingback: Installing elementary OS on my late 2006 MacBook | pommi.nethuis.nl

  19. Tom says:

    THX, this is the first version to boot Ubuntu that worked on my macbook(white)

  20. sammczk says:

    Thank you for this great article. JFYI – i also been able to use Enterprise EFI boot loader to load live distribution from iso images on USB flash. It allows to put more then one image on a single USB drive and select them on boot.

  21. Jason says:

    I put a new SSD, unformated as the previous one fried, into a 2006 macbook pro a1212 and when I try to access the boot menu I get as far as a grey screen and a cursor and then then it stops. Its not frozen because the cursor moves, my usb is formatted as you describe. Has anyone else had this problem? Cheers!

  22. Rob says:

    Thank you. I’d been struggling for a week to get Ubuntu (or any version of Linux) onto a 64bit Macbook 2007 w/32bit EFI that had a broken DVD and wouldn’t boot anything from an external DVD or anything from a USB. I first tried the simple method of the two files in directory /efi/boot on a properly formatted USB, and no success of any live USB creation methods.

    However, what worked for me was to install rEFInd (I did it manually), to the EFI partition of the USB. With this done, re-booting with the option-key now consistently recognized the USB and brought up an “EFI-Boot” icon representing rEFInd. Although I tried and couldn’t get rEFInd to complete a boot of any Linux version, now at least, the machine was seeing the USB. So I tried the simple method again booting with the option-key and it brought up a second “EFI Boot” Icon representing the 32bit Ubuntu 14.04 using the bootia32, and Presto! Ubuntu loaded presenting itself to install on my brand-new clean SSD.

    While I might have done a dual-boot just for fun, there seemed no point since os-x 10.7.5 is the end of the line for this macbook.

  23. OldMacUser says:

    This tutorial has been a lifesaver. My optical drive broke on my early 2006 MacBook and I could not get ubuntu to load using either rEFInd or rEFit. I guess the secret is the boot.efi files located at http://www.mediafire.com/?dpgorsfdkf6nn2c . I am able to boot into ubuntu 14.04.4 i386 no problem now. -Thanks!

  24. Emmanuel says:

    This works on terminal of mac os x or I need to do it in Linux conosole?

    • AstroFloyd says:

      I prepared my USB pendive on a Linux machine, but I suppose using a console on MacOS should work, possibly with slightly different commands, depending on the packages you have installed.

  25. Johan Thor says:

    This tutorial got me a few steps further. Thanks. Have tried creating bootable USBs using all available methods but my old Mac Mini 2.1 wont agree with them.

    When using the 32-bit efi file rEFInd displays the boot option. I guess my computer is 32 bit at least in the startup process. The CPU is a Core 2 duo so it should be 64 bit capable Going here will for some reason leave be with a GRUB 1.99 prompt. The prompt is placed in the root of the boot.iso file. Have tried a few different Ubuntu 64 bit ISOs. 16 Desktop, 16 server, 14 server.

    Any ideas why I get that grub prompt and what could be done?

  26. AstroFloyd says:

    I’m not sure (nor an expert) – did you try a 32-bit iso?

  27. O-D-M says:

    My macbook is a 64 bit system, but the EFI architecture is 32 bit. Could I use the 32 bit efi boot file with a 64 bit disk image? This might have been an issue on my part, but rEFind seemed impossible to install using a 32 bit version of linux.

    • AstroFloyd says:

      I apologise – I don’t know the answer to your question. I would give it a try with a 32-bit EFI and a 64-bit OS. Please report back if you do. BTW, if I am not mistaken, 32-bit OSs should run on 64-bit hardware.

      • O-D-M says:

        I’ve tried and you do need a 32 bit iso when using the 32 bit elf file. I was able to get rEFind installed using your tutorial and it seems to be functioning correctly. However, I can’t install 64 bit linux images (I actually haven’t tried 32 bit ISOs yet, it’s not really a viable downgrade to me), a real shame since a 64 bit version of Debian was on that machine for ages and a lot of software seems to be dropping 32 bit Linux support lately.

  28. Steve says:

    I tested this with Ubuntu 64 as boot.iso on a 64-bit UEFI IdeaPad 300.
    It got to the grub prompt.
    I then typed
    configfile /boot/grub/loopback.cfg
    and it booted to Ubuntu fine

  29. Steve says:

    See http://www.rmprepusb.com/tutorials/136_uefi_ubuntu
    Hopefully, I have managed to patch the .efi files so they ‘just work’!

  30. Netta says:

    Hi,
    I have an iMac which hardware is 64bit but it has bootloader – EFI32 (it’s a kind of a bug in iMacs from 2006, 2007), i want to install linux 64 as doal boot from usb flash drive.
    i installed refined bootloader, i can see the usb, but when i try to boot from it, i get message that system refuse to boot from it.
    Will this method work for me? And what should i use the 32 boot file or 64?

    • AstroFloyd says:

      Sorry, no idea. I used trial and error once for the system described, and this turned out to be the solution. Try it and report back whether it works for future users of your system.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s