Agenda: install-ubuntu-mac-mini.htm

File install-ubuntu-mac-mini.htm, 18.7 KB (added by admin, 5 years ago)
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5  <meta http-equiv="Content-Style-Type" content="text/css" />
6  <meta name="generator" content="pandoc" />
7  <title>Installation of Ubuntu on Mac Mini</title>
8  <style type="text/css">code{white-space: pre;}</style>
9  <link rel="stylesheet" href="../../style.css" type="text/css" />
10</head>
11<body>
12<div id="header">
13<h1 class="title">Installation of Ubuntu on Mac Mini</h1>
14</div>
15<div id="TOC">
16<ul>
17<li><a href="#overview"><span class="toc-section-number">1</span> Overview</a><ul>
18<li><a href="#mac-mini-versions"><span class="toc-section-number">1.1</span> Mac Mini versions</a></li>
19<li><a href="#items-required"><span class="toc-section-number">1.2</span> Items required</a></li>
20</ul></li>
21<li><a href="#preparing-the-install-image"><span class="toc-section-number">2</span> Preparing the install image</a></li>
22<li><a href="#installation"><span class="toc-section-number">3</span> Installation</a></li>
23<li><a href="#login-after-reboot"><span class="toc-section-number">4</span> Login after reboot</a><ul>
24<li><a href="#format-the-second-hard-drive"><span class="toc-section-number">4.1</span> Format the second hard drive</a></li>
25<li><a href="#configure-the-internal-network-interface"><span class="toc-section-number">4.2</span> Configure the internal network interface</a></li>
26<li><a href="#update-all-packages"><span class="toc-section-number">4.3</span> Update all packages</a></li>
27</ul></li>
28<li><a href="#troubleshooting-post-installation-problems"><span class="toc-section-number">5</span> Troubleshooting post installation problems</a><ul>
29<li><a href="#your-mac-does-not-boot"><span class="toc-section-number">5.1</span> Your Mac does not boot</a></li>
30<li><a href="#problems-with-video"><span class="toc-section-number">5.2</span> Problems with video</a></li>
31</ul></li>
32<li><a href="#installing-on-older-macminis"><span class="toc-section-number">6</span> Installing on older MacMinis</a><ul>
33<li><a href="#boot-using-mac-os-x-install-cd"><span class="toc-section-number">6.1</span> Boot using Mac OS X install CD</a></li>
34<li><a href="#wipe-out-all-partitions"><span class="toc-section-number">6.2</span> Wipe out all partitions</a></li>
35<li><a href="#get-the-right-ubuntu-install-cd"><span class="toc-section-number">6.3</span> Get the right Ubuntu install CD</a></li>
36<li><a href="#install-ubuntu"><span class="toc-section-number">6.4</span> Install Ubuntu</a></li>
37<li><a href="#edit-grub-defaults"><span class="toc-section-number">6.5</span> Edit grub defaults</a></li>
38<li><a href="#convert-into-server"><span class="toc-section-number">6.6</span> Convert into server</a></li>
39</ul></li>
40</ul>
41</div>
42<h1 id="overview"><a href="#overview"><span class="header-section-number">1</span> Overview</a></h1>
43<p>These notes describe the installation of Ubuntu 12.04.3 on a Mac Mini. This is the most powerful server we have found for its size, especially considering that the PSU is internal.</p>
44<h2 id="mac-mini-versions"><a href="#mac-mini-versions"><span class="header-section-number">1.1</span> Mac Mini versions</a></h2>
45<p>The recommended configuration of a workshop server is:</p>
46<ul>
47<li>Quad-core i7 (&quot;server&quot; version)</li>
48<li>16GB RAM</li>
49<li>Two 250GB SSDs (e.g. OCZ Vertex 4)</li>
50</ul>
51<p>These instructions have been tested on the following models:</p>
52<ul>
53<li>Mid 2011 (Macmini5,3)</li>
54<li>Mid 2013 (Macmini6,2)</li>
55</ul>
56<p>When you have Linux running, you can determine your model using</p>
57<pre><code>sudo dmidecode -s system-product-name</code></pre>
58<p>For more information on the different models of Mac Mini see:</p>
59<ul>
60<li><a href="https://support.apple.com/kb/HT3476">https://support.apple.com/kb/HT3476</a></li>
61<li><a href="https://en.wikipedia.org/wiki/Mac_Mini">https://en.wikipedia.org/wiki/Mac_Mini</a></li>
62</ul>
63<h2 id="items-required"><a href="#items-required"><span class="header-section-number">1.2</span> Items required</a></h2>
64<p>For installation only, you will need:</p>
65<ul>
66<li>A mini-displayport to VGA adapter, or a mini-displayport to DVI adapter and a DVI-to-DVI or DVI-to-HDMI cable</li>
67<li>A monitor</li>
68<li>A USB keyboard</li>
69<li>A 1GB+ USB flash drive or a USB CD-R drive</li>
70</ul>
71<p>We also recommend an Apple USB to Ethernet adapter for the external Internet connection. This leaves the internal gigabit Ethernet port available for the lab internal network and avoids having to trunk VLANs; it also helps if you have a newer Mac Mini where the internal ethernet adapter is not supported in the default kernel.</p>
72<h1 id="preparing-the-install-image"><a href="#preparing-the-install-image"><span class="header-section-number">2</span> Preparing the install image</a></h1>
73<p>First you need to choose which ISO image to use and download it. Start with the standard 64-bit server edition (ubuntu-12.04.3-server-amd64.iso) which should work fine with recent Mac Minis.</p>
74<p>If you have problems booting, then try one of the amd64+mac<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> variants from the <a href="http://www.ubuntu.com/download/alternative-downloads">alternative downloads</a> page:</p>
75<ul>
76<li>ubuntu-12.04.3-alternate-amd64+mac.iso</li>
77<li>ubuntu-12.04.3-desktop-amd64+mac.iso</li>
78</ul>
79<p>However you would then end up installing a desktop version.</p>
80<p>You may burn the image onto a CD-R if you have a USB CD-ROM drive to boot from, such as the Apple Superdrive.</p>
81<p>Otherwise, to write the image to a USB stick you need use a Mac which is running OSX and follow <a href="http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx">these instructions</a></p>
82<pre><code>hdiutil convert -format UDRW -o ubuntu-12.04.3-server-amd64.img ubuntu-12.04.3-server-amd64.iso
83# Note: the output filename may be .img.dmg
84diskutil list   # note the devices seen
85# insert flash drive
86diskutil list   # note the new device seen, e.g. /dev/disk2
87diskutil unmountDisk /dev/diskN
88sudo dd if=ubuntu-12.04.3-server-amd64.img.dmg of=/dev/rdiskN bs=1m
89diskutil eject /dev/diskN
90# remove flash drive</code></pre>
91<h1 id="installation"><a href="#installation"><span class="header-section-number">3</span> Installation</a></h1>
92<p>Insert the CD-ROM or flash disk into the Mac Mini, and connect the keyboard and screen. Connect ethernet uplink - using the USB-to-ethernet adapter if you have one.</p>
93<p>Power on and hold the alt/option key while it is starting. You may get a choice of boot icons - the USB key will be &quot;EFI boot&quot;.</p>
94<p>After this you should get a menu of Ubuntu options:</p>
95<pre><code>Install Ubuntu Server
96Install in expert mode
97Multiple server install with MAAS
98Check disc for defects
99Rescue a broken system</code></pre>
100<p>Select &quot;Install Ubuntu Server&quot; and proceed as normal, choosing country, language and keyboard layout.</p>
101<p>If you are using the USB-to-ethernet adapter for your external Internet connection, then you will be prompted for the primary network interface:</p>
102<pre><code>eth0: Broadcom Corporation NetXtreme BCM57765 Gigabit Ethernet PCIe
103eth1: Ethernet</code></pre>
104<p>Choose the one which is your ethernet uplink (i.e. eth1)</p>
105<ul>
106<li>When you see &quot;Configuring network with DHCP&quot; press ENTER to cancel. Do this quickly!</li>
107<li>Press &quot;Continue&quot; on the Network autoconfiguration failed screen.</li>
108<li><p>Select &quot;Do not configure the network at this time&quot;</p></li>
109<li>Hostname: s1</li>
110<li>Full name for the new user: NSRC instructor</li>
111<li>Username: nsrc</li>
112<li>(Use a suitable instructor password)</li>
113<li>Encrypt your home directory? No</li>
114<li>Select timezone. If you are going to be travelling around the world you should not accept the local timezone, and instead scroll down to &quot;UTC&quot; at the very end of the worldwide list.</li>
115<li>Partitioning:
116<ul>
117<li>Guided - use entire disk</li>
118<li>&quot;Select disk to partition&quot; SCSI1 (0,0,0) sda</li>
119<li>&quot;Write changes to disk&quot; Yes.</li>
120</ul></li>
121<li>Use HTTP proxy? leave blank</li>
122<li>No automatic updates (you don't want changes in the middle of a workshop)</li>
123<li>Software to install: select only &quot;OpenSSH server&quot;</li>
124<li><p>Installation is complete: hit Enter, then unplug CD-ROM or USB stick.</p></li>
125</ul>
126<h1 id="login-after-reboot"><a href="#login-after-reboot"><span class="header-section-number">4</span> Login after reboot</a></h1>
127<p>Your Mac should be up and running - login as user <code>nsrc</code>.</p>
128<p>Use <code>ifconfig -a</code> to find its external IP address, and you should be able to ssh into it from outside. Then you no longer need the keyboard and monitor.</p>
129<p>Hint: also take a note of the MAC address of the USB-ethernet adapter, and label it. It helps when locating the machine without a monitor.</p>
130<h2 id="format-the-second-hard-drive"><a href="#format-the-second-hard-drive"><span class="header-section-number">4.1</span> Format the second hard drive</a></h2>
131<p>The secondary hard drive needs to be partitioned and formatted so it can be used for storing half of the VM disk images.</p>
132<pre><code>sudo su - (type the nsrc account password)
133parted -s -a optimal /dev/sdb mklabel gpt -- mkpart primary ext4 1 -1
134mkfs.ext4 /dev/sdb1
135mkdir /data
136edit /etc/fstab
137    /dev/sdb1   /data   ext4    defaults    0   2
138mount /data</code></pre>
139<p>Now let's see that we actually have the second disk available to us under the /data partition:</p>
140<pre><code>df -h</code></pre>
141<p>You should see something like:</p>
142<pre><code>Filesystem      Size  Used Avail Use% Mounted on
143/dev/sda2       215G  1.5G  202G   1% /
144udev            7.8G  4.0K  7.8G   1% /dev
145tmpfs           3.2G  376K  3.2G   1% /run
146none            5.0M     0  5.0M   0% /run/lock
147none            7.8G     0  7.8G   0% /run/shm
148/dev/sda1        93M  2.1M   91M   3% /boot/efi
149/dev/sdb1       230G   60M  219G   1% /data</code></pre>
150<p>Note that /data is mounted on /dev/sdb1, or the second hard drive in your MacMini</p>
151<h2 id="configure-the-internal-network-interface"><a href="#configure-the-internal-network-interface"><span class="header-section-number">4.2</span> Configure the internal network interface</a></h2>
152<p>We purposely did not configure our network interfaces during installation so that the installation would go faster and we could configure out interfaces as we want now. You can see that neither eth0 or eth1 are configured by doing:</p>
153<pre><code>ifconfig</code></pre>
154<p>To fix this, as root, at the command line prompt type:</p>
155<pre><code>edit /etc/network/interfaces</code></pre>
156<p>Make sure the file looks like this:</p>
157<pre><code># This file describes the network interfaces available on your system
158# and how to activate them. For more information, see interfaces(5).
159
160# The loopback network interface
161auto lo
162iface lo inet loopback
163
164auto eth0
165# eth0 internal network interface
166iface eth0 inet static
167        address 10.10.0.241
168        netmask 255.255.255.0
169
170auto eth1
171# eth1 external, public network interface
172iface eth1 inet dhcp</code></pre>
173<p>Now to bring up both interfaces with their new configurations do:</p>
174<pre><code>ifup eth0
175ifup eth1</code></pre>
176<p>Wait a few seconds for the script to complete then type:</p>
177<pre><code>ifconfig</code></pre>
178<p>to see that your network is now configured. Trying pinging some external sites to verify that your network is working.</p>
179<h2 id="update-all-packages"><a href="#update-all-packages"><span class="header-section-number">4.3</span> Update all packages</a></h2>
180<p>Now that our base operating system is installed we need to pull down a list of current versions of available packages and then download and install the packages.</p>
181<p>Let's first see what version of the Linux kernel we are running:</p>
182<pre><code>uname -a</code></pre>
183<p>Remember this and see if you have a newer kernel version once we are finished with this exercise. To update apt and then packages that need updating do:</p>
184<pre><code>sudo apt-get update
185sudo apt-get dist-upgrade</code></pre>
186<p>Say &quot;Yes&quot; to downloading and installing the new packages.</p>
187<p>This could take some time as a considerable amount of information is going to be downloaded. While this is happening we will go on to the next set of configuration items for your workshop kit which includes configuring your switch and access point.</p>
188<p>When your machine finishes with the apt-get update and the apt-get dist-upgrade processes you will likely have a new kernel image. This is one of the few times you need to reboot Linux to see change. To do this do:</p>
189<pre><code>sudo shutdown -r now</code></pre>
190<p>Wait for the MacMini to restart and log back in as the user nsrc, then type:</p>
191<pre><code>uname -a</code></pre>
192<p>To see the version of the Linux kernel that you are running. Is it different from what you had before running &quot;apt-get update&quot; and &quot;apt-get dist-upgrade&quot;?</p>
193<p>At this point your MacMini is ready and in its initial state. We'll be updating your MacMini environment using a tool called Ansible a bit later.</p>
194<p>Assuming your network interfaces are properly configured you can now remove the monitor and keyboard attached to your MacMini and connect to it using ssh instead.</p>
195<h1 id="troubleshooting-post-installation-problems"><a href="#troubleshooting-post-installation-problems"><span class="header-section-number">5</span> Troubleshooting post installation problems</a></h1>
196<h2 id="your-mac-does-not-boot"><a href="#your-mac-does-not-boot"><span class="header-section-number">5.1</span> Your Mac does not boot</a></h2>
197<p>If this is the first time you are installing Linux on your MacMini it's possible that the Linux installer will not set the boot order correctly. Your Mac may be set to boot Mac OS X, but this is no longer available. To correct this you need to do:</p>
198<ul>
199<li>Connect a current Ubuntu version installation media, such as an Ubuntu 12.0.4.3 LTS USB disk.</li>
200<li>Start your MacMini and hold down the option key until you see an option to boot as &quot;EFI Boot&quot;</li>
201<li>Select &quot;EFI Boot&quot; and when presented with the Ubuntu Install screen select &quot;Rescue a broken system&quot;</li>
202<li>You are now asked to run through the initial stages of the Ubuntu installation.</li>
203<li>Select keyboard, country, set hostname and time zone. Note that you can just use all defaults as none of these items will be saved.</li>
204<li>When you see the screen for &quot;Device to use as root file system:&quot; select /dev/sda2</li>
205<li>Select &quot;Execute a shell in /dev/sda2&quot; and select &quot;Continue&quot;</li>
206</ul>
207<p>At the bottom of your screen you will see the &quot;#&quot; command prompt. You are now in a rescue Linux shell where we can set some hardware options. You can type:</p>
208<pre><code>efibootmgr</code></pre>
209<p>You'll probably see MacOS X listed as the BootCurrent item (0080). We want the Ubuntu entry to become the BootCurrent item. To do this type:</p>
210<pre><code>efibootmgr -o 00</code></pre>
211<p>And, that's it.</p>
212<ul>
213<li>Type &quot;exit&quot; to leave the rescue shell</li>
214<li>Select &quot;Reboot the system&quot; and remove the USB key.</li>
215</ul>
216<p>Your MacMini should now boot. It may pause for a moment with the white screen, but give it a few seconds to complete booting.</p>
217<h2 id="problems-with-video"><a href="#problems-with-video"><span class="header-section-number">5.2</span> Problems with video</a></h2>
218<p>If the attached monitor displays the grub prompt but then goes blank after booting, your monitor may not support the default resolution. If this happens, try booting with parameter &quot;nomodeset&quot;.</p>
219<ul>
220<li>Hit any key at the grub menu to stop booting</li>
221<li>Hit 'e' to edit</li>
222<li>Go to the end of the &quot;linux ...&quot; line, and add <code>nomodeset</code> to the end</li>
223<li>Ctrl-X or F10 to continue booting</li>
224</ul>
225<p>Then to make this change permanent:</p>
226<pre><code># vi /etc/default/grub
227GRUB_CMDLINE_LINUX_DEFAULT=&quot;nomodeset&quot;
228
229# update-grub</code></pre>
230<h1 id="installing-on-older-macminis"><a href="#installing-on-older-macminis"><span class="header-section-number">6</span> Installing on older MacMinis</a></h1>
231<p>The following instructions were from previous tests with a Macmini4,1 and are kept in case they help debugging problems on older machines.</p>
232<h2 id="boot-using-mac-os-x-install-cd"><a href="#boot-using-mac-os-x-install-cd"><span class="header-section-number">6.1</span> Boot using Mac OS X install CD</a></h2>
233<h2 id="wipe-out-all-partitions"><a href="#wipe-out-all-partitions"><span class="header-section-number">6.2</span> Wipe out all partitions</a></h2>
234<p>It's probably safer to wipe out the existing Mac OS X and Linux partitions, which should also get rid of rEFIt. That way we make sure that rEFIt is not changing how Linux views the system.</p>
235<ul>
236<li>Use Disk Utility to remove all partitions on both drives</li>
237</ul>
238<h2 id="get-the-right-ubuntu-install-cd"><a href="#get-the-right-ubuntu-install-cd"><span class="header-section-number">6.3</span> Get the right Ubuntu install CD</a></h2>
239<p>The image used successfully was the alternate-amd64+mac.iso image</p>
240<p>The problem is that this installs all the desktop GUI crap, which must be removed after installation.</p>
241<h2 id="install-ubuntu"><a href="#install-ubuntu"><span class="header-section-number">6.4</span> Install Ubuntu</a></h2>
242<ul>
243<li>Boot from CD</li>
244<li>Press F6 and select:
245<ul>
246<li>acpi=off</li>
247<li>nomodeset</li>
248</ul></li>
249<li>Continue as above, including same partitioning scheme</li>
250<li>Reboot</li>
251</ul>
252<h2 id="edit-grub-defaults"><a href="#edit-grub-defaults"><span class="header-section-number">6.5</span> Edit grub defaults</a></h2>
253<pre><code># vi /etc/default/grub
254
255GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet&quot;
256GRUB_CMDLINE_LINUX=”noacpi nomodeset reboot=acpi”</code></pre>
257<p>Disable lightdm (replacement for gdm):</p>
258<pre><code>echo &#39;manual&#39; | sudo tee /etc/init/lightdm.override</code></pre>
259<p>Then:</p>
260<pre><code># update-grub</code></pre>
261<h2 id="convert-into-server"><a href="#convert-into-server"><span class="header-section-number">6.6</span> Convert into server</a></h2>
262<p>Remove all the desktop-related packages:</p>
263<pre><code># apt-get --purge remove &#39;gnome-*&#39; xerver-xorg</code></pre>
264<p>And install the right kernel:</p>
265<pre><code># apt-get install linux-headers-server linux-image-server linux-server</code></pre>
266<p>All set.</p>
267<p>Aside: there may be another way to do this <a href="http://www.darrinhodges.com/converting-ubuntu-12-04-lts-desktop-to-server/">using tasksel</a></p>
268<div class="footnotes">
269<hr />
270<ol>
271<li id="fn1"><p>See <a href="http://askubuntu.com/questions/37999/what-is-different-about-the-mac-iso-image">http://askubuntu.com/questions/37999/what-is-different-about-the-mac-iso-image</a><a href="#fnref1">↩</a></p></li>
272</ol>
273</div>
274</body>
275</html>