Friday, July 27, 2018

Revive Old Mac Mini (2009) with Linux


We have an old Mac Mini (late 2009 version) lying around. The latest Mac OS X it could support was Mac OS X El Capitan. The machine is still good although the DVD drive does not worked anymore.  Apple will drop security update for El Capitan very soon. Running OS X El Capitan without any security update is not an option. 



Instead of disposing a good piece of hardware, we can install Linux. However, before we start playing around with the Linux installation, we need to take stock of the hardware capability. We might need to upgrade some hardware so that we can run Linux smoothly.

Mac Mini 2009 Specification

This Mac has Core 2 Duo CPU (P8700) running at 2.53GHz. It support PC3-8500 DDR3 RAM running at 1066MHz. This Mac Mini has a Nvidia Geforce 9400M video card. It support 2 display output. Wifi specification is 802.11a/b/g/n. This is pretty high end at the time.  However, this WiFi uses Broadcom chipset (BCM4321), which is not very well supported in Linux since it is an older chip. The down side for this machine is that it support only 5x USB 2.0 and the Bluetooth is using protocol 2.1+EDR.


Upgrading Hardware

The most important upgrade will be RAM and the storage. If you use Bluetooth device heavily, then you might consider buying a Bluetooth 4 USB adapter. Please bear in mind that this system only support up to USB 2.0.

The most important upgrade will be SSD if you are still using traditional HDD. If you are on a budget or if you do not wish to spend too much money on the old machine. We would recommend you to upgrade traditional HDD to SSD first. You can have the choice of 128GB, 256GB or higher capacity SSD. The upgrade will make a big difference in the user experience. For instruction to upgrade, please check out website from iFixit or OWC. These website also sell RAM and SSD together with upgrade kit.

According to the specification, this Mac Mini uses PC3-8500 DDR3 with 1066 MHz. This RAM is no longer in the PC building market. However, we might still able to obtained it via Mac upgrade company such as iFixit or OWC. Alternatively, we can obtained from 2nd hand market via eBay or craigslist. Officially, Apple support 4GB of RAM for this Mac Mini, however, Mac OS X is able to support up to 8GB. We are not sure if the chipset is able to support 16GB of RAM if we are to use Linux. It is recommended to to upgrade to 8GB. However, if you have 16GB of DDR3 with 1066MHz lying around, you might want to try it and let us know if Linux could recognize 16GB RAM.

We have previously upgraded the RAM and SSD for this Mac Mini. As far as we can remember, we do not need any special kit to upgrade RAM or SSD. Please checkout the following upgrade video from OWC and iFixit.


Possible Hardware Issue and Preparation

Please note that for Mac Mini (late 2009), we need to install third party drivers for Nvidia Geforce 9400M and Broadcom wifi. These two hardware will constantly cause us much of the conflict, headache and time during installation of Linux. 

For some Linux distribution, the open source video driver did not work well and we need to install Nvidia drivers.

The Broadcom third party driver is also not very reliable,  the driver works intermittently. The wifi could not detect available wifi host occasionally. A lan cable is required during Linux installation. After installation of third party driver, some time the wifi could not detect any network. We need to reboot a few time in order to get wifi connected. If wifi is a must for you, We would recommend that you buy an USB wifi adapter.

In addition, we would recommend you to use a wired mouse and keyboard during Linux installation. Wireless mouse and keyboard only works well when Linux is installed in the main drive and patched. 

Please also note that if we are going to switch between different Linux distribution, the Mac Mini or the bootable USB drive might not able to boot properly. In this case, we have to clear SMC or reset PRAM or perform both.

Please also prepare a couple of USB drive if you plan to try out different Linux distribution.


Different Class of Linux Distribution

Before, we start talking about which Linux distribution to install, we might want to classified different Linux distribution into different class. Each class of distribution uses the same type of OS. Usually they are forks or variant of the original Linux distribution. The based operating system is the same except that different distribution might use different user interface. 

Debian/Ubuntu class of Linux distribution are based on Debian/Ubuntu. There are many distribution that are based on Debian/Ubuntu. Some distributions are named as *buntu such as Xubuntu and Kubuntu. Popular distribution in this class are Debian, Ubuntu, ElementryOS, MX Linux, Zorin and Linux Mint.

Fedora/Red Hat class of linux distribution consist of Red Hat Enterprise Linux, Fedora and CentOS. Arch Linux class of distribution consist of Arch Linux,  Manjaro and Antergos. OpenSUSE and Solus are built independently. 


Which Linux To Install

From our experiment Ubuntu is the best choice with no extra steps involved in installing additional drivers. It also give us less problem while booting up. So using Debian/Ubuntu class of Linux distribution will give you less problem. The only problem that Ubuntu give is the Broadcom wifi issue. If you are only using wired network then it will be no issue at all. 

For Fedora class of Linux distribution, we could not install additional third party driver while installing the main OS. We could only add additional repository after the main OS is installed. Similarly, the wifi behaves intermittently. CentOS also present similar problem.

Manjaro is more of a headache. When mange to install Manjaro, however,  sometimes the OS could not boot properly due to video driver issue. In addition, Manjaro do not work well with other distribution for dual boot.

Word of advice, if you do not have much time to spent, just install Ubuntu. This guide contain instruction on installing Ubuntu on Mac Mini. 

Making Bootable USB Drive

Downloading and Verify Linux Distribution 

Downloading of various distribution is straight forward. Go to Distrowatch.com and select your favorite Linux distribution. Follow the download instruction from the website. For verification of downloaded package, we use shasum in Mac OS X to perform verification.

Use the following command:
                          sudo shasum -a 256 xxxxx.iso

The option -a follow by a number tell the shasum to compute using sha 256 algorithm.  For sha 1 no option is required.

The above command will generate a checksum which we can check against the website.

Alternatively, we can download a checksum file. Checksum file is a text based file that contain all the checksum from a download site. Please put checksum file and the image file in the same folder. Use the following command:

sudo shasum -a 256 -c checksum.txt

The system will run through the list in the checksum file and compare against the iso on the list. Those verified package will return OK. 


Preparing USB Drive for Mac Mini

Downloading of various distribution is straight forward. But due to the nature of our Mac Mini, some distribution could not boot. Please note that our Mac Mini uses 32-bit EFI. We must configure the USB drive such that it is bootable from our Mac Mini. Some Linux distribution make it easy to boot from 32bit EFI while it is impossible to boot on some Linux distribution.


Preparing Ubuntu USB

Ubuntu website has a tutorial for making a bootable USB for Mac system. See links below. The preparation involves in downloading an open source software called Etcher. 


We would recommend to uses the same method to make a bootable USB drive for all Debian/Ubuntu class of Linux distribution.

Preparing Fedora USB

When you try to download the latest Fedora workstation distribution, you will down the Fedora Media Writer instead. This is a useful tool to make bootable USB drive. To make Fedora USB drive, just run the media writer and download Fedora. Once download is completed, we can choose to copy the distribution to an USB drive. We recommend to use the same media writer for making USB drive for CentOS.

Preparing USB for Other Linux

The best method to make bootable drive for Manjaro is to use dd command. We will explore the details of making bootable drive in separate post.


Booting from Mac Mini

Booting from Mac Mini is quite straightforward. When the Mac Mini chimes, press option key (Alt key for Windows keyboard). Then, we choose to boot from the USB drive.

We did not encounter any problem when we try to boot Ubuntu. However, after multiple switching of Linux distribution, multiple partitioning and reboot; the system could not boot and hangs occasionally. The only way is to reset SMC, or PRAM or both. Listed below is the support document for resetting SMC and PRAM.


If you still encounter issue booting up the USB drive, please check the downloaded package or change the USB drive.

Please check the list below on other startup shortcut for Mac product:


In the following section, we will go through the steps in installing Ubuntu on Mac Mini late 2009.


Installing Ubuntu on Mac Mini (late 2009)

Please note that we had upgrade the Mac Mini previously. Currently our Mac Mini hold 8GB of RAM and it has 128GB of SSD. Please follow the previous section on preparing Ubuntu USB drive after you have downloaded the latest version of Ubuntu from the web.

Booting USB on Mac Mini

Once you have the USB drive ready, insert it to your Mac Mini and start the machine. Press “option” (or “Alt” for windows keyboard) when you hear a chimes from the Mac Mini. The key press must be either earlier or together with the chimes. The system will show a few drives which you can boot from. Ubuntu USB drive always produce 2 bootable drives. Select either one and the system will bring you to a boot page. Select “Try Ubuntu Without Installing”. Ubuntu should be able to boot up. If for some reason the USB drive could not boot up, please clear SMC and/or PRAM. If you are still not able to boot up, please check the iso image or change USB drive.

Installing Ubuntu

Once you are in the system, you can select Install Ubuntu to start the installation process. 



The installation app will appear with the screenshot as shown below:



Select your appropriate language and click Continue.


Select your keyboard layout and click Continue.


Select the type of installation. We would recommend minimal install if you have very limited disk space, otherwise use the default. For third party driver, we suggest that you select to install third party driver. However, you can choose not to install third party driver as shown below:


Click Continue.


We can choose to install Ubuntu along side other OS. For fresh installation, select the option Erase disk and install Ubuntu. Click Install Now to proceed with the installation. A dialogue box will appear to inform us how the system is going to partition the drive. Since our Mac Mini uses 32bit EFI, the system will create a boot partition mounted as /boot/efi formatted using FAT32. The root partition will be formatted as ext4. Click Continue.


The next screen  allow us to select the time zone.


Select the appropriate time zone and click Continue.


Next we need to create our default account. Enter userID and password. Since this is an experimental box, I choose to auto login. Click Continue to proceed.


The system will start its installation process. Once it is completed. The dialogue box appear as below. 


You can choose to continue testing with the USB version or choose to reboot the Mac.

Post Installation

After the system is rebooted. We need to update the system. The system will automatically launch the Software Update app. Click Install to update the patches.


Alternatively we can use the command from the terminal:

sudo apt-get update

Personally, I would like to keep the dock at the bottom. You can set the dock under Settings > Dock.


For software installation, we use Ubuntu Software app. Click the All tab and click on the search icon. We prefer to install gparted and vlc. Search for gparted.


Click on the gparted result. 


Click Install.

Similarly, we also search for vlc and click install as shown below.


To install Chrome, we activate Firefox and search for Chrome.

 

Click to download and install.


Choose the first option For Debian/Ubuntu and click Install down the scroll box.



The system will launch the Ubuntu Software app as shown above. Click Install.

After installation of all the app we want, we can go to Settings > Details > Default Application to set the default app for video playing and web browsing.



Important: Please note that when we launch Chrome or VLC for the first time; the system will take a while to launch the app. Sometimes, we may need to wait for 1 min or more for the initial launch. There is nothing wrong with the installation. Fortunately, it is just for initial launch.

Please also note that when we launch Chrome, we must set password for the keyring in Linux. Chrome uses Linux keyring to store password. Every time when we rebooted the system Chrome will ask for keyring password. However, it will only asked once when the system is booted.

Video Driver Issue

The current 18.04 LTS Ubuntu do not have video problem. By default, it uses open source nouveau video driver. It does not create any problem. However, if you use dmesg to look at the kernel, you will see some error relating to nouveau video driver.

You can choose to install Nvidia video driver. It will reduce video related error in the dmesg. To install third party driver, got to Software & Update app. Select the tab Additional Drivers.


Select "Using Nvidia...." driver and click Apply Changes.

If you are happy with the video you can leave it as default.

Update 29 July 2018

We have discovered that Nvidia driver does not work well with RealNVC in Ubuntu. If you intended to install VNC server, we would suggest that you keep existing driver.

Our testing with Linux Mint also shows that if Nvidia driver is installed, Linux Mint would not launch X windows session during boot up, if monitors are not detected. This creates problem if you intended to boot your box without monitor attached.

If you intend to use the box with VNC server or to boot without monitor, use the original open source video driver, DO NOT install Nvidia driver.

Broadcom Wifi Issue

This is the only persistent problem with Ubuntu distribution. In fact, if you search the web there are many issue relating to Broadcom wifi driver, especially on older chipset. Our Mac Mini uses BCM4321 wifi chip.

If you are happy with just wired network connection. You can just ignore this section and you are good to go.

If you prefer to make the wifi work, You can choose to install the third party driver. Go to Software & Update app. Select the tab Additional Drivers.  Click on "Using Broadcom..." and click Apply Changes.


We have tried using this driver. The system is able to detect the wifi after installation of the driver. The wifi is also able to scan and detect all the routers. We manage to established connection with our router. However, subsequent reboot shows that the wifi is not able to established connection consistently. Sometimes, the wifi is able to established connection, sometimes it don't. To resolve the issue, we have to reboot the system few times until the wifi works.

There is a detail troubleshooting post on solving Broadcom wifi issue. the links is below.

https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers

Based on the linked post above, there are 2 drivers for BCM4321. We will present both drivers for you to test.

The two drivers are bcmwl-kernel-source and firmware-b43-installer.

Install Broadcom Drivers bcmwl-kernel-source
To install bcmwl-kernel-source, you just need to use the additional drivers from the GUI. We suggest you test with this driver first.

Install Broadcom Drivers firmware-b43-installer
To install firmware-b43, we must first remove the bcmwl driver. To remove it use the command below:

sudo apt-get remove --purge bcmwl-kernel-source

Then install the driver as follows:

sudo apt-get install firmware-b43-installer b43-fwcutter

After that we need to make change to a block file as this driver is currently being blocked. Edit the file using the command below

sudo nano /etc/modprobe.d/blacklist.conf

Comment by adding # in front of the line blacklist bcm43xx

Restart the machine.

Our Test and Conclusion
We have tried the method recommended in the post and we also tried installing firmware-b43. However, the wifi still connects intermittently. Unfortunately, it is very hard to troubleshoot intermittent behavior.

Final resort is to get another wireless adapter which does not cost much according to amazon website.


Making Use of the Revived Box

Now that Ubuntu is running on this Mac Mini, what can we do with it? Mac Mini has the reputation of low power consumption. So it is ideal to run this box 24x7.

Media Server
Perhaps we can use it as a media server. If you can attached an external USB drive to this Mac Mini, perhaps we can try to install Plex Server or Kodi. We can get a mini Display port to Display port cable and connect them to a TV.

Network Server
Perhaps we can use the box to run VPN server. Using Mac Mini as a router is not an option since router need more than 1 network interface.

Please let me know in the comment if you have any more ideas on how to make use of this box.


***




No comments:

Post a Comment

Note: Only a member of this blog may post a comment.