You are on page 1of 17

blog@ eriktrips

Erik JM Schneider

Dual Booting Crunchbang Linux and OS X Lion on a MacBook Air 4,1


[teel, dear: I usually prefer doing things the hardest way possible, especially since 'easy' usually involves a kludge of one kind or another.] For reasons that are obscure and interesting only to myself and possibly other ambivalent OS X users who may not be eager to give up their rights to use their devices the way they want to, a few weeks ago a bee entered my bonnet and refused to leave until I got one of my Macs dual-booting into one of the minimalist Linux distros. Although my eventual obsession is still unsatisedto dual boot my iMac, leaving the current OS X system alone except for trimming it down as much as possibleI did reach an intermediate goal last week: dual-booting the MacBook Air that does not hold much crucial data rst, to see how possible and how tricky such a thing might be.

I decided on crunchbang (#!) Linux ( after considering Arch ( and Slackware ( and deciding that maybe I should go with a slightly less DIY distribution so that I could keep the number of mysteries down to a manageable number at least until I knew a little more about the processes required to get an EFI-loading Mac to boot into Linux at all. I have used crunchbang for several months on a weak-willed little netbook, and it does quite well with it, or at least way better than it did under Ubuntu ( But then, Ubuntu was my First Linux, and so I did get a little carried away with all the free software and tried to install pretty much everything on that puny little netbook, until it began to freeze with every movement of the cursor or click of the mouse. But that is another story. I ended up wiping the netbook drive and putting crunchbang on it and I like using it quite a bit. crunchbang is based on Debian (, so there is a ton of support available at various ( websites and many, many pages on the internet detailing how to do almost everything. crunchbang itself has been for me a perfect intermediate Linux distro. It tends to work well out of the box on most machines, but much conguration is still done by editing cong les rather than using GUI tools, and it does not come with wizards or even much instruction on what to do once you see the desktop. However, it does give you a desktop to start with, so it might only be mildly frightening to anyone uncomfortable with the command line. To nd out how to do most things on crunchbang it is necessary to consult the internet. But the crunchbang user forums ( are notoriously friendly and I can say that I have been able to nd almost everything I have needed for day-to-day operation either there or at ( I am old, and used to reading linearly-organized manuals to nd out how things work, but this modern business of googling everything is beginning to charm me quite a bit. A hunt for information can keep me entertained all day, and discovering which search terms will get me what I want is at least half of the fun in my universe. And so I undertook to nd out a bit more about my computer than how to change my window theme. This, then, is my account of How I Did It, offered in the hope that it might be useful to others.

So the current going options for booting an EFI-based Mac into Linux appear to be three: 1. Create a hybrid Master Boot Record (MBR) ( on the EFI partition and use BIOS like in the old days; 2. Install rEFIt ( or rEFInd ( to mediate between Apples EFI boot manager and whatever bootloader one decides to use for their Linux installation. I think one can go either to EFI or BIOS from there, but either way I did not like this solution aesthetically.

3. Since aesthetics is generally my guide when there are no particularly compelling and outstanding ethical issuesand I took care of those mainly by choosing a Debian distroI followed my nose and went looking for ways to make the Apples native EFI boot manager talk directly to an EFI-enabled boot loader on the Linux side. Number three is the least straightforward way to go, but it leaves you with the most straightforward boot process. I think maybe all my years with Apple hardware have allowed a certain minimalist design fascism to take root in my brain, so I cannot stand to employ even one more component than I think I should need, and I will persevere(ate?) until either I get what I want or I cry myself to sleep from exhaustion. I try to keep this tendency of mine on a short leash, but when there are no harmful consequences to be had, it can be fun to let it dictate how I spend my time. For a little while. Well, it only took ve days, which is not that bad I guess except that I am disabled and do not have a day job and so those ve days were pretty much dedicated to eating, sleeping, visiting the bathroom, and trying to get my MacBook Air to boot into crunchbang. And feeding the cats, of course. And putting my feet up when one of them wanted a lap. And scooping out their litter boxes. And pulling together my end-of-the-month pennies to get them a couple more cans of wet food. But you sorta get the picture maybe.

Rather than detail the process from start to nish (my install log is up to 5100 words and still going and lacks a narrative arc) I am going to copy and paste the successful parts. Or the successful parts so far. So be aware of these two things: 1. This is not a procedure that I have tested all in one grand swoop yet; it is a procedure that I have worked out from my very circuitous experience. It could be tested. I considered testing it. But once I achieved my main goal of booting into crunchbang without rEFIt/rEFInd or BIOS, I could not bring myself to wipe the install and conrm the process as a procedure. But: I did wipe the Linux partition and start all over just before the install that worked, and I did approximately the same things I had done before. Until I came to those places where I needed to do something different, of course. 2. I still have some issues to resolve. I did get my right-click working the next day. My wi card is still not showing up in Network Manager but I have not looked very far for it yet. I have not optimized graphics performance. My biggest problem now is that I think the machine runs hot under crunchbang, but nding a way to get readings from the hardware sensors to see if that is really the case is proving challenging. This, then, is approximately what I expect I could do again to do it again: Back up everything interesting on the MacBook Air, of course! And after trashing a bunch of old unused les.

Create a Recovery HD image for OS X Lion on a USB key. Apple offers a software tool for this and instructions on how to use it: ( Note: my hard drive was encrypted and this interfered with the function of the Recovery HD image. Because I was in a hurry to see if I could get crunchbang to work, I unencrypted my disk and went from there. If I ever plan to leave the house with my computer again, I will look into reencrypting it.


General information about UEFI and its commercial hardware implementations: ( ( ( (

Information specic to running Linux on the MacBook family of machines: ( ( ( (

Successful EFI boot mode installs on MacBooks:

A MacBook Air 4,2 install of Debian: ( Practical link: provides concrete steps to follow

A Debian install on MacBook Air 5,1, written in both French and English: ( Not much different from the above link, but shored my belief that this could be done. Debian EFI boot mode on a Macbook Pro: ( This link showed me the light, dropped the scales from my eyes, and pointed out that the grubinstall script is a crucial component in installing grub. Heh.

All those empty spots that havent been lled in yet: ( I kept noticing that when I needed to do some intricate command line task that I really did not quite understand, Googling the subject invariably brought up links to this site. So I link the index page here. These are the pages I found most useful myself: ( Tools for partitioning disks that use a GUID Partition Table ( Which EFI bootloader do I want to use? ( Ubuntu install with rEFInd, but also good partitioning guidance


Downloaded here: (

I copied the .iso image using dd in OS X:

First show locally mounted disks to determine identier for USB key $ df -hl This shows lesystems and their names; useful if you have a bazillion devices mounted. My USB partition was /dev/disk2s1

Unmount USB partition(s) I just used Disk Utility to do this. Choose the partition in the left pane, click Unmount. Then in terminal, write the image to the unmounted partition: $ sudo dd if=crunchbang-11-20130119-amd64.iso of=/dev/disk2 bs=4194304; sync wait a little while. For me, this returned: 187+1 records in 187+1 records out 787480576 bytes transferred in 347.709451 secs (2264766 bytes/sec) Note: I originally used 4M for the bs ag in dd, ie, bs=4M But that returned bs: illegal numeric value, so I converted the gure to bytes, geekily using powers of 2 to get the fancier number. That made it happier. Note note: Commenter Johnny points out two points that make using dd a little faster and possibly less annoying ( to avoid the bs: illegal numeric value error, make that 4M (upper case M) a 4m (lower case m) unless you enjoy typing in long numbers that may or may not be elegant depending on your denition or elegance. And in fact 16m will probably work ne on most current USB keys. The other point: identifying the disk you are writing to as rdisk instead of just disk will speed things up quite a bit. That is, if you are writing to disk2, for instance, use something like of=/dev/rdisk2!. I have used this before and it is much more efcient. Something about raw disk pointers, but other than recognizing what raw and pointer mean, I dont know precisely how this works. But it does! The day it fails I will probably look it up in some greater detail.


Its partitioning, so back up everything you would cry about if you lost it. I resized my OS X partition twice without incident, but there are no guarantees!

You can resize the OS X partition using Disk Utility:

Highlight the target drive. It can in fact be your current startup drive!

Click the Partition button above the right pane. This button only appears when you have chosen the whole drive. If you have highlighted a partition, rather than the whole disk, you wont see it. Your OS X partition will be shown with a shaded portion representing existing data. If this partition has those three diagonal lines in the bottom right corner, then you can resize it. If it does not, you might have an encrypted drive. Me I had already unencrypted mine. See above. Click and drag on that corner to resize the partition. Highlighting a partition will tell you its size. Highlighting the new, emerging partition will tell you size of space you are proposing to free up. You can add however many partitions you want here, which may be a little easier than waiting until you are on the command line, where you are headed anyway. Or you can write your changes to disk without doing much more to the new partition. This is what I did: Left about 18GB data-free space on the OS X partition Chose MS_DOS(FAT) as the format for the new partition Make sure that when you click the Options button that GUID Partition Table is chosen. If you have OS X on the disk already, it should be already. I checked anyway. Several times. Name the partitions in such a way that you will remember what you were planning to do with them when you see a partition map on the terminal. Or not. Live life on the edge if you like. When you have things how you want them, click Apply. Hold your breath if you have found that this appeases the partition gods.

Using GPT fdisk tools to reliably divvy up and label your new partition(s)
As outlined at (, the GPT fdisk tools will create partitions on GPT disks such that the partition boundaries will line up properly with the data boundaries on the disk. This is better, but if you need more precise reasons to do this and they are not already clear in any of the above links, bug me and I will try to nd the relevant links in my browser history. A link to download GPT fdisk tools is here: ( They will install and run on Linux, FreeBSD, Mac OS X, and Windows. gdisk and cgdisk are similar. I used both of them at different times, but prefer cgdisk. If you need your hand held a bit more tightly or need protection from yourself when trying to destroy hard drive data, it may feel more comfortable than gdisk. I like cgdisk because it displays all of the commonly-used commands in a menu at the bottom of the screen, and that helps me not to have to keep calling up a command list because my short-term memory gave out long ago and to me delete and erase are not distinct but only one of them will do anything in gdisk or cgdisk.

You can nd an outstanding guide to using cgdisk by visiting ( Its awless. Just follow the instructions; they are way better than anything I would try to write here. For reference, this is what my screen displayed just before I told cgdisk to write my changes to disk:

Part. # Size Partition Type Partition Name ---------------------------------------------------------------3.0 KiB free space 1 200.0 MiB EFI System EFI system partition 2 83.6 GiB Apple HFS/HFS+ littleBlackHat 3 619.9 MiB Apple boot Recovery HD 128.0 MiB free space 5 8.0 GiB Linux filesystem linux 128.0 MiB free space 6 20.4 GiB Microsoft basic data share

As you can see, I left 128MB of space around the new partitions. It is said by many that Apple hardware really likes it when you do this, but I did note that Apple themselves left no space between their partitions. Nonetheless, as a gesture to the Apple gods, I put those spaces in, because I was tired of googling for accurate info and gured I could sacrice the space for good luck. The EFI partition and the Apple partitions were already there. Leaving them alone is the best way to not disturb them.


The main idea here is to install crunchbang without installing the version of grub that the installer will choose for you. After that, I boot up from the LiveUSB image and then chroot into my new system and install grub-e-amd64. Then comes some fancy footwork on the command line that will place an .e target on the existing system EFI partition so that it appears as a startup disk choice when you boot with the Option key held down. That is basically what is going on here: ( but I changed a few things and actually forgot some steps but it worked anyway so I did not have to go through all this one more time. I will detail what I did. I may or may not know precisely why or how any particular step works the way it does, but I have many more hunches now than I did last week at this time, so feel free to ask!

Onward! Power off MacBook Air Insert USB with #! Waldorf image ["#!LiveUSB" is what I am calling it] While holding down the Option key, press the Power button After a few seconds, you will see a screen that offers you a choice of what system to boot. Mine labeled the #!LiveUSB as Windows and its icon was a generic yellow USB drive icon. I was also offered my existing OS X system and the Recovery HD, which exists to help you to reinstall OS X Lion if something gets borked. I chose Windows even though normally I would not. You can also connect to your wireless network while on this screen, but my MacBook Air has never played will with my Netgear wireless router, and I guess they werent speaking to each other just then, because the little wheel kept spinning but I was never able to connect. So I plugged in a USB to Ethernet adapter when I needed internet outside of OS X. When the crunchbang Live menu appearsas it has for me perfectly everytime I have booted the #!LiveUSBchoose Install. Note: the trackpad did not work throughout the Install process, but: Arrow keys will move the cursor through possible choices Esc will go back to the last screen Enter aka Return will accept whatever changes you made on that screen and advance to the next. Follow the prompts (language, keyboard, hostnamethese you can set however you want) until you reach the screen where it asks you about choosing and partitioning your disk drive. Choose Manual If you have not manually partitioned a for a Linux install before, this can look a little intimidating, but if you got through the cgdisk procedures, you will do ne. These are very similar. Also, as with cgdisk, you can ddle with your partitioning scheme for days if you want. All your changes are stored; nothing happens to your disk until you tell the installer to go ahead and write the partitions, and it gives you fair warning. I put the whole crunchbang installation on one 8GB partition to keep things simple and so setting up my partitions was also relatively simple: Choose 8GB partition Mount as: / [root, in other words] Format: ext4 Bootable: Yes Name: someCoolName I did not create a swap partition after having read repeatedly that with 4GB or more of RAM it is not necessary. And it is also written that solid state hard drives do weird stuff with swap partitions.

If you do not create a swap partition, the installer will ask if you meant to do that and prompt you to go back to the partitioning menu. You may politely turn it down and move on. Once you have allowed the installer to write your partitions to disk, you can continue until it asks you where to install the grub boot loader. It does not immediately give you the choice not to install it at all, but if you press Esc it will take you to a scrolling menu of install steps. Skip over those having to do with any sort of boot loader, then choose the following step and press Enter. Unfortunately, I cannot nd in my notes what step is next on the list, but all I knew then was that I wanted to skip the boot loader installation, and it was clear at the time how to do that. Then just nish up the installation according to your own lights, and then shut down to proceed.


This is the tricky part, but also the fun part. I installed grub-e-amd64_1.99-27 after downloading the necessary .deb les directly from a Debian package mirror. ( Otherwise, crunchbang will try to install an earlier version, and since this package is still evolving, I wanted the latest I could get. The earlier version might work for all I know, but somewhere in the middle of multiple failures I decided to grab the newest one and so that is what I worked with from that point on. grub-e-amd64_1.99-27 is mostly installation scripts as far as I can tell, and it depends on several packages that will not be installed on crunchbang by default, so I downloaded those, too. The dependency chainand thus install orderis: ebootmgr [not kfreebsd-amd64] grub-common (= 1.99-27) grub-e-amd64-bin (= 1.99-27) grub2-common (= 1.99-27) grub-e-amd64 (= 1.99-27) I put those on a FAT-32 USB stick. Mounting it was also tricky but fun. But rst:

Boot into #!LiveUSB to modify your new crunchbang system

With #!LiveUSB inserted, hold Option while powering up. Choose the #!LiveUSB (Windows, in my case) as startup disk. Choose Live Session from menu.

You will need internet for the rst bit of work, so plug ethernet in if that is where your internet comes from. You start inside the #!LiveUSB system, but you want to work in your newly installed system. chroot can help you with this. I have cribbed this procedure from xaos52!s most excellent post: ( I reproduce parts of it here for some small convenience. You rst need to look for the location of your new crunchbang install. You can open GParted to see this easily, or you can deduce it by thumbing through: $ ls /dev If you open GParted, it is a good idea to note where the system EFI partition is, too. Most likely it will be sda1, but computers are devious beasts! Once you know, you can

Use chroot to work from inside your new crunchbang install:

Prepare the target. A number of directories in the system you booted into need to be forwarded to your new crunchbang install in order for it to function correctly after you have chrooted into it. You will also be working as root for some time, so have your wits about you to whatever extent your existing data is important to you. Remember also to replace the [x]brackets and allin sda[x] with the correct number for your new system partitioni.e., /media/sda5 if you installed to sda5. $ # # # # # # # # sudo su TARGET=/media/sda[x] mkdir -p $TARGET mount /dev/sda[x] $TARGET mount --bind /dev $TARGET/dev mount --bind /dev/pts $TARGET/dev/pts mount --bind /proc $TARGET/proc mount --bind /sys $TARGET/sys cp /etc/resolv.conf $TARGET/etc/

Then chroot into your new system: chroot $TARGET /bin/bash From here, my procedure is synthesized using the ideas at ( and (

Some of the instructions are lifted directly from one or the other of them, and it is worth looking over what they each do to get an idea of what you might need to do.

Update, upgrade, and install a couple of utilities

Since you are now inside your new installation of crunchbang, and its root directory is your working root directory, it is a good time to # apt-get update # apt-get upgrade These will also help you with setting up your .e target: # apt-get install hfsprogs icnsutils

Mount the USB key with grub-e-amd64 packages inside of the new system
Make a place to mount the USB holding the grub packages: # mkdir -p /target/usb Now you need to go back to the #!LiveUSB system to fetch the USB: Control-D Drops you back out of chroot. Mount the USB stick inside your new system (mine is called rentMe; replace that with whatever name of yours shows up in /media with: $ ls /media) :

# mount --bind /media/rentMe/ /media/sda5/target/usb Return to your new install: # chroot $TARGET /bin/bash

Mount the system EFI partition inside your new system and install grube-amd64

An fstab entry for the system EFI partition will help with mounting it later: # echo $(blkid -o export -s UUID /dev/sda1) /boot/efi auto defaults 0 0 >> /etc/fstab Then mount it: # mkdir /boot/efi # mount /boot/efi Tell your kernel what the EFI variables are: # modprobe efivars This gave me the error efivars: Unknown symbol efi_enabled_facility (err 0) but still seemed to work ok. If you skip this step, the install of grub-e-amd64 could fail. Install grub-e-amd64 from /target/usb in depency chain order: # dpkg ... # dpkg ... # dpkg ... # dpkg ... # dpkg --install /target/usb/efibootmgr_0.5.4-3_amd64.deb --install /target/usb/grub-common_1.99-27_amd64.deb --install /target/usb/grub-efi-amd64-bin_1.99-27_amd64.deb --install /target/usb/grub2-common_1.99-27_amd64.deb --install /target/usb/grub-efi-amd64_1.99-27_amd64.deb

Edit /usr/sbin/grub-install: Look for xfat and remove the block of code that looks like:

if test "x$efi_fs" = xfat; then :; else echo "${efidir} doesn't look like an EFI partition." 1>&2 efidir= fi

Run grub-install: # /usr/sbin/grub-install

Now copy /boot/e/EFI/debian/grubx64.e to a spot where the system EFI will nd it: # mkdir -p /boot/efi/System/Library/CoreServices # cp /boot/efi/EFI/debian/grubx64.efi /boot/efi/System/Library/CoreServices/boot.efi

Consider the consequences of trusting the wisdom of fools

This is where ( details steps to bless the boot.e le, but I was so excited to see grubx64.e actually appear where it was said to appearI had been looking for it in vain for over 48 hoursI skipped right past them and backed out of the fresh install to the LiveUSB, shut down and rebooted. I only realized I had done this after I was booted into my new, working MacBook Air crunchbang system! At least one other person has commented on that page that no blessing is needed, so I dunno if it does something crucial that I am missing, or not. If you have not yet looked at that page, now might be a very good moment to take a break and then visit ( p=2830) to decide for yourself whether you want to rely on my dumb luck. You can also stop and put a distinctive icon on the EFI target if you dont want to see a generic hard drive icon:

# rsvg-convert -w 128 -h 128 -o /tmp/icon.png /usr/share/icons/gnome/sc [or /path/to/some/other/i # png2icns /boot/efi/.VolumeIcon.icns /tmp/debian.png # rm /tmp/debian.png

Back out to the #!LiveUSB and unmount everything you mounted however long ago it was:
Un-chroot: Command-D Checking the value of $TARGET is a good idea: # $TARGET If it is still assigned /media/sda[x], then # umount -l $TARGET/dev/pts

# umount -l $TARGET/dev # umount -l $TARGET/sys # umount -l $TARGET/proc And also # umount -l $TARGET/target/usb Now you can shut down the #!LiveUSB session and shut down. Praying to whatever beings you nd to be congenial to technological issues certainly cannot hurt.

If all went well and the wind is from the west and the moon either waxing or full you should be able to remove the #!LiveUSB now and boot into the crunchbang system on your hard drive. To do this you will still need to hold the Option key down while booting. This takes you to the EFI boot managers startup disk menu; otherwise you will boot directly into OS X. My crunchbang system shows up on that menu as EFI boot; if you put a custom icon on it before restarting, that should also appear, rather than OS Xs generic hard drive icon. Choose it, hit Enter, and look on breathlessly as crunchbang Linux puts itself together on your Mac. The crunchbang welcome script will lead you through a few more steps to customize your install. The only difference is that updating your repository locations and then upgrading your system should not take very long at all, since you already did that before installing the grub EFI bootloader. One more caveat: when I try to do a system-wide upgrade using apt-get, it defaults to trying to DOWNGRADE grub-e-amd64. Just be aware of that. There is at least one way to tell it not do that, but I have not yet investigated it, or any others, to the point that I am comfortable upgrading with apt-get. Synaptic is installed by default in crunchbang, though, and allows you to control exactly what gets installed by checking and un-checking boxes, so for now I am using that to get packages needed to tweak my installation. That is all for now! Hope this was useful in some way!

8 thoughts on Dual Booting Crunchbang Linux and OS X Lion on a MacBook Air 4,1

1. marek says: 2013/05/20 at 11:33 could you write a little bit about battery life and general working/not working things Reply eriktrips says: 2013/05/23 at 08:08 hi marek, Later today I will put up a brief overview of the main problems so far, of which overheating and fan control seem the most serious to me. I have not taken it for a battery test-drive yet. I have always carried around power cords for Macs of the bookish sort anyway, since they dont ever seem to have enough life for a full day away from home even when brand new! But I will put that on the list of things to try if I can get the heat down to a level where I can work in crunchbang for a solid stretch. Reply 2. Chris says: 2013/06/23 at 04:58 Great write-up! After following these steps, the EFI boot worked but my grub menu had no entries. I ended up going back into the chroot and running `update-grub` to have /boot/grub/grub.cfg created. Reply 3. Johnny says: 2013/11/14 at 04:24 Fabulous write-up! Im glad I was not alone in my frustrations of chaining boot loaders and solutions together when everything pointed at a much cleaner solution. While I admire your geekily solution to the bs: illegal numeric value for dd on OSX, having seen this many times I can conrm it is simply a case issue with the M, therefore: bs=4m will work, while bs=4M will not. Go gure Also, using the raw disk pointer /dev/rdiskN rather than simply /dev/diskN speeds things up a great deal, and for most most USB drives nowadays, going up to bs=16m combined with rdisk will just y through your image write. Reply eriktrips says: 2013/11/14 at 13:42 Hi Johnny, I am glad you found this usefulor entertaining, or nice-looking, or whatever else fabulosity might entail. :) Now that you mention it, I think I did once mistakenly type a small m and thought oh shit and then watched as the disk went and wrote itself quite nicely. I was just writing to an SD card last night (raspberry pi for fun and distraction!) and paused for a moment because I thought I had seen M work before but couldnt recall how so just used my 4millionsomethinginpowersoftwo number. Thanks for mentioning the rdisk trick. Yes it is much faster. I may not have known about it yet in April. I did pick it up somewhere (later on?) but it hadnt occurred to me to amend this post.

Reply 4. Stephen Lang (@skl_) says: 2013/12/08 at 12:45 Thank you for this guide! All went well except booting into the #! Live USB system (which booting but nothing would launch). I ended up burning a Knoppix 7.2 DVD and running that with knoppix64! boot ags in order to chroot. FYI the Knoppix CD is 32bit only so be sure to download the DVD for 64bit. Wi- doesnt work out of the box with Broadcom BCM43224 chipset, investigating now. Thanks again for the write up. Reply eriktrips says: 2013/12/08 at 13:12 Youre welcome! Thanks for letting us know what worked and what did not. I have never worked with Knoppix but would be interested to know how your experiment turns out. Since it is Debian-based as well, there may be something in my one single lone follow-up post that might be of value. If I recall correctly, I downloaded a couple of likely-looking drivers and the rst one worked easy as pie! Best of luck. And skill and hard work, of course. :) Reply Stephen Lang (@skl_) says: 2013/12/22 at 12:01 Looks like we arrived at the same solution for the WiFi, thanks for the link to the followup. Ive written up what I did after following your post here: Reply

Blog at | Customized Sunspot Theme. Follow

Follow blog@ eriktrips

Powered by