Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
The first post of this thread is a WikiPost and can be edited by anyone with the appropiate permissions. Your edits will be public.

supermariofan25

macrumors regular
Original poster
Feb 7, 2011
139
14
After a lengthy bit of browsing I decided that I could not easily find a tutorial for installing and booting Linux from a external usb that works on Macs, so I thought that I might make one. Here it goes:

Installing Ubuntu Linux (or any other Linux distro really) onto a USB drive for use with Macs.

Prerequisites:

  • A 64 bit capable Intel Mac (Anything from 2008 or after should be fine i.e Intel Core 2 Duo machines)
  • A 64 bit EFI capable (Desktop) Ubuntu iso file or equivalent for your favourite distro.
  • UNetbootin or similarly capable software for creating an install drive from the .iso file
  • A 2GB or larger USB for putting the installer on. This will be erased so make sure you take everything important off it.
  • A USB Flash or Hard Drive of you choice and size (32 GB minimum recommended for Ubuntu 16.04) This will be erased so make sure you take everything important off it.
DISCLAIMER: EVEN THOUGH I HAVE USED THIS METHOD MANY TIMES WITH MUCH SUCCESS AND NO ISSUES, I HIGHLY RECOMMEND THAT YOU CREATE A BACKUP OF YOUR CURRENT INSTALLATION USING WHATEVER METHOD YOU CHOOSE. FOLLOW THIS TUTORIAL AT YOUR OWN RISK!!!

Note: For this tutorial I am using a Mac with OS X El Capitan, If you are using a Mac with an earlier version of OS X installed then some parts that use Disk Utility will be slightly different.

Step #1:

Once you have everything you need a good place to start is Disk Utility.


  1. Open Disk Utility and select the USB drive you wish to boot the installer from and erase it as FAT32 using GPT Partition Table. For this I am using a 4 GB Sandisk Cruzer from back when they made the 'U3' USBs
27347330763_d3e602a5f6_o_d.png


While still in Disk Utility you can partition your soon to be OS install drive.




    • Select the drive and erase it as OS X Extended (Journaled) with the GPT Partition Table, this is because for some reason El Capitan wont let you partition a drive that has been formatted otherwise.
      27347330753_6700616eea_o_d.png
      27960815565_6f84f72bef_o_d.png
    • Once the drive has been erased, open the partitioning window and create the partitions however you want them. I you are not sure, I for example have created three partitions on my drive. The first partition is 50 GB and is for the system (/ mount point) the third partition is 4 Gb for swap and the second partition takes up what ever space is left and is used for the user data (/home mount point)
      27859013822_918d202565_o_d.png
    • Click 'Apply' and wait for the disk to Finish partitioning.
Before closing Disk Utility make note of the device 'BSD name' for the USB that you will be putting the installer on. As seen here:
27859438452_6c01d2b028_o_d.png


Step #2

After formatting the drives, you will need to create the install disk with UNetbootin or your preferred equivalent.

  1. Open UNetbootin, you will be confronted with a prompt to input the credentials of an account with administration rights.
    27960814565_11f5bca153_o_d.png
  2. Select the 'Disk Image' option and browse to your .iso file, then select the correct device from the drop down list. It should look something like this before hitting 'OK':
    27348336704_380cfac6f6_o_d.png
Once done, UNetbooting might say something like 'the created USB cannot be used on this computer' this can be ignored as the USB will indeed work on your Macintosh. Restart your Mac and hold down the option key to get to the Boot device selection menu.
27348342274_b6647d3ae6_o_d.jpg

Select 'EFI Boot' followed by 'Try Ubuntu without installing' to boot into a 'live' version of Ubuntu

Step #3

Tip: At this point you may want to use WiFi if you are using a laptop, but you may find that you are unable to if your laptop has a Broadcom wireless chip (Most 802.11AC laptops to my knowledge). To enable Wifi for updates ect. during the installation, Go to 'System Settings' -> 'Software & Updates' -> 'Additional Drivers' and enable the Broadcom driver (Note: this seems to only work during installation, you will need to connect to the internet some way or another and install 'bcmwl-kernel-source' via the terminal after installation).
27681507830_a3922cace2_o_d.jpg


  1. Open the Ubuntu Installer shortcut thats on the desktop to open the Ubuntu Installer.
    27348342214_4cf3216c51_o_d.jpg
    Note: At somepoint the installer might ask you if you want to unmount the currently mounted drives, CLICK YES
    27681507400_88844bdd7f_o_d.jpg
  2. Continue through the installer as normal until you get up to 'Installation Type' screen.
    27348341904_2aa0196eda_o_d.jpg
  3. At this point you must click 'Something Else' OTHERWISE you risk losing all your data or doing something that you didn't mean to do.
  4. Set the 'boot loader' install device to your desired USB device from the drop down menu and setup the partitions to how you desire MAKING SURE that you are using the right partitions, for example if your USB device shows up as '/dev/sda' from the drop down menu then only edit the partitions that start with '/dev/sda' for example '/dev/sda2'. Do not touch any partitions that don't start with the same path as your USB unless you know what you are doing. If you are following the partition scheme that I am using then your screen should look similar to this (substituting /dev/sda2 with /dev/sdX2 or what ever letter your drive has assigned:
    27960821635_0cd5877e54_o_d.jpg
  5. Once you are sure that you have done the partition setup correctly you may hit 'Install Now' and finish the rest of the installation setup such as time zone, user ect. DO NOT restart at the end of the installation.
Step #4

Now that you have your favorite version of Linux installed, it's now time to make it 'bootable' so that your Mac can see it as a boot drive.

Note: Some of you may not have to mount the EFI partition on the internal drive if GRUB managed to install itself on the external drive. Steps 2 - 5 are solely a work around for a glitch that I have experienced where the Ubuntu installer completely ignores when you told it to install the boot loader. If you are sure that is not the case (e.g. you disconected the internal drive to prevent harm.) then only create a folder for and mount the EFI partiton of the USB drive. However it is always handy to mount the EFI partition of the internal drive just to check.

  1. While still in the live environment, open up a terminal and start your disto's file manager as root, for example in Ubuntu the command is
    Code:
    sudo nautilus
    27926428846_8aa86384f8_o_d.jpg
  2. Navigate to /mnt/ (Click 'Computer' in the side bar then click the folder named 'mnt') and create two folders, one will be named after the EFI partition of your internal Hard Drive (for example mine was sdb1), and the other will be named after the EFI partition of your USB drive (for example mine was sda1). Note: The EFI partition will always be the first partition e.g /dev/sdX1 where X is the drive letter and 1 is the partition.
    27681504860_9dced44365_o_d.jpg
  3. Using another Terminal window you will need to mount the EFI partitions of both the internal and USB drives using the command
    Code:
    sudo mount /dev/sdX1 /mnt/sdX1
    Replace X with the letter assigned to your drive e.g. for me it was
    Code:
    sudo mount /dev/sda1 /mnt/sda1
    for the USB drive and
    Code:
    sudo mount /dev/sdb1 /mnt sdb1
    for the internal drive.
  4. Once you have the EFI partition mounted you can move the 'ubuntu' folder from the internal drive's EFI partition to that of your USB drive. First, however you must create a folder called 'EFI' (without the quotation marks) on the root of the EFI partition for your USB drive. If that folder already exists then you may use that one instead.
  5. Move (don't copy, move) the 'ubuntu' folder from the EFI folder inside the EFI partition on your internal drive to the EFI folder on the EFI partition on you USB Drive (if that makes any sense to you).
  6. While in the EFI folder of your USB drive, create a folder named 'boot' (without the quotation marks of course). The EFI folder on the EFI partition of the USB drive should now look like this.
    27347331933_0913a89a87_o_d.jpg
  7. Finally move the file named 'grubx64.efi' located inside the 'ubuntu' folder to the 'boot' folder you created earlier and rename it 'bootx64.efi' (If you prefer to use the 'secure boot' version of grub then move the 'simx64.efi file along with the grubx64.efi and rename the shimx64 file instead.)
    27926427776_79b433c3e6_o_d.jpg
    Note: I have previously renamed my grubx64.efi file to ubuntux64.efi to test something, yours will be called grubx64.efi
  8. Once you have in the EFI folder on the EFI partition of your USB drive a folder named 'boot' containing a file named bootx64.efi (previously grubx64.efi) and another folder called 'ubuntu' with the grub.cfg file and the other files found in the 'ubuntu' folder then you may restart your computer holding the 'option' key as you do so.
  9. Boot into OS X
Step #5

Once you have installed Linux you may need to set OS X as the startup disk again, I have found myself that ubuntu (more likely grub) sometimes likes to set itself as the default boot loader for when the system starts up which will inevitably lead to your system complaining that no startup volume can be found because you moved the boot files after the installation.

  1. Once OS X has booted login to an admin account and open 'System Preferences' -> 'Startup Disk'
  2. Select 'Macintosh HD' (or whatever your OS X drive is called) and click restart.
    27347330443_7ae61dbdee_o_d.png
    Hint: You may need to unlock the preference pane by clicking the lock on the lower left corner and inputing the credentials of an admin account.
  3. While restarting you may jump straight to the OS selection menu by holding 'option' and then selecting the 'EFI Boot' option. Hint: If there are two, remove the USB that you used to install Ubuntu or whatever Linux distro you used. Then select the sole remaining option named 'EFI Boot'
    27348342274_b6647d3ae6_o_d.jpg
Congratulations,if you see something like the image below then you have successfully installed Linux onto a USB drive and have also made it bootable by your Mac!!!
27859014482_6e65fcbc43_o_d.jpg
 
Last edited:
  • Like
Reactions: BorderingOn
Thanks for writing this. Would the same procedure work for installation onto a drive in one of the PCIe slots of a 2008 Mac Pro (MacPro3,1)?

I want to put linux on dedicated drive. I figure an SSD drive will help me add some life to the old hardware, and it should be a PCIe drive to take advantage of the speed. My current boot drives are in the first two hard drive bays. I may remove them temporarily, but would like to end up with a system that lets me choose to boot from the PCIe drive for linux, or one of the regular hard drives for MacOS. Think it would work?
 
Thanks for writing this. Would the same procedure work for installation onto a drive in one of the PCIe slots of a 2008 Mac Pro (MacPro3,1)?

I want to put linux on dedicated drive. I figure an SSD drive will help me add some life to the old hardware, and it should be a PCIe drive to take advantage of the speed. My current boot drives are in the first two hard drive bays. I may remove them temporarily, but would like to end up with a system that lets me choose to boot from the PCIe drive for linux, or one of the regular hard drives for MacOS. Think it would work?

You could possibly do that but their is no promise that you will be able to boot from it and would be better off getting an SSD for the Linux boot drive despite the slower SATA II Speeds. If you wanted to use the PCIe drive as a fast storage option, you can still setup Linux to point various directories to the PCIe drive during installation. For example, you can map the /home directory to a completely different drive while installing ubuntu. That way your /home folder and all your user files would be on a different drive (PCIe) to your boot drive (SSD).
 
You could possibly do that but their is no promise that you will be able to boot from it and would be better off getting an SSD for the Linux boot drive despite the slower SATA II Speeds. If you wanted to use the PCIe drive as a fast storage option, you can still setup Linux to point various directories to the PCIe drive during installation. For example, you can map the /home directory to a completely different drive while installing ubuntu. That way your /home folder and all your user files would be on a different drive (PCIe) to your boot drive (SSD).

Hmmm. So the firmware will look at drives in the drive bays for a bootable OS, but maybe it doesn't know to look for a PCIe drive? Is that the problem? And then, if I want a dedicated internal drive for linux, my best bet may be to put it in one of my free drive bays, so it will be recognized? I could still use an SSD, but at slower SATA II protocol. Am I getting it?

Your suggestion of mounting various directories on a faster PCIe intrigues me. I wonder if I could do that with all of them except for the boot partition? In particular, I wonder if doing that with the swap partition might be a win.

Thanks,

David
 
Hmmm. So the firmware will look at drives in the drive bays for a bootable OS, but maybe it doesn't know to look for a PCIe drive? Is that the problem? And then, if I want a dedicated internal drive for linux, my best bet may be to put it in one of my free drive bays, so it will be recognized? I could still use an SSD, but at slower SATA II protocol. Am I getting it?

Your suggestion of mounting various directories on a faster PCIe intrigues me. I wonder if I could do that with all of them except for the boot partition? In particular, I wonder if doing that with the swap partition might be a win.

Thanks,

David
Well, after some thought it seems that you might be able to trick your Mac Pro into booting from the PCIe SSD using GRUB. From my understanding the Mac Pro will only like booting from SATA drives, maybe USB drives. But whether or not it can natively boot from a PCIe based storage drive is unknown to me. It wont hurt to try, but it will be wasted time if it doesn't work (Assuming you already have a PCIe SSD, otherwise it will be wasted money as well). As for tricking the Mac Pro using GRUB, I will look into this to the best of my abilities but I don't have a Mac Pro to test with, or a PCIe SSD, so any method found will only work in theory for your situation. If you want to try install Linux solely to the PCIe SSD and try booting from that, then follow the guide but adapt for your needs and fell free to ask me questions or for help with issues you come across. Also, before trying any of this, I would at least see if you can install ubuntu on a normal HDD or SSD using the above method to see if you Mac Pro even supports the type of EFI Ubuntu uses. This tutorial only works for EFI installs and NOT legacy type installs.
 
Well, after some thought it seems that you might be able to trick your Mac Pro into booting from the PCIe SSD using GRUB. From my understanding the Mac Pro will only like booting from SATA drives, maybe USB drives. But whether or not it can natively boot from a PCIe based storage drive is unknown to me. It wont hurt to try, but it will be wasted time if it doesn't work (Assuming you already have a PCIe SSD, otherwise it will be wasted money as well). As for tricking the Mac Pro using GRUB, I will look into this to the best of my abilities but I don't have a Mac Pro to test with, or a PCIe SSD, so any method found will only work in theory for your situation. If you want to try install Linux solely to the PCIe SSD and try booting from that, then follow the guide but adapt for your needs and fell free to ask me questions or for help with issues you come across. Also, before trying any of this, I would at least see if you can install ubuntu on a normal HDD or SSD using the above method to see if you Mac Pro even supports the type of EFI Ubuntu uses. This tutorial only works for EFI installs and NOT legacy type installs.

Thanks for your thoughts! Hmmm. Buying that PCIe drive now seems risky.

Are you saying that the Mac Pro prefers booting from spinning SATA drives, or are you saying that it's looking in the regular drive bays and USB? If the latter, I might still be able to buy an SSD drive for one of the two empty drive bays. That might be less risky. I do want a dedicated drive for linux.

Thanks!

-David
 
The boot drive doesn't have to be a spinner, it can be SSD.

Based on my experience with a 4,1 running linux, I'd say just stick one or two SSD's into the empty drive bays and use them for linux. Unless you're running some fairly serious I/O intensive work, you won't really see that much of an improvement from a PCIe based SSD. I have both in my box, and while the PCIe storage is clearly faster when running benchmark loads, it's very nearly imperceptible for interactive stuff, compiles, etc.
 
Thanks for your thoughts! Hmmm. Buying that PCIe drive now seems risky.

Are you saying that the Mac Pro prefers booting from spinning SATA drives, or are you saying that it's looking in the regular drive bays and USB? If the latter, I might still be able to buy an SSD drive for one of the two empty drive bays. That might be less risky. I do want a dedicated drive for linux.

Thanks!

-David
Yeah, well while I cant prove this myself. The evidence that I have seen shows that the Mac Pros only like booting from SATA attached drives or IDE drives depending on what yours came equiped with. Possibly USB install drives depending on the year. SATA attached would mean spinning HDD or SSD, basically any permanent storage medium that interfaces with the computer via SATA.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.