Install Ubuntu 15.04 to a Micro SD Card on a MacBook Pro 12,1

Posted: 2015-08-16 in How To, Tech, Unix Geekery
Tags: ,

GEEK ALERT! GEEK ALERT! GEEK ALERT!

I recently purchased an early 2015 13″ Ratina MacBook Pro. I wanted to do something with the SD Card slot and saw an ad for the Nifty MiniDrive. I decided I was going to install Ubuntu on the SD Card so that it was always available but without making any permanent modifications to my internal drive. This post will describe exactly what I did to accomplish this goal.

When complete, you will have Ubuntu installed to your SD card, rEFInd installed on your SD Card, and GRUB will be removed from your internal hard drive.  When booting into Ubuntu you will first use the Apple Boot Manager (by holding the “option” key) to get you to rEFInd, and then rEFInd will boot Ubuntu in verbose mode.

Eventually, I would like to remove rEFInd as well and just use the Apple StartUp Manager to boot directly into Ubuntu but I have not found a good tutorial yet.  In all honesty, I don’t understand enough about EFI booting to understand how the boot process is being completed without GRUB.  I just deleted GRUB from /dev/sda to see what would happen and found that not only did Ubuntu boot but it booted a lot faster without it!

Nifty MiniDrive

Nifty MiniDrive

Nifty MiniDrive installed in the SD Card slot of my rMBP

Nifty MiniDrive installed in the SD Card slot of my rMBP. The entire Ubuntu system, rEFInd, and my user files all reside inside that little red MicroSD Card.

Nifty MiniDrive Box

Nifty MiniDrive Box

Downloads

What you need

  • 32GB or greater micro SD Card
  • Nifty MiniDrive Adapter (not required. You can use any SD Card or MicroSD Card with adapter.
  • Ubuntu 15.04 iso
  • 8GB USB stick (to create the Ubuntu install USB)
  • A verified, and bootable backup of your system.

Create The Ubuntu Live USB

Create a bootable Ubuntu USB stick using these instructions on the Ubuntu download page.

Prepare SD Card

Use Disk Utility to create three partitions on the SD Card.

  • 10GB for the Ubuntu root partition (FAT32). Will be changed to ext4 during install of Ubuntu.
  • 18GB for your Home partition (FAT32).  Will be changed to ext4 during install of Ubuntu.
  • ~4GB for a Share partition (FAT32)
  • Select options and select GUID partition scheme.
  • Press Apply.

Install rEFInd onto the SD Card

  1. Open Terminal and type the following command
    diskutil list
  2. The output will look similar to this:
    $ diskutil list
    /dev/disk0
    #:                      TYPE NAME     SIZE      IDENTIFIER
    0:     GUID_partition_scheme          *500.3 GB disk0
    1:                       EFI EFI      209.7 MB  disk0s1
    2:         Apple_CoreStorage          499.4 GB  disk0s2
    3:    Apple_Boot Recovery HD          650.0 MB  disk0s3 
    
    /dev/disk1
    #:                      TYPE NAME     SIZE      IDENTIFIER
    0:         Apple_HFS MBP SSD          *499.1 GB disk1
                                 Logical Volume on disk0s2
                                 11B21249-47B3-4FF1-A807-AD81CEC8B910
                                 Unencrypted
    
    /dev/disk2
    #:                      TYPE NAME     SIZE      IDENTIFIER
    0:     GUID_partition_scheme          *31.9 GB  disk2
    1:                       EFI EFI      209.7 MB  disk2s1
    2:      Microsoft Basic Data UBUNTU   10.5 GB   disk2s2
    3:      Microsoft Basic Data HOME     18.1 GB   disk2s3
    4:      Microsoft Basic Data SHARE    3.1 GB    disk2s4
    $
  3. Above, you can see that the EFI partition on my 32GB flash drive is /dev/disk2s1.
  4. Type the following commands in Terminal to mount the EFI partition of the SD Card:
    mkdir /Volumes/efisd
    sudo mount -t msdos /dev/disk2s1 /Volumes/efisd
  5. Mount the rEFInd disk image.
  6. Drag the rEFInd EFI folder and copy it to the EFI partition of the SD Card by dragging and dropping. Unmount the rEFInd image.
  7. On the SD Card EFI folder, delete the 32-bit drivers and executables.
  8. Optionally, you can edit the rEFInd.conf file in order to remove the Recovery HD, and Legacy mode boot options.  Just open the rEFInd.conf file in a text editor and remove the “#” that precedes these two lines in the file.  They are not adjacent so you will have to scroll through and find them.
    scanfor internal,external,optical,manual
    dont_scan_volumes "Recovery HD"
  9. Once you make the edits to rEFInd.conf, save it and close it.
  10. OPTIONAL: With the EFI partition mounted you can change the icon to an Ubuntu icon (or any other icon you prefer.  Find an icon you like and apply it to the EFI folder.  I used an Ubuntu icns file I downloaded off of the internet.
  11. Eject the EFI folder.
  12. Copy the wireless driver to the share partition on your SD Card. Just drag the “brcmfmac43602-pcie.bin” file that you downloaded earlier to the SHARE partition on the Micro SD Card.

Install Ubuntu to the SD Card

  1. Ensure your Ubuntu Live USB is inserted.
  2. Reboot computer and press and hold the option key after you hear the startup chime. If you changed the icon of the EFI folder on the SD card, then your start up screen will look similar to mine. If you see two “EFI” sections, choose the one on the left.

    Start Up Manager before installing Ubuntu. Choose the LEFT EFIBoot.

    Start Up Manager before installing Ubuntu. Choose the LEFT EFIBoot.

  3. Select “Try Ubuntu” and let it boot up.
  4. Click on “Install Ubuntu” and follow the prompts until you get to Preparing to Install Ubuntu.
  5. Ensure that “Download updates while installing” and “Install this third-party software” are Unchecked. My installs failed when either were checked.
    Do not install updates or software
  6. When you get to Partitioning, choose “Something Else.”
  7. At the bottom of the window, select /dev/sdb2 as the location to install the boot loader (the same partition that you will install Ubuntu and mount at /. I think there is a bug in the installer because it always installs GRUB to the EFI partition of /dev/sda/. No worries because we will fix it after the install.
  8. Select the /dev/sdb2 partition (yours may be different, make sure you choose your 10GB Ubuntu partition). Press “Change…” In the drop down choose use as ext4 and set mount to “/”. Check format. Hit ok.
  9. Select /dev/sdb3 (may be different on your system, choose the “HOME” partition you created when we prepared the SD Card in OS X). Press “Change…” In the drop down choose use as ext4 and set mount to /home. Check format. Hit ok.
  10. Hit continue. You’ll get a warning that you will erase those two partitions. Hit ok.
  11. You’ll get another message that you have no Swap. That is fine, I have 16GB of RAM and doubt I will need it. Hit ok.
  12. Press “Install.”
  13. Once the install is complete choose to reboot.  You’ll get a message to remove the Installer USB and press enter.  Remove it and press enter.  The system will reboot. Reboot into OS X.

Remove GRUB From Your Internal Drive

  1. Once you are booted back into OS X, open a Terminal.
  2. Mount the EFI partition of your internal hard drive using the following commands.
    diskutil list
    Your EFI partition is probably disk0s1 but verify this from the output of diskutil list!
  3. Type the following commands in Terminal to mount the EFI partition of your internal HD:
    mkdir /Volumes/efi
    sudo mount -t msdos /dev/disk0s1 /Volumes/efi
  4. The EFI partition will mount.  Open it with the Finder.
  5. Open the EFI Folder.  There will be two folders: APPLE and UBUNTU
  6. Delete the UBUNTU folder ONLY
  7. Eject the EFI volume.
  8. Restart the computer.
  9. Press the “option” key after you hear the start up chime and choose “EFIBoot.” Mine looks like this:

    Apple Start Up Manager

    Apple Start Up Manager

  10. On the rEFInd Menu Choose Ubuntu and press enter.  Your system will load.  Enter your password and you will be logged in to Ubuntu. My rEFInd Menu looks like this:

    rEFInd Menu

    rEFInd Menu

  11. If you open the “Disks” application in Ubuntu you can see how your partitions are laid out.  Below is a picture of my final set up.

    Final partition setup in Ubuntu

    Final partition setup in Ubuntu

Get Your Ubuntu WiFi Working

  1. Open Terminal and enter the following commands:
    cd /lib/firmware/brcm
    sudo cp /media/YOURUSERNAME/SHARE/brcmfmac43602-pcie.bin .
  2. Reboot.
  3. WiFi should be working and you should be able to update your software.
  4. Reboot after updates have been applied and enjoy Ubuntu running off your SD Card!

Fixes Still Required

  1. 5Ghz WiFi does not work.  Only 2.4Ghz.
  2. Trackpad does not work perfectly.  No two-finger scrolling or two-finger right clicking.
    1. Go to Github and download the zip file (on the right hand side).  Extract the archive.  Open a terminal go to the directory of the archive.  Follow the instructions in the readme file and reboot.  Works like a charm!
    2. I noticed that after an update, I had to re-apply this fix.  So bookmark the github link.
  3. I’d like to figure out a way to get rid of rEFInd but have not figured that out yet.

I hope you found this tutorial helpful.  Please leave a comment if it helped or if you have any questions.

References

Comments
  1. Yikpur says:

    Thank you very much! Installed it on my Macbook 6,2. Only suspend isn’t working on battery, but when connected to power.

    Like

  2. Damon Goldsmith says:

    This worked like a charm! Thanks so much.

    Like

  3. Daniel Seddon says:

    Thanks John. This is a great guide, I was looking to do exactly this. But, I’ve followed the steps and don’t see the SD card after hitting the Option key (I can see the USB stick when it’s plugged in). I’m suspecting this is some kind of hardware issue with my SD card. Should the card always be visible, or do you have to get the setup exactly right to see it there?

    Like

    • John A says:

      Dan, if the SD card does not appear in the Start up manager (by holding down the OPTION key at the boot chime), it usually means there is not a bootable partition on that drive.

      Is rEFInd installed on the EFI partition of the SD Card? It needs to be in order to boot the Ubuntu system. See the “Install rEFInd onto the SD Card” section and ensure you followed my instructions to the letter.

      Also, try shutting down the computer. Turn it back on and enter start up manager. Sometimes it can be a little wonky.

      Another thing to check is your partition scheme. Open a terminal and enter the following command:

      diskutil list

      Your SD card partition scheme should look like the output below if you followed my instructions.

      /dev/disk2 (internal, physical):
         #:   TYPE                   NAME    SIZE       IDENTIFIER
         0:   GUID_partition_scheme          *31.9 GB   disk2
         1:   EFI                    EFI     209.7 MB   disk2s1
         2:   Linux Filesystem                10.5 GB   disk2s2
         3:   Linux Filesystem                18.1 GB   disk2s3
         4:   Microsoft Basic Data   SHARE     3.1 GB   disk2s4

      Like

  4. Blackdoom says:

    Hey man
    Just want to know. Can I remove the sdcard from the computer and run mac without a problem?
    Regards

    Like

    • John A says:

      Dan,
      Absolutely. Obviously you wouldn’t be able to run Ubuntu, but MacOS will run fine without the SDCard.

      Like

      • Blackdoom says:

        Hi John

        Ok so you are sure about this even though the bootloader is installed on the sd card.

        “7. At the bottom of the window, select /dev/sdb2 as the location to install the boot loader (the same partition that you will install Ubuntu and mount at /. I think there is a bug in the installer because it always installs GRUB to the EFI partition of /dev/sda/. No worries because we will fix it after the install.”

        Will it know to not search for that bootloader when the sd card is removed?

        Regards

        Like

  5. John A says:

    The boot loader is GRUB. MacOS does not need the Ubuntu boot loader to boot up. If you pull the SDCard out, Ubuntu is gone, and the boot loader is gone because the entire Ubuntu system is on the SDCard.

    Like

    • Blackdoom says:

      Hi Ok so I tried it and got to some point now it is giving me this error

      “mmc0: Controller never released inhibit bit(s).”

      I have

      OS X Yosemite
      Version 10.10.5
      MacBook Pro (Retina, 15-inch, Early 2013)
      Processor 2.7 GHz Intel Core i7
      16GB 1600 DDR3
      Macintosh HD
      Intel HD Graphics 4000 1024MB

      I dont know why but it does not seem to boot after the installation is finished.
      What info do you need and can you please try and help me.

      Like

  6. MagicCamera says:

    Nice job! I had already installed Ubuntu to an SD card prior to finding this tutorial and I had the grub loader issue when I removed the SD card on reboot. The idea of putting rEFInd on the SD card is a good one as I was reluctant to put it on my main hard drive as it gets purged when you update the OS. Anyway to get rid of the grub CLI on start up type exit and go to your Startup disk prefs in Sys prefs and choose your Apple disk and it eliminates the issue as there was no file or folder in the EFI mounted partition of the mac.

    This works great so well done!

    Like

  7. Ash says:

    Newbie here so might be a bad question. This worked like a charm except for some reason, after closing the laptop lid and having it sleep, when I open the laptop lid I get a black screen with the message unable to read itable block. I am assuming this is a problem with reading the sd card after putting the laptop to sleep? I can give more details but was wondering if anyone else who tried this ran into a similar problem. I installed Ubuntu `18 instead of 15

    Like

    • John A says:

      Hi Ash, a few people have had issues with hibernation or sleep. I usually don’t put the laptop to sleep when running Linux off an SD Card. Wish I could give you a better answer or a fix.

      Like

  8. robert says:

    mkdir /Volumes/efisd
    Permission denied
    any idea?

    Like

  9. asedeinfo says:

    Hello. Thanks so much for the tutorial 🙂
    Everything worked but I have a question.
    Why is it necessary to create one partition for / and another one for /home. I’m doing it with a 128GB SD card and I’m guessing if it would be possible to install it in one partition to make use of the whole storage capacity for apps, files, etc.

    Like

    • John A says:

      I don’t think you MUST. However, by creating a separate partition, you can easily backup your user folders without the OS. This is how I’ve always done it and it has worked well for me.

      Like

      • asedeinfo says:

        Thanks!! I think I am going to erase the SD Cards and restart the process and just give more space to the root partition.

        Like

Leave a comment