1 Overview

These notes describe the installation of Ubuntu 14.04 on a Mac Mini. This is the most powerful server we have found for its size, especially considering that the PSU is internal.

1.1 Mac Mini versions

The recommended configuration of a workshop server is:

These instructions have been tested on the following models:

When you have Linux running, you can determine your model using

sudo dmidecode -s system-product-name

For more information on the different models of Mac Mini see:

1.2 Items required

For installation only, you will need:

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.

2 Preparing the install image

First you need to choose which ISO image to use and download it. Start with the standard 64-bit server edition (ubuntu-14.04-server-amd64.iso) which should work fine with recent Mac Minis.

If you have problems booting, then try one of the amd64+mac1 variants from the alternative downloads page:

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.

To write the image to a USB stick you can simply dd it. To do this on a Mac running OSX:

diskutil list  # note the devices seen
# insert flash drive
diskutil list   # note the new device seen, e.g. /dev/disk2
diskutil unmountDisk /dev/diskN
sudo dd if=ubuntu-14.04-server-amd64.iso of=/dev/rdiskN bs=1m
diskutil eject /dev/diskN
# remove flash drive

To install older versions of Ubuntu you need to use a Mac which is running OSX and follow these instructions

hdiutil convert -format UDRW -o ubuntu-12.04.3-server-amd64.img ubuntu-12.04.3-server-amd64.iso
# Note: the output filename may be .img.dmg
diskutil list   # note the devices seen
# insert flash drive
diskutil list   # note the new device seen, e.g. /dev/disk2
diskutil unmountDisk /dev/diskN
sudo dd if=ubuntu-12.04.3-server-amd64.img.dmg of=/dev/rdiskN bs=1m
diskutil eject /dev/diskN
# remove flash drive

3 Installation

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.

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 "EFI boot".

After this you should get a menu of Ubuntu options:

Install Ubuntu Server
Install in expert mode
Multiple server install with MAAS
Check disc for defects
Rescue a broken system

Select "Install Ubuntu Server" and proceed as normal, choosing country, language and keyboard layout.

If you are using the USB-to-ethernet adapter for your external Internet connection, then you will be prompted for the primary network interface:

eth0: Broadcom Corporation NetXtreme BCM57765 Gigabit Ethernet PCIe
eth1: Ethernet

Choose the one which is your ethernet uplink (i.e. eth1)

4 Login after reboot

Your Mac should be up and running - login as user nsrc.

Use ifconfig -a 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.

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.

Since all the following commands need to be done as root, get a root shell:

$ sudo -s

4.1 Add the second hard drive

The second hard drive can now be made available for storing data.

The simplest way to do this is to make the whole second drive an LVM physical volume, and add it to our volume group.

First, check your current volume group name:

# vgs

Look under the first column "VG": if it was created by the Ubuntu installer it will be something like "-vg".

Label your second drive as a physical volume, and add it to the volume group:

# pvcreate /dev/sdb
# vgextend <hostname>-vg /dev/sdb

Now check your work:

# pvs   # should show both /dev/sda3 and /dev/sdb as physical volumes
# vgs   # The "#PV" (number of physical volumes) and VSize/VFree should increase

Alternatively you could choose to partition it in the same way as the first drive, and it might be possible to boot off this drive if the first one fails - but you'd almost certainly have lost your OS installation anyway.

Now let's create a new logical volume and mount it under /data. By creating a "striped" volume, half of the extents will be on each disk; this increases performance by dividing the read and write load between the disks. Choosing a large stripe size ensures that smaller reads and writes hit only a single disk.

# lvcreate --size 300G --stripes 2 --stripesize 4096 --name data <hostname>-vg
# mkfs.ext4 -m 0 /dev/<hostname>-vg/data
# mkdir /data
# vi /etc/fstab
... add this line ...
/dev/<hostname>-vg/data  /data  ext4    noatime         0       2

# mount /data
# df -h

To see which physical volume(s) each logical volume is using:

# lvs -a -o +devices
# lvs -a -o name,lv_size,devices

4.2 Optimise the swap volume

You can move the swap volume to the second disk, which helps balance the usage slightly.

# pvmove -n swap_1 /dev/sda3 /dev/sdb

Optionally, you could also reduce its size. By default a 16GB RAM system will have a 16GB swap volume. If you don't intend to use hibernate functionality you can reduce it to (say) 4GB, as you never want your machine to go this far into swap anyway.

# swapoff -a
# lvresize --size 4G /dev/<hostname>-vg/swap_1
  WARNING: Reducing active logical volume to 4.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce swap_1? [y/n]: y
  Reducing logical volume swap_1 to 4.00 GiB
  Logical volume swap_1 successfully resized
# mkswap /dev/<hostname>-vg/swap_1

Finally enable the swap partitions again

# swapon -a
# free   # should have 4GB of swap space

4.3 Configure the internal network interface

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:

$ ifconfig

To fix this, as root, at the command line prompt type:

# vi /etc/network/interfaces

Make sure the file looks like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

auto eth1
iface eth1 inet dhcp

Now to bring up both interfaces with their new configurations do:

# ifup eth0
# ifup eth1

Wait a few seconds for the script to complete then type:

# ifconfig

to see that your network is now configured. Trying pinging some external sites to verify that your network is working.

4.4 Update all packages

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.

Let's first see what version of the Linux kernel we are running:

$ uname -a

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:

# apt-get update
# apt-get dist-upgrade

Say "Yes" to downloading and installing the new packages.

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.

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:

# reboot

Wait for the MacMini to restart and log back in as the user nsrc, then type:

$ uname -a

To see the version of the Linux kernel that you are running. Is it different from what you had before running "apt-get update" and "apt-get dist-upgrade"?

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.

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.

4.5 Update /etc/hosts file

By updating your /etc/hosts file to include the lab.nsrc.org domain your machine's public IP address will be registered on the public Internet using dynamic DNS. This will be configured using Ansible in our upcoming exercises. In addition for class exercises and infrastructure your Mac Mini is referred to as "s1" or "s1.ws.nsrc.org". We will add both these entries to your /etc/hosts file.

The first two lines in your /etc/hosts file should look like:       localhost       kitX

The "X" is the number of your kit. We will now edit this file by doing:

$ sudo vi /etc/hosts

And change the first two lines to look like this:       localhost     kitX.lab.nsrc.org kitX s1.ws.nsrc.org s1

Be sure you substitue your kit's number for "X". Once done, save the file and exit.

5 Troubleshooting post installation problems

5.1 Your Mac does not boot

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:

At the bottom of your screen you will see the "#" command prompt. You are now in a rescue Linux shell where we can set some hardware options. You can type:


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:

efibootmgr -o 00

And, that's it.

Your MacMini should now boot. It may pause for a moment with the white screen, but give it a few seconds to complete booting.

5.2 Problems with video

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 "nomodeset".

Then to make this change permanent:

# vi /etc/default/grub

# update-grub

5.3 Problems with ethernet

On the Internet there is another set of instructions for installing Ubuntu 12.04 on a Mac Mini 6,2. The author describes building the tg3 network driver from source and installing with the "noapic" option. However we found we didn't have to do this.

6 Installing on older MacMinis

The following instructions were from previous tests with a Macmini4,1 and are kept in case they help debugging problems on older machines.

6.1 Boot using Mac OS X install CD

6.2 Wipe out all partitions

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.

6.3 Get the right Ubuntu install CD

The image used successfully was the alternate-amd64+mac.iso image

The problem is that this installs all the desktop GUI crap, which must be removed after installation.

6.4 Install Ubuntu

6.5 Edit grub defaults

# vi /etc/default/grub

GRUB_CMDLINE_LINUX=”noacpi nomodeset reboot=acpi”

Disable lightdm (replacement for gdm):

echo 'manual' | sudo tee /etc/init/lightdm.override


# update-grub

6.6 Convert into server

Remove all the desktop-related packages:

# apt-get --purge remove 'gnome-*' xerver-xorg

And install the right kernel:

# apt-get install linux-headers-server linux-image-server linux-server

All set.

Aside: there may be another way to do this using tasksel

  1. See http://askubuntu.com/questions/37999/what-is-different-about-the-mac-iso-image