{"id":2830,"date":"2012-11-18T11:18:14","date_gmt":"2012-11-18T10:18:14","guid":{"rendered":"http:\/\/glandium.org\/blog\/?p=2830"},"modified":"2019-09-03T15:30:34","modified_gmt":"2019-09-03T06:30:34","slug":"debian-efi-mode-boot-on-a-macbook-pro-without-refit","status":"publish","type":"post","link":"https:\/\/glandium.org\/blog\/?p=2830","title":{"rendered":"Debian EFI mode boot on a Macbook Pro, without rEFIt"},"content":{"rendered":"<p><a href=\"http:\/\/blogs.gnome.org\/diegoe\/2012\/11\/16\/efi-mode-boot-on-macbook31-with-debian\/\">Diego's post<\/a> got me to switch from grub-pc to grub-efi to boot Debian on my Macbook Pro. But I wanted to go further: getting rid of rEFIt.<\/p>\n<p><a href=\"http:\/\/refit.sourceforge.net\/\">rEFIt<\/a> is a pretty useful piece of software, but it's essentially dead. There is the <a href=\"http:\/\/www.rodsbooks.com\/refind\/\">rEFInd fork<\/a>, which keeps it up-to-date, but it doesn't really help with <a href=\"http:\/\/support.apple.com\/kb\/HT4790\">FileVault<\/a>. Moreover, the boot sequence for a Linux distro with rEFIt\/rEFInd looks like: Apple EFI firmware \u00e2\u2020\u2019 rEFIt\/rEFInd \u00e2\u2020\u2019 GRUB \u00e2\u2020\u2019 Linux kernel. Each intermediate step adding its own timeout, so rEFIt\/rEFInd can be seen as not-so-useful intermediate step.<\/p>\n<p>Thankfully, Matthew Garrett did all the research to allow <a href=\"http:\/\/mjg59.dreamwidth.org\/12037.html\">to directly boot GRUB from the Apple EFI firmware<\/a>. Unfortunately, his blog post didn't have much actual detail on how to do it.<\/p>\n<p>So here it is, for a Debian system:<\/p>\n<ul>\n<li>Install a few packages you'll need in this process:<br \/>\n<blockquote>\n<pre># apt-get install hfsprogs icnsutils<\/pre>\n<\/blockquote>\n<\/li>\n<li>Create a small HFS+ partition. I have a 9MB one, but it's only filled by about 500K, so even smaller should work too. If, like me, you were previously using grub-pc, you probably have a GRUB partition, you can repurpose it. In <code>gdisk<\/code>, it looks like this:<br \/>\n<blockquote>\n<pre>Number  Start (sector)    End (sector)  Size       Code  Name\r\n   5       235284480       235302943   9.0 MiB     AF00  Apple HFS\/HFS+\r\n\r\nPartition GUID code: 48465300-0000-11AA-AA11-00306543ECAC (Apple HFS\/HFS+)\r\nPartition unique GUID: AD1F5465-B777-4178-AC4D-1DE8B2EB1B4B\r\nFirst sector: 235284480 (at 112.2 GiB)\r\nLast sector: 235302943 (at 112.2 GiB)\r\nPartition size: 18464 sectors (9.0 MiB)\r\nAttribute flags: 0000000000000000\r\nPartition name: 'Apple HFS\/HFS+'\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<li>Create a HFS+ filesystem on that partition:<br \/>\n<blockquote><p><code># mkfs.hfsplus \/dev\/sda5 -v Debian<\/code><\/p><\/blockquote>\n<p>(replace <code>\/dev\/sda5<\/code> with whatever your partition is)\n<\/li>\n<li>Add a <code>fstab<\/code> entry for that filesystem:<br \/>\n<blockquote>\n<pre># echo $(blkid -o export -s UUID \/dev\/sda5) \/boot\/efi auto defaults 0 0 &gt;&gt; \/etc\/fstab<\/pre>\n<\/blockquote>\n<\/li>\n<li>Mount the filesystem:<br \/>\n<blockquote>\n<pre># mkdir \/boot\/efi\r\n# mount \/boot\/efi\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<li>Edit <code>\/usr\/sbin\/grub-install<\/code>, look for \u00c2\u00ab <code>xfat<\/code> \u00c2\u00bb, and remove the block of code that looks like:<br \/>\n<blockquote>\n<pre>if test \"x$efi_fs\" = xfat; then :; else\r\n    echo \"${efidir} doesn't look like an EFI partition.\" 1>&2\r\n    efidir=\r\nfi\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<li>Run <code>grub-install<\/code>. At this point, there should be a <code>\/boot\/efi\/EFI\/debian\/grubx64.efi<\/code> file (if using <code>grub-efi-amd64<\/code>).<\/li>\n<li>Create a <code>\/boot\/efi\/System\/Library\/CoreServices<\/code> directory:<br \/>\n<blockquote>\n<pre># mkdir -p \/boot\/efi\/System\/Library\/CoreServices<\/pre>\n<\/blockquote>\n<\/li>\n<li>Create a hard link:<br \/>\n<blockquote>\n<pre># ln \/boot\/efi\/EFI\/debian\/grubx64.efi \/boot\/efi\/System\/Library\/CoreServices\/boot.efi<\/pre>\n<\/blockquote>\n<\/li>\n<li>Create a dummy <code>mach_kernel<\/code> file:<br \/>\n<blockquote>\n<pre># echo \"This file is required for booting\" &gt; \/boot\/efi\/mach_kernel<\/pre>\n<\/blockquote>\n<\/li>\n<li>Grab the <a href=\"http:\/\/www.codon.org.uk\/~mjg59\/mactel-boot\/mactel-boot-0.9.tar.bz2\"><code>mactel-boot<\/code> source code<\/a>, unpack and build it:<br \/>\n<blockquote>\n<pre># wget http:\/\/www.codon.org.uk\/~mjg59\/mactel-boot\/mactel-boot-0.9.tar.bz2\r\n# tar -jxf mactel-boot-0.9.tar.bz2\r\n# cd mactel-boot-0.9\r\n# make PRODUCTVERSION=Debian\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<li>Copy the <code>SystemVersion.plist<\/code> file:<br \/>\n<blockquote>\n<pre># cp SystemVersion.plist \/boot\/efi\/System\/Library\/CoreServices\/<\/pre>\n<\/blockquote>\n<\/li>\n<li>Bless the boot file:<br \/>\n<blockquote>\n<pre># .\/hfs-bless \/boot\/efi\/System\/Library\/CoreServices\/boot.efi<\/pre>\n<\/blockquote>\n<\/li>\n<li>(optional) Add an icon:<br \/>\n<blockquote>\n<pre># rsvg-convert -w 128 -h 128 -o \/tmp\/debian.png \/usr\/share\/reportbug\/debian-swirl.svg\r\n# png2icns \/boot\/efi\/.VolumeIcon.icns \/tmp\/debian.png\r\n# rm \/tmp\/debian.png\r\n<\/pre>\n<\/blockquote>\n<\/li>\n<\/ul>\n<p>Now, the Apple Boot Manager, shown when holding down the option key when booting the Macbook Pro, looks like this:<br \/>\n<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2012\/11\/MBP-boot-manager-with-Debian.png\" \/><\/p>\n<p>And the Startup disk preferences dialog under OSX, like this:<br \/>\n<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2012\/11\/Startup-disk-prefs.png\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Diego&#8217;s post got me to switch from grub-pc to grub-efi to boot Debian on my Macbook Pro. But I wanted to go further: getting rid of rEFIt. rEFIt is a pretty useful piece of software, but it&#8217;s essentially dead. There is the rEFInd fork, which keeps it up-to-date, but it doesn&#8217;t really help with FileVault. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,25],"tags":[23],"class_list":["post-2830","post","type-post","status-publish","format-standard","hentry","category-debian","category-planet-mozilla","tag-en"],"_links":{"self":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2830"}],"version-history":[{"count":14,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2830\/revisions"}],"predecessor-version":[{"id":2846,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2830\/revisions\/2846"}],"wp:attachment":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}