Tuesday, November 12, 2013

Linux Mint / Mac OS 10.9 dual boot setup on Haswell i7-4770 GA-H87N-WIFI

Setup Objective:  Dual Boot MacOS / Linux

My new computer hardware:

  • MI--008 Mini-ITX Black Case with 250w PSU
  • Gigabyte GA-H87N-WIFI motherboard with 1150 slot
  • Intel Core i7-4770 Quad Core 3.4Ghz processor with HD 4600 integrated graphics
  • 16GB DDR3 1600 MT/s (PC3-12800) Crucial Ballistix Sport RAM
  • Samsung 840EVO 250GB SSD (boot drive)
  • Seagate Barracuda 2TB HDD (data drive)
  • LG Blu-Ray reader / DVD-RW UH12NS30
  • Gentle Typhoon 120mm cooling fan
This amounts to a pretty tiny PC with lots of computing power (but low energy usage). I do wish I could install more RAM, but 16GB is the limit. I'll use it mostly for intensive processing for my dissertation and for work [I'm a programmer]. But I may also do photo editing with the mac side and use it as a part-time HTPC under linux/xbmc.

Instructions

A) Install MacOS:
  1.  Purchase and download (but don't install) MacOS from an existing Mac. Use Unibeast to setup a USB key with a bootable MacOS installation. I used OSX 10.9 (Mavericks). Also copy Multibeast 6.0 to the USB key.
  2. Setup BIOS to use the optimized settings with the following modifications:
    1. Disable VT-d. 
    2. Extreme Memory -> Profile1.
    3. Make IGFX the first option.
    4. UEFI and Legacy boot.
  3. Take the key to the new computer and boot. I needed to use the "-x PCIRootUID=1" (no quotes) settings to get the video mode to work. Install normally, using the whole boot drive as a partition. It can be shrunk later. Instructions here.
  4. Upon reboot, again boot with the USB, this time selecting the new mac partition, again with the same settings.
  5. Setup: System Preferences->Security & Privacy->Unlock; Then: allow apps downloaded from anywhere. Back arrow. Mouse->Disable scroll direction "natural".
  6. Copy multibeast to the desktop and run. With my hardware, most things work straight out of the box. Select the following (de-selecting all else):
    1. DSDT Free
    2. Audio->Realtek ALCxxx > Without DSDT->ALC892
    3. 3rd Party SATA
    4. TRIM Enabler -> 10.9.0 TRIM Patch (for SSD)
    5. FakeSMC v5.3.820 (Plugins and HWMonitor are nice, optional extras)
    6. Network->Atheros -- Shailua's ALXEthernet v1.0.2
    7. Network->Intel -- hank's AppleIntelE1000e v2.5.4d     (need both to support both ethernet ports)
    8. System->Patched AppleIntelCPUPowerManagement -> OS X 10.9.0 --- THIS IS NECESSARY; otherwise boot will hang without safe mode on after loading bluetooth drivers.
    9. System -> AppleRTC Patch for CMOS Reset
    10. Boot Options-> Generate CPU States, GraphicsEnabler=Yes, Hibernate mode-Desktop, PCIRootID Fix (this sets PCIRootUID=1), Use KernelCache. Might want to still edit /Extra/org.chameleon.Boot.plist to add GraphicsMode to match your monitor. [App Store -> Find/Install TextWrangler; Finder->Go->Go to folder-> /Extras]
    11. System Definitions -> Mac Pro ->Mac Pro 3.1 (don't know if this is optimal, but it works)
  7. If you can boot now, it's a good time to setup linux (below). But first fix the drives up some.
    1. Open disk utility and shrink the macos partition on the boot drive. 
    2. Format the data disk using NTFS. NTFS is the best choice for a drive between windows and anything, but also between macOS and linux, supporting >4GB files and big drives. 
    3. Enable read/write support for the data drive: from the terminal, run sudo vifs and add this line: /dev/disk1s1 /Volumes/data ntfs rw,auto,nobrowse. The first is the partition (make sure this is correct) and the second is the mount point (a directory which you must create). Run sudo mount -a to test that it works; browse to this location with finder. Then drag the directory into the favorites list to the left of finder (for easy access later). It will be mounted at boot up from now on.
  8. At this point most things worked, except WIFI, which is a known limitation. But not audio via the HDMI cable, and the video drivers were flickering/unstable around animations. To fix both these issues, do toleda's HDMI fix for Haswell systems. Be careful to follow the directions exactly. First verify pre-requisites, then perform all steps in the "Before you start" section, referring to the Notes section below. Finally, do either the DSDT or the SSDT installation method. I did the DSDT method, and selected the -1 variant of the driver, which worked nicely.
  9. Setup SAMBA sharing to match linux.
  10. VNC setup

B) Linux Setup. I used Linux Mint 15 [Cinnamon 64], for which I burned an install DVD. You will also need a grub rescue DVD.
  1. Boot up linux mint on the install DVD, being sure to select the UEFI DVD option (and not the P? option) from the BIOS boot menu. DO NOT INSTALL DIRECTLY FROM BOOTUP, as it will fail to properly setup grub. Instead, once Linux Mint has booted, double click the Installer program on the desktop to start installation.
  2. Choose "something else" for how to install the OS. Create an ext4 partition at the end of the drive. I did not create a swap partition, preferring a file instead as it's more flexible (see below). At the bottom, choose to install Grub in /dev/sdb3 (or whatever your new ext4 partition is). If you install it in the default /dev/sdb, it will overwrite chimera and macOS won't boot.
  3. Next, boot with the grub rescue DVD. Select the partition you just installed [/dev/sdb3] to load the new linux install.
  4. To add linux to the UEFI boot menu, sudo cp /boot/efi/EFI/linuxmint/grubx64.edi /boot/efi/EFI/boot/bootx64.efi [efibootmgr does not work correctly for me, I strongly suspect Gigabyte's UEFI implementation is faulty]. Grub will not install automatically to the EFI either, and I can't get Grub to load chimera or the mac kernel either. I even tried creating partitions just for grub or using the data disk MBR, to no success. Basically I tried about 100 options (which means >100 reboots) and no fully satisfactory option arose for a good boot loader for both mac and linux. I settled for using the bios to choose either the boot disk MBR (to load MACOS via chimera) or to use UEFI default boot (to load Linux via grub partition boot loader). A bit ugly, but at least it works. [Update - Linux Mint 16 may have fixed UEFI support for this motherboard. I have just installed Mint 17.1, and it appears that as long as the install DVD was booted in EFI mode, mint will set up grub properly to boot. If not, you may need to run boot repair]
  5. Setup swap file (I made mine 16GB, same as RAM, but it may be worth investigating the "swapspace" tool for dynamic swap space, or you may not even need one at all):
    1. sudo fallocate -l 16G /var/swapfile
    2. sudo mkswap /var/swapfile
    3. sudo swapon /var/swapfile
    4. You should see your swap listed when you run free.
    5. Edit /etc/fstab to use it at reboot, adding this line: /var/swapfile  none  swap sw  0  0
  6. Setup Paragon UFSD drivers. These are kernel-level drivers that permit read-write for both NTFS drives and HFS+ drives (even with journaling enabled). As such they're a major improvement over the drivers included as redistributables with linux. NTFS writing is significantly faster since it's not a user-space driver. Although it is proprietary, it's free for personal use. Fill in a little form and a few minutes later you'll get the download link via email. To install, simply:
    1. Download them to ~/Downloads. 
    2. cd ~/Downloads; mkdir ufsd; cd ufsd; tar -xvzf ../Paragon-147-FRE_NTFS_Linux_8.9.0_Express.tar.gz
    3. See the README to confirm all is good. Although the website is outdated, it supports kernels up to 3.11.x as of this writing and works fine under ubuntu/mint (I have kernel 3.8.0-19). Then run sudo ./install.sh.
    4. Edit fstab to use the new drivers by replacing the mount types with ufsd. I have these two lines:  /dev/sda1  /data  ufsd uid=myusername,gid=smbusers,noatime,umask=0002  0  2
      /dev/sdb2  /macos ufsd defaults 0 3
    5. You may also need to clear the dirty flag on the drive by rebooting properly from Window/MacOS, or by using fsck (otherwise ufsd will give error 1000). Check dmesg | tail for more detailed errors when mounting. In Linux mint 16, (not in 15 or 17), I had to add ufsd to /etc/modules for it to load at boot.
  7. Setup SAMBA shares to match macos. 
  8. To play videos in vlc (and possibly other apps), it was necessary for me to choose Tools->preferences->Video->Output as OpenGL GLX or X11 Video.
  9. To get HDMI audio working, I had to do as I later saw was suggested in the release notes (directions below). I also found the pavucontrol app to be helpful. You may need to disable SPDIF using the configuration tab of this tool to use HDMI.
    1. sudo add-apt-repository ppa:ubuntu-audio-dev/alsa-daily
    2. apt update
    3. apt install oem-audio-hda-daily-dkms
  10. It may be worth changing your user's UID to match that of macos, for while writing to the HFS partition. That can be done by looking it up under macos: ls -n in the home directory (mine was 501). Then from the linux console (ctrl-alt-F1), login as root and run usermod -u uid username. If like me you chose to create an encrypted home directory, also run chown -R username /home/.ecryptfs/username. Reboot.
  11. Use software manager GUI to install all the wonderful free packages you want.

    Et, Voila!  That simple, in retrospect.

2 comments:

  1. I follow ur setup but still unable to boot without safe mode (-x) :(

    ReplyDelete
    Replies
    1. I would try using boot option PCIRootUID=0 if 1 doesn't work, or leaving it out altogether. This setting may depend upon where on the motherboard you installed your hard drive. Good luck.

      Delete