{"id":6,"date":"2015-08-28T12:34:00","date_gmt":"2015-08-28T16:34:00","guid":{"rendered":""},"modified":"2022-11-09T12:39:55","modified_gmt":"2022-11-09T16:39:55","slug":"the-one-with-more-oses","status":"publish","type":"post","link":"https:\/\/mvgrafx.net\/blog\/2015\/08\/the-one-with-more-oses\/","title":{"rendered":"The one with more OSes"},"content":{"rendered":"<p>I recently came into ownership of a 2008 unibody MacBook. One of the first aluminum ones. It&#8217;s been serving me well, and I recently replaced the unused DVD-ROM drive with a drive caddy containing a second SSD I had lying around.<\/p>\n<p>I didn&#8217;t really have a use for the space so I thought I would challenge myself to get Ubuntu Linux installed on the second drive.<\/p>\n<p>I&#8217;m going to detail my experiences here while trying to be as general about the installation and EFI boot process as possible.<\/p>\n<p>First I downloaded an Ubuntu ISO image and use hdiutl to convert it to a DMG:<\/p>\n<p><span style=\"font-family: Courier New, Courier, monospace;\">hdiutil&nbsp;convert -format UDRW -o ubuntu.img Downloads\/ubuntu-15.04-desktop-amd64.iso<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\"><br \/><\/span><span style=\"font-family: inherit;\">This will actually generate a file named&nbsp;ubuntu.img.dmg, but we&#8217;re just going to write the contents to a USB flash drive, so the name doesn&#8217;t matter.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">I then plugged in a USB flash drive and used&nbsp;<\/span><span style=\"font-family: Courier New, Courier, monospace;\">diskutil list<\/span><span style=\"font-family: inherit;\"> to determine the device path &#8211; <b>\/dev\/disk4<\/b> in my case.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Using&nbsp;diskutil again, I prepared the flash drive to accept the installer image:<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">diskutil partitionDisk \/dev\/disk4 1 &#8220;Free Space&#8221; &#8220;unused&#8221; &#8220;100%&#8221;<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Be sure to replace \/dev\/disk4 with the device path you determined in the previous step.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Finally I copied the installer to the flash drive:<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">sudo dd if=ubuntu.img.dmg of=\/dev\/disk4 bs=1m<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Again, be sure to replace \/dev\/disk4 with the correct path.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Eject the flash disk (replacing \/dev\/disk4):<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">diskutil eject \/dev\/disk4<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Now it&#8217;s time to boot the target Mac. Plug the USB drive into the Mac and hold <i>Option<\/i> while it boots.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">You should eventually see at least two boot selections. One will be a yellow USB drive icon with the label &#8220;EFI Boot&#8221;. Use the cursor keys to select it and press enter.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Now you can install Ubuntu normally. Ensure you have free,&nbsp;unpartitioned space. I was using an entirely separate drive from my OS X drive, but you need to ensure you don&#8217;t overwrite your OS X install. Also, create a small 128MB partition during the install (or from Mac OS X prior to the install) &#8211; this will hold the EFI loader.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Once Ubuntu is installed you need to create an EFI boot loader so the Mac&#8217;s firmware can boot the OS.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">You need to have GRUB2 installed to accomplish this. Here&#8217;s the command:<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">grub-mkstandalone -o boot.efi -d usr\/lib\/grub\/x86_64-efi -O x86_64-efi &#8211;compress=xz \/boot\/grub\/grub.cfg<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\"><br \/><\/span><span style=\"font-family: inherit;\">This will generate the file&nbsp;boot.efi in the current directory. You need to get&nbsp;this to the Mac side of the computer. Either copy it to another USB stick, or over the network to another system.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Now reboot back to Mac OS X.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Make sure the 128MB partition is formatted as OS X Extended Journaled.<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Open a Terminal window and navigate to the EFI partition you created, possibly something like:<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">cd \/Volumes\/Ubuntu_EFI<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: inherit;\">Create the required directory structure:<\/span><br \/><span style=\"font-family: inherit;\"><br \/><\/span><span style=\"font-family: Courier New, Courier, monospace;\">mkdir System mach_kernel<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\">cd System<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\">mkdir -p Library\/CoreServices<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\">cd Library\/CoreServices<\/span><\/p>\n<p>Copy the <b>boot.efi<\/b> we generated into this folder (CoreServices).<\/p>\n<p>Open a new text file in your favourite text editor (I prefer vim) named&nbsp;<b>SystemVersion.plist<\/b> with the following contents:<\/p>\n<p><xmp><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<\/string><\/dict><\/plist><\/xmp>If you have an icon file in .icns format, you can copy that into the root of the volume (i.e. \/Volumes\/Ubuntu_EFI)<\/p>\n<p>Finally, we need to &#8220;bless&#8221; the volume<\/p>\n<p>sudo bless &#8211;mount \/Volumes\/Ubuntu_EFI<\/p>\n<p>Also, to set a boot label other than &#8220;EFI Boot&#8221; we need to use the bless command again:<\/p>\n<p><span style=\"font-family: Courier New, Courier, monospace;\">sudo bless &#8211;folder \/Volumes\/Ubuntu_EFI -label &#8220;Ubuntu&#8221;<\/span><br \/><span style=\"font-family: Courier New, Courier, monospace;\">sudo bless &#8211;folder \/Volumes\/Ubuntu_EFI\/System\/Library\/CoreServices -label &#8220;Ubuntu&#8221;<\/span><\/p>\n<p>Substitute your own desired label for &#8220;Ubuntu&#8221;. Why do I run it twice? It takes a full reboot cycle to see if trying to set the label was successful or not. I just ran both of those together between reboots &#8211; so I have no idea which one was the one that set it. Sorry.<\/p>\n<p>So hopefully this will get you on track to getting Linux set up on your Mac if that&#8217;s you goal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently came into ownership of a 2008 unibody MacBook. One of the first aluminum ones. It&#8217;s been serving me well, and I recently replaced the unused DVD-ROM drive with a drive caddy containing a second SSD I had lying around. I didn&#8217;t really have a use for the space so I thought I would&#8230;<\/p>\n<p class=\"more-link-wrap\"><a href=\"https:\/\/mvgrafx.net\/blog\/2015\/08\/the-one-with-more-oses\/\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &ldquo;The one with more OSes&rdquo;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":1,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mvgrafx.net\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}