<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>64k &#187; hard disk</title>
	<atom:link href="http://www.64k-tec.de/tag/hard-disk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.64k-tec.de</link>
	<description>Software development and more ...</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:58:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Installing Linux on a USB hard disk for the MacBook Pro</title>
		<link>http://www.64k-tec.de/2010/04/installing-linux-on-a-usb-hard-disk-for-the-macbook-pro/</link>
		<comments>http://www.64k-tec.de/2010/04/installing-linux-on-a-usb-hard-disk-for-the-macbook-pro/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 02:29:11 +0000</pubDate>
		<dc:creator>cp</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Root]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[Boot Camp]]></category>
		<category><![CDATA[EFI]]></category>
		<category><![CDATA[FireWire]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[hard disk]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MacBook Pro]]></category>
		<category><![CDATA[removable media]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://www.64k-tec.de/?p=885</guid>
		<description><![CDATA[One of the features of Mac OS X I love, is the possibility to install Mac OS X on any attached removable media, like a FireWire or USB hard disk. This makes it really easy for me to test VirtualBox on the several versions of Mac OS X we support (formerly Tiger, now Leopard and [...]]]></description>
			<content:encoded><![CDATA[<p>One of the features of Mac OS X I love, is the possibility to install Mac OS X on any attached removable media, like a FireWire or USB hard disk. This makes it really easy for me to test VirtualBox on the several versions of Mac OS X we support (formerly Tiger, now Leopard and Snow Leopard). The advantage of this setup is that I don't waste disk space for operation systems I usually don't use very often. Currently I have a 150GB hard disk in my MacBook Pro which is really not that much if you deal in the virtualization business. There are several test VM's of any kind of guest operation systems and of course the ISO's to install them. The second main OS, I do much of my work, is Linux. For this I have a standard PC with Gentoo on it, which have all that I need. Unfortunately this doesn't really help when I on travel. As I soon be away for some time, I decided I need, at least for testing, the same flexibility mentioned above for a Linux installation. And here the problems start to arise. Of course Apple didn't really support installing other OS's than Mac OS X on Apple hardware. Yes, there is Boot Camp, but this is mainly for Windows, is very inflexible and doesn't really help if you try to install something on another place than the integrated hard disk. There are projects like <a href="http://refit.sourceforge.net/" target="_blank">rEFIt</a>, which even makes Boot Camp superfluous, but this project has really bad USB boot support. In the following I will explain how it is even possible to install Ubuntu 9.10 on a USB hard disk.</p>
<p>The hardware used, as already said, is a MacBook Pro 3,1 and a Western Digital My Passport Essential 500GB USB hard disk. Other combination may work, but I don't guarantee this, as always. Also you should be warned that anything I describe here could destroy your existing installation and I'm not responsible for that. Doing some kind of backup might be a good idea. Time Machine is easy to use <img src='http://www.64k-tec.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Before we start, as usual, the credits for some sites I get my information from. This is mainly the <a href="http://www.produnis.de/blog/?p=678" target="_blank">Produnis blog</a>, <a href="http://blog.christophersmart.com/2009/07/23/linux-on-an-apple-xserve-efi-only-machine/" target="_blank">the Blog of Chris</a>, the <a href="https://wiki.ubuntu.com/MactelSupportTeam/CommunityHelpPages" target="_blank">Ubuntu wiki</a> and of course the guys around the <a href="http://grub.enbug.org/TestingOnMacbook" target="_blank">Grub2</a> development.</p>
<h2>Creating the EFI boot loader</h2>
<p>Apple doesn't use the legacy BIOS to boot their machines, they use the <a href="http://en.wikipedia.org/wiki/Extensible_Firmware_Interface" target="_blank"><em>Extensible Firmware Interface</em></a> (EFI). This new way of booting operation systems is very flexible, as the name suggest, but has several drawbacks, like most of the standard operation system doesn't speaks it language. Although Linux can be configured to use EFI directly we will emulate a legacy BIOS in the following. For this we need a connector which makes EFI and Linux happy and let them both work smoothly together. This connector is <a href="http://www.gnu.org/software/grub/" target="_blank">Grub2</a>, which is in development for several years now. It's the successor of Grub and is the standard in many popular Linux distributions these days. We have to build a version our self, for which an existing Linux installation is really helpful. I used my 64-bit Gentoo installation. First you have to find out if the EFI installation on your target Apple machine is 64 or 32-bit. You can do this by executing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ioreg <span style="color: #660033;">-l</span> <span style="color: #660033;">-p</span> IODeviceTree <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> firmware-abi</pre></div></div>

<p>This will return EFI64 or EFI32 respectively. In my case I need the 64-bit version, which is a little bit surprising when I consider that my MacBook Pro isn't able to boot a 64-bit Snow Leopard. Anyway, grab the <a href="ftp://alpha.gnu.org/gnu/grub/grub-1.98.tar.gz">latest version</a> of Grub2 and unpack it on the Linux machine. Please note that you need a gcc with multilib support if you are targeting an architecture which isn't the same as the host one. Use the following to configure Grub2 and to build it. Of course you have to adjust the target architecture if it is a different one.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-platform</span>=efi <span style="color: #660033;">--target</span>=x86_64 <span style="color: #660033;">--disable-werror</span>
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>When this is finished you create the EFI package by executing<a name="mkimage"></a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>grub-mkimage <span style="color: #660033;">-d</span> . <span style="color: #660033;">-o</span> bootx86.efi <span style="color: #000000; font-weight: bold;">*</span>.mod</pre></div></div>

<p>Here I included all modules which are available. If size matter for you, you could of course make a selective choice on the modules included. I didn't test this myself, so you have to find out yourself which one are important.</p>
<h2>Whipping the USB hard disk into shape</h2>
<p style="text-align: left;">Next we have to prepare the USB hard disk for the new installation. In the following I assume your USB hard disk doesn't contain any valid data and could be reformatted without data lose. Make a backup of your data first if this isn't the case on your side. Apple uses the <a href="http://en.wikipedia.org/wiki/GUID_Partition_Table" target="_blank">GUID Partition Table</a> scheme to organize their partitions on a hard disk. This specification is part of EFI and remove many limitations of the <em><a href="http://en.wikipedia.org/wiki/Master_Boot_Record" target="_blank">Master boot record</a></em> (MBR) scheme, which is widely used in the PC world. That is e.g. the disk size limitation of 2TB or the maximum of 4 primary partitions. You reformat your disk, using the Disk Utility application of Mac OS X. Make sure all existing partitions on the disk are unmounted. When necessary, change the partition scheme from MBR to GUID in the Options dialog of the Partitions window. Select the partitions count you want to use. You need at least 3 partitions to make Linux works fine. My partition scheme looks like in the following: <a href="/wordpress/wp-content/uploads/Disk-Utility.png"><img class="aligncenter size-full wp-image-972" title="GUID Partition Table scheme" src="/wordpress/wp-content/uploads/Disk-Utility.png" alt="" width="188" height="390" /></a>As you can see I have 5 partitions configured. The first one is an additional Snow Leopard installation for testing. I also added a Data partition at the end for making the data transfer between the different operation systems as easy as possibly. LINUXBOOT is a small partition which will contain the EFI boot loader (size it 50MB or something like that). Linux Swap, obviously, will become the swap partition of the Linux installation. DISK1S5 is the Linux root partition itself. The Data partition has to be formated as Mac OS Extended. Don't use the Journaled version of HFS+, cause this makes trouble on the Linux side. The other partitions have to be formatted as MS-DOS (FAT).</p>
<p>After applying the changes we can add the EFI boot loader to the LINUXBOOT partition. The Apple EFI implementation is searching for a file with the efi extensions on all bootable hard disks. Mount LINUXBOOT and create a <code class="path">efi/boot</code> directory on the root path. Copy the <a href="#mkimage">bootx86.efi</a> file into the boot/ directory. As bootx86.efi is a Grub2 boot loader we need a valid Grub2 configuration file. The following <code class="path">grub.cfg</code> shows the configuration for a Ubuntu 9.10 i386 installation. For the 64-bit version or any other version of Ubuntu the settings might be slightly different.</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">menuviewer</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;text&quot;</span>
<span style="color: #000099;">timeout</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">10</span>
<span style="color: #000099;">default</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">0</span>
set F1<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">ctrl-x</span>
menuentry <span style="color: #933;">&quot;ubuntu-9.10-desktop-i386&quot;</span>
<span style="">&#123;</span>
 fakebios
 search --set -f /boot/vmlinuz-2.6.31-<span style="">14</span>-generic
 linux /boot/vmlinuz-2.6.31-<span style="">14</span>-generic root<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">UUID=4e140981-4ab3-41a2-a2fb-26b1287beb87 ro quiet splash noefi video=efifb</span>
 initrd /boot/initrd.img-2.6.31-<span style="">14</span>-generic
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;ubuntu-9.10-desktop-i386 single&quot;</span>
<span style="">&#123;</span>
 fakebios
 search --set -f /boot/vmlinuz-2.6.31-<span style="">14</span>-generic
 linux /boot/vmlinuz-2.6.31-<span style="">14</span>-generic root<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">UUID=4e140981-4ab3-41a2-a2fb-26b1287beb87 ro noefi video=efifb single</span>
 initrd /boot/initrd.img-2.6.31-<span style="">14</span>-generic
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;ubuntu-9.10-desktop-i386 text&quot;</span>
<span style="">&#123;</span>
 fakebios
 search --set -f /boot/vmlinuz-2.6.31-<span style="">14</span>-generic
 linux /boot/vmlinuz-2.6.31-<span style="">14</span>-generic root<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">UUID=4e140981-4ab3-41a2-a2fb-26b1287beb87 ro noefi vga=normal</span>
 initrd /boot/initrd.img-2.6.31-<span style="">14</span>-generic
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;Mac OS X&quot;</span>
<span style="">&#123;</span>
 search --set -f /usr/standalone/i386/boot.efi
 chainloader /usr/standalone/i386/boot.efi
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;CD&quot;</span>
<span style="">&#123;</span>
 appleloader CD
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;mbr&quot;</span>
<span style="">&#123;</span>
 appleloader HD
<span style="">&#125;</span>
menuentry <span style="color: #933;">&quot;reboot&quot;</span>
<span style="">&#123;</span>
 reboot
<span style="">&#125;</span></pre></div></div>

<p>You have to change the root UUID to the one the Ubuntu installer will assign to your hard disk after installation. Just check the fstab file when the installation has finished. The first entry boots Linux with a splash image enabled. The second one is for the single user mode in the case something went wrong. Please note the <strong>video=efifb</strong> option, which enables the graphical mode in the boot phase.</p>
<h2>Installing Ubuntu</h2>
<p>Most of the installation process is straight forward and doesn't need any special attention. Download the version of your choice from one of the mirrors, burn it on CD and start the installation. You can select the CD as boot medium by pressing <code class="key">Alt</code> when your Mac starts. When the installer ask for the partition scheme, you have to switch to "manual choice". Select the DISK1S5 (your what it is in your case) as the root / partition and change the filesystem type to ext3. Also remember the path to the system partition, cause you will need it later again. Select the swap partition and change its type to swap. Proceed with the rest of the installation until the last dialog. There select "advanced settings" and change the boot loader target from <code class="path">hd0</code> to <code class="path">/dev/sdXX</code>, where you replace XX to the path you used previously in the partition tool.</p>
<p>If all went right you should be able to select the LINUXBOOT partition by pressing <code class="key">Alt</code> when your Mac starts. After that Grub2 should shows up, you will be able to boot into your freshly installed Ubuntu.</p>
<h2>Conclusion</h2>
<p>In this post I showed how to easily add the possibility to boot Linux on your MacBook Pro. With the external USB hard disk solution, no internal valuable space is wasted. Of course the speed isn't the same as if the OS would be installed on the internal drive, but for testing software on different operation systems this is satisfactory. To increase the speed a little bit more, an external FireWire hard disk could be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.64k-tec.de/2010/04/installing-linux-on-a-usb-hard-disk-for-the-macbook-pro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

