Oct 18, 2015 If this link is wrong, Spex will probably correct me shortly. In the MacBook or another computer where you want to install Linux, you need to create a partition that is necessary so you don’t install two OS on the same drive. Go to Disk Utility on your MacBook. Click on View and choose ‘Show All Devices’. Now select the primary internal drive. Dec 21, 2016 To live boot into Linux on Mac, you will first have to create a Live USB for the distro you want. We’re demonstrating this using Ubuntu 14.10 “Yakkety Yak”, on a MacBook Air running the latest version of macOS Sierra. You should avoid Linux on a Mac Not because it is a bad OS - on the contrary, they are some very good distros out there. The problem that I have run into is consistency across distributions.
I’ve been feeling the pull of desktop Linux for a while now.The last time I tried to use Linux as my daily desktopwas almost 10 years ago.It was a pretty big failure.
But after so many years of using,and falling in love with,Linux on the server,I wanted to give it another chance.
So last week I hunkered down and,over the course of a few days,managed to build a functionalLinux environment on my laptop.I took rigorous notesas I struggled and encountered breakthroughs,the results of which you’ll find below.
The steps in this guide will take you froma single-boot OS X install on a Macbook Airto a dual-boot system with OS X and NixOS.Many of the steps apply to installinganother Linux distribution, too,in particular those dealing withdisk encryption (in OS X and Linux)and the requirement for Broadcom drivers.
Other than that,make sure you have any important bits saved somewhere safe,and enjoy the path to Linux below!
Table of Contents
What is NixOS?
There are many, many Linux distributions:distrowatch.com tracks 278 at the moment.Of those 278,you’ve probably heard of some of the major ones:Mint, Ubuntu, Arch, etc.NixOS is not one of the major ones.
So why did I choose it?
I’ve experimented previously withusing the Nix package manager,on which NixOS is built,and found it very interesting and powerful.
I really like the ideaof having a handful of declarativeconfiguration filesfrom which my entire system can be built.It means I can store it in gitand track the history of my configuration,just like with my dotfiles.It also means I can quicklyget up to speed on a new machine.
The ability to easily apply–and later rollback–configurations was also appealing,since I knew it would take a lot of experimentationto get the system working like I wanted.
I’d encourage you to read more aboutNixOS and Nix,especially if you intend to follow the guide below!
Download minimal 64-bit NixOS livecd
The steps below were performedwith the minimal installation CDfor NixOS version 14.12found on the NixOS Download page.
(Optional) Disable OS X disk encryption
If you’re not using FileVault for full-disk encryption,you can safely skip this step.
If you use FileVault to encrypt your disk,you will not be able to use Disk Utilityto update your disk’s partitions,which will need to be donein a later step.
Open FileVault and disable disk encryption,following the on-screen instructions.After rebooting,re-open FileVault and waitfor the disk to be fully decrypted before continuing.This will probably take a while—for me, about 30 minutes.
(Optional) Prepare Broadcom driver
Depending on your particular hardware configuration,it may be necessary to use Broadcom’s unfree drivers.You’ll need to follow the instructions belowfor any Apple laptop from the last few years.
The steps that follow are almost certainlynot the quickest or easiest wayto prepare the Broadcom driver for installation.But I had already written most of the stepsfor a future blog post,so it was something I understood how to do.
Attach your USB device,and configure two partitions in Disk Utility:
NIXOS_ISO
(600 MB), and DATA
(the rest).Each should be formatted as “MS-DOS (FAT)”.Eject the drive,but keep it plugged in.
Now in the terminal,we’re going to create a VirtualBox VM running the NixOS livecd.If you’re more comfortable with the VirtualBox GUI,you can do all of the following steps there instead.
You should be able to copy and paste the script below,remembering to set
nixos_livecd
to the path of the downloaded iso.You should now be at a login prompt in a VM window,which you can login to with root and no password.
From the menu bar,select “Devices” and thenthe name of your USB device to attach it.
Now in the VM window,mount the device:
Now we’ll install the driver:
Then we will export the driver and all of its dependencies
Finally,unmount the USB drive and shutdown the VM:
Prepare livecd
Open “Disk Utility”and change the USB partition name to
NIXOS_ISO
.![Linux For Mac Air Linux For Mac Air](/uploads/1/3/4/2/134235732/165198078.jpg)
Linux Mac Os
Mount the downloaded livecd,and then copy its contents onto the USB device.
Eject the ISO and the USB device.
Prepare partition
Open Disk Utility,click on “Macintosh HD”,add new partition,choose size (e.g., half),choose format as free space,apply.
Boot into livecd
Now reboot the machine,with the USB device inserted,and hold down the Option key.
You should be presented with three choices:“Machintosh HD”, “Recovery”, and “EFI Boot”.Select EFI Boot.
(Optional) Install Broadcom driver
Skip this if you didn’t followthe steps in “Prepare Broadcom driver”.
First,mount the USB device’s
DATA
partitionand import the Broadcom driver and dependencies.Now install the driver:
Finally, load the driver:
Create disk partitions
We will be creating two new partitionsin the free space we made in the previous step.The first will be 512MB,and be used as our Linux boot partition.The second will use the remaining free spaceand be used for our Linux swap and root partitions.
Make note of the partition numbersassigned to the partitions.You can always find them againby running
fdisk -l
and reading the device name of the last two entries,whose types should be “EFI Boot” and “Linux Filesystem”.Configure disk encryption
On OS X,the standard for disk encryption is FileVault.On Linux, it’s LUKS.
We’ll be using a strategy called LVM On LUKS,where the partition we created aboveis an encrypted LUKS partition,on top of which we’ll layer root and swap partitions with LVM.
Format partitions
And then mount them:
You can recover back to this step,by booting into the livecdand running:
Connect to wireless network
You will need a network connectionto complete your NixOS installation.The following commands will update your wireless configurationto recognize your local wireless network.
Within a few seconds,you should be connectedand a command like
ping -c 1 google.com
should be successful.Configure and install system
Start by generating a template configuration:
This will produce two files:
/mnt/etc/nixos/configuration.nix
:the system’s configuration file/mnt/etc/nixos/hardware-configuration.nix
:the system’s hardware configuration
If you followed this guide’s Broadcom instructions above,you’ll need to apply an edit to
hardware-configuration.nix
.Find the line which starts with boot.extraModulePackages
and enable the Broadcom kernel moduleby removing the surrounding quotes:Now we will need to edit
configuration.nix
to contain the minimum requirements:Also, you should ensure that the grub deviceis correct. For me, this was:
Now copy your wireless configuration:
Linux For Mac Air Keyboard Cover
And then install!
If everything goes well,
reboot
to boot into your new NixOS system!OS X final steps
When you updated the partition table with
gdisk
,the recovery disk partition lost some metadata,and shows up as “EFI Disk” instead of “Recovery”.If you go into Disk Utility,and hit “Repair” on “Macintosh HD”,that will fix this.Also, don’t forget to re-enable FileVaultif you turned it off earlier!
Where to go from here
At this point,you should be able to dual-bootinto a functional, if not particularly useful,NixOS system.
Now starts the fun part,which I’m still going through myself,of exploring Nix, NixOS, and Linuxto build your new environment.I can recommend some resourcesto help you on your way:
- NixOS Options—browser-based searchand documentation for NixOS configuration options.
man configuration.nix
—the same information as above,in your terminal.- GitHub code search—include
language:nix
in your searchto turn up other user’s configurations. - My current system and userNix configurations.
Bootable Linux For Mac
References and credits
Ubuntu Linux For Mac
- Lots of helpful people on Linux forums and StackOverflow.