HOW TO: Run Linux Ubuntu on a MacBook from an external drive
HOW TO | TECHNOLOGY | OPERATING SYSTEMS | LINUX | UBUNTU | APPLE | MAC BOOK
Disclaimer: Proceed at your own risk, every device and digital file has its own merits and limitations, this guide provides no troubleshoot in the event of user, hardware or software error. No liability is accepted in the event of damage to your devices or systems.
This ‘How To’ guide is designed to guide you through the theoretical steps on how one might install the full Linux Ubuntu OS onto an external drive (such as an SSD) and run this on a MacBook. Given that this could irreversibly damage or destroy your device or system, it is not advised that you do this on any device or system that you do not own and do not mind loosing if you make any mistakes or anything goes wrong. Irreversible damage may be caused.
Why install on an external drive?
Linux and MacOS are both very secure so why run from an external drive? If you require a full Linux OS and do not want to deal with the lag caused by virtual machines but do not want to make permanent changes or partitions to your MacBook. Installing on a high speed external drive will allow the running of a full Linux Ubuntu OS environment with the convenience of a portable system that can simply be plugged into and run from any MacOS device.
- An Intel powered Macbook form 2013 or later with at 2 UBS or USB-C ports.
- A bootable USB flash drive for installing Linux Ubuntu.
- A blank, high speed SSD drive. You can still use a USB drive, but an SSD USB drive will be more durable, reliable and faster. These types of drive typically range around €80-€200 depending on country and brand.
Format your portable environment:
This is the SSD drive you wish to run the Linux Ubuntu OS from.
- Connect the drive to a MacBook and open Utilities.
- From Utilities – open Disk Utilities.
- Select the SSD (NOT your MacBook hard drive – check this CAREFULLY)
- Select Erase with the following variables selected:
- Name: EmptyDrive
- Format: Mac OS Extended (Journaled)
- Scheme: GUID Partition Map
- Create a new partition called ‘Ubuntu Boot Loader’.
Loading Linux Ubuntu OS on the external drive:
Firstly you will need to start a Linux ‘Live Session’
- Shutdown your Mac.
- Eject and remove the external SSD drive.
- Connect your Linux Installer USB flash drive that has the Linux Ubuntu installer on it.
- Boot you Mac pressing and holding the options key at the same time.
- Select the Orange EFI Boot option (right directional key then enter).
- Select ‘Try Ubuntu’
Prepare your external drive:
- Reconnect your external SSD drive.
- Open the GParted application that will be in your Linux window (click the upper left corner search icon, type in “GParted” and click the GParted Partition Editor application icon).
- Within the GParted application, find your external SSD drive. (It will look something like this: /dev/sdd) . Check the letters disk size are appropriate to ensure you are selecting the correct drive.
- Delete all the partitions EXCEPT the hfs+ Ubuntu Boot Loader partition. (Removed partitions may be things such as: fat32 system labelled EFI or hfs+ system labelled EmptyDrive.) For each partition to delete:
- Select it
- Click the red circular icon.
- The delete operations are only queued and have not yet been actioned. Click the green check box to action the operations.
- Add a new partition (click Partition > new).
- Select the following variables:
- New Size: 14210 MiB (this should match your device’s RAM specs – e.g. 16 GB RAM would be 14210 MiB) How to convert GB RAM to MiB
- File system: linux-swap
- Add another new partition with the following options:
- New size: default
- File system: ext4
- Label: (Label as you wish)
- Apply the new partitions by clicking the green check
- Make a note of the ext4 partition name, e.g. /dev/sdd2
- Close GParted
Installing your new OS environment:
- Connect to WiFi (this saves time later, but is optional)
- Select “Install Ubuntu” in upper left corner on the desktop.
- Select your language.
- Check the boxes:
- Download updates
- Install third party software
- Select the “something else” option.
- Find the ext4 formatted partition you just created in GParted. Be exact and don’t make any mistakes here – check, double check, then check again, it is extremely important you select the correct partition on the correct drive here.
- Select “change”… and apply the following variables:
- default size
- Ext4 journaling file system
- Format the partition (check this box)
- Mount point: /
- Choose this device for boot loader installation: select the device that corresponds to the ext4 partition. (Do not select the SSD external drive itself, only the GParted created ext4 partition.)
- Follow the onscreen installation instructions.
- Once the installation has ‘finished’ select “continue testing”. (The installation process has not ‘finished’.)
Linux Ubuntu OS at this point is technically installed on your SSD external drive, yes, but you will not be able to boot into it from the MacBook load screen, since there’s no EFI boot loader needed for Mac firmware to recognise the OS as bootable.
You need to access the Ubuntu installation and create a boot.efi file that will be used to boot the OS. This needs to be done whilst still in the live Ubuntu session.
Making the OS Bootable:
- Using the same search icon you used to find GParted, search for and open “Terminal”.
- Run the following command: (replace ‘/dev/sdaN’ with the device that corresponds to your ext4 partition that you made a note of earlier.)
sudo mount /dev/sdaN /mnt
- To mount the top line directories use the following one line command:
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
- You can now use the chroot command to change your root directory to /mnt, so that the bash session in ‘Terminal’ is effectively running inside the Ubuntu installation:
sudo chroot /mnt
- This allows you to configure GNU GRUB, the “GRand Unified Bootloader,” with:
grub-mkconfig -o boot/grub/grub.cfg
- Save this to a standalone file with the following one line command:
grub-mkstandalone -o boot.efi -d usr/lib/grub/x86_64-efi -O x86_64-efi --compress=xz boot/grub/grub.cfg
- Exit the chrooted partition:
- The boot.efi file is in the new installation, however, you now need to copy it to the live session:
cp /mnt/boot.efi /home/ubuntu
- You now need to access the boot.efi file from your Mac OS system. The easiest way is to email the file to yourself, or save it to a cloud drive. You can find the boot.efi file in your home directory (click the file cabinet icon in the upper left, which launches a folder view of your home folder).
- Now you can shutdown Ubuntu. The device might lag.. give it 30 seconds or so and then shutdown the device itself.
- Click Utilities > Terminal.
- In the Terminal window, type in:
- Press Enter.
- Restart your Mac. If you get a black screen with the word “GRUB”, type “EXIT”Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen
- Press Enter.
- Restart your Mac. If you ever get a black screen with the word “GRUB”, type “EXIT”.
- In the Terminal window, type in:
- Launch Terminal (Go > Utilities > Terminal)
- Plug in your Linux Ubuntu SSD external drive and enter the following command into Terminal:
cd /Volumes/Ubuntu\ Boot\ Loader/
- Enter the following commands (one at a time) (the password is your Mac’s password):
sudo mkdir System mach kernel
sudo mkdir -p Library/CoreServices
- Download your boot.efi file from your email or cloud drive.
- Assuming your boot.efi file is now in your Downloads folder, enter the following command into Terminal:
sudo cp ~/Downloads/boot.efi ./
- In both Mac OS and Linux Ubuntu, you can find a file through the user interface / finder, and drag the file into a terminal window, and it will insert the full path to the file.
- Now you need to make a ‘SystemVersion.plist’ file.
<xml version="1.0" encoding="utf-8"?> <plist version="1.0"> <dict> <key>ProductBuildVersion</key> <string></string> <key>ProductName</key> <string>Linux</string> <key>ProductVersion</key> <string>Ubuntu Linux</string> </dict> </plist>
- Copy the SystemVersion.plist file to the same directory on the external SSD drive where your boot.efi is (/Volumes/Ubuntu\ Boot\ Loader/System/Library/CoreServices). Go back to Terminal and execute the command:
sudo cp ~/Downloads/SystemVersion.plist ./
- Open Disk Utility (Go > Utilities > Disk Utility) to check what disk number your bootloader is.
sudo bless --device /dev/diskNsK --setBoot
Where you replace N and K with the numbers from step 20.
Turning SIP security back on:
- Shut down your MacOS device.
- Remove your external device.
- Reboot your Mac into Recovery Mode by restarting your device and holding down Command+R until the Apple logo appears on your screen.
- Utilities > Terminal.
- Shutdown the Mac device.
Boot to Linux Ubuntu from your MacBook:
- Plug in your external SSD drive.
- Press the option key while booting up the MacBook.
- Select the orange Boot EFI.
- Now you have a full Ubuntu install actively running on your MacBook from the external device.
If you see the GRUB screen repeatedly when booting into Linux: go to System Preferences > Startup Disk, unlock, then select your Mac harddrive and restart the system. This will take longer than usual, so be patient. After that you won’t see the grub screen anymore on restarting your MacBook.
Get an external mouse with a left and right clicker. Failing that, in Linux select the “activities” icon and type “Universal Access”. Select “Pointing and Clicking”, and turn on Simulated Secondary Click. Now if you click and hold for a brief moment, you will get a right click.
© 2021 Al-Sahawat Times, Printed and Distributed by IPMG, an Al-Said Group entity.
Since you’re here …
… we have a small favour to ask. More people are reading Al-Sahawat Times than ever but advertising revenues across the global media industry are falling fast. And unlike many news organisations, we haven’t put up a total paywall. We want to keep our journalism as open as we can. So you can see why we need to ask for your help. Al-Sahawat Times’ independent, investigative journalism takes a lot of time, money and hard work to produce. But we do it because we believe truly ethical media and an unbias perspective really matters.
“I appreciate there not being a paywall: it is more democratic for the media to be available for all and not a commodity to be purchased by a few. I’m happy to make a contribution so others with less means still have access to information.”
If everyone who reads our reporting, who likes it, helps fund it, the future of ethical media and the futures of our staff and their families would be much more secure. For as little as £1, you can support Al-Sahawat Times and it only takes a minute. Thank you.
This story is available on:
Talk to a journalist
Follow Al-Sahawat Times
⬆️ Follow on Instagram
⬆️ Follow on Twitter
⬆️ Follow on LinkedIn
⬆️ Follow on Facebook
⬆️ Follow on YouTube
Read it on FLIPBOARD