Tag Archive for 'mac'

Linux on Mac with multiple drives – by Larry Edwards

Larry has been following my original post about running Linux on a Mac Pro with multiple drives, and had some dramas himself. He kindly posted his findings in a comment on that thread, so I’m re-posting them here as they might be helpful for someone else.

Here’s a short how-to on installing Linux (running under BIOS emulation) on a Mac Pro with multiple disks. I’ve done this with both RHEL6 and Kubuntu 10.10. RHEL6 requires a third party tool, Kubuntu does not.

One thing to note is that fan control under Linux is less sophisticated than under OS X. Under OS X, my Mac Pro is usually almost silent, whereas with both Linux versions, the fans are always quite noticeable, although not as loud as my old Dell PC.

My setup:

2010 2.66 GHz 12 Core Mac Pro
4 disks, the disks in the first two drive bays make up a RAID mirror
Mac OS X 10.6.6 installed on the RAID mirror

Goal: install Linux, in particular RHEL6, on the disk in the 3rd drive bay of my Mac Pro

WARNING: mistakes or errors in the following can cause you to lose all your data. Follow the procedure at your own risk, and backup any and all disks that contain data that matters to you. This worked for me, it may not work for you.

Preliminary Preparation for RHEL6 (you’ll need Xcode installed)
————————————————

1) Download the rEFIt 0.14 source code:

http://sourceforge.net/projects/refit/files/rEFIt/0.14/refit-src-0.14.tar.gz/download

2) Move the downloaded tar file to some place reasonable and double-click to extract the archive contents. This should create a refit-src-0.14 directory.

3) Open a terminal and go to the refit-src-0.14/gptsync sub-directory.

4) Compile the source code: make -f Makefile.unix

If you have the 10.4 SDK installed, this will fail and you’ll have to edit Makefile.unix, commenting out lines that refer to:

/Developer/SDKs/MacOSX10.4u.sdk.

5) This should create two executables:

gptsync
showpart

6) Now in the terminal, sudo tcsh (or sudo bash) to get admin privileges, and move the executables to somewhere useful, e.g., /usr/sbin.

Procedure for installing RHEL6
———————–

1) Run the “Boot Camp Assistant” app. At the “Create or Remove a Windows Partition” dialog select the disk you will use for Linux, press “Continue” (“Erase and Create a Single Partition for Windows” should be the only possible action) and enter an administrator username/password. When you get to the “Start Windows Installation” dialog, press the “Quit & Install Later” button and exit the program.

Using Boot Camp Assistant is probably not really necessary, everything it does should be possible with “diskutil” and “gpt” command line tools. I use it because it quickly puts the disk in a known correct state.

2) Run the “Disk Utility” app. Select the disk you just initialized with Boot Camp Assistant and select and delete the large Windows MS-DOS (FAT) partition.

At this point you have two options, one: 1) use the Disk Utility app (or diskutil command line tool) to create the desired partition layout for Linux, or 2) create the partition layout within the Linux installer. I assume the latter in the following.

3) Reboot, booting off the RHEL6 installation disk (I used a DVD).

4) Proceed with the installation and when it comes time to partition the disk, choose “Create Custom Layout”. In the free space on your intended Linux disk, create the desired partition layout. I’ve had success with a Linux+swap partition layout (i.e., “/” and swap), a boot+Linux+swap layout, and LVM.

5) When the RHEL6 installation is finished, reboot into Mac OS X.

6) Open a terminal and sudo tcsh or sudo bash to get admin privileges. To determine which device is associated with your Linux disk, run:

diskutil list

Note: the device associated with a specific disk changes across reboots in Mac OS X!

From the commandline run:

gptsync /dev/diskN

where /dev/diskN is the device associated your Linux disk. If you created a Linux+swap partition layout you should see output similar to:

Current GPT partition table:
# Start LBA End LBA Type
1 40 409639 EFI System (FAT)
2 411648 3848329215 Basic Data
3 3848329216 3907028991 Linux Swap

Current MBR partition table:
# A Start LBA End LBA Type
1 1 3907029167 ee EFI Protective

Status: MBR table must be updated.

Proposed new MBR partition table:
# A Start LBA End LBA Type
1 1 409639 ee EFI Protective
2 * 411648 3848329215 83 Linux
3 3848329216 3907028991 82 Linux swap / Solaris

May I update the MBR as printed above? [y/N]

Type ‘y’ and hit return.

That’s it. Your Linux disk should now be an option appearing as “Windows” when you hold down the option key on boot.

NOTE: I occasionally experience a hang after selecting the RHEL6 disk and initiating the boot. There is a short amount of disk activity, and then nothing. The grey screen with the disk icons remains up. I’ve never seen this with Kubuntu, just RHEL6. RHEL6 uses an older GRUB version, so possibly a GRUB bug, although I see a similar problem mentioned in forums on dual booting Windows on Macs (e.g., http://www.insanelymac.com/forum/index.php?showtopic=201737)

Procedure for installing Kubuntu/Ubuntu 10.10
————————————-

For Kubuntu/Ubuntu installation, you don’t need the rEFIt gptsync. The following describes a Kubuntu 10.10 install, I assume Ubuntu 10.10 is essentially identical.

1) Initialize the Linux disk as with RHEL6, but after you delete the Windows partition created by the Boot Camp Assistant app, in the Disk Utility app, create the desired Linux partition layout in the free space. I’ve only tried a Linux+swap layout, but others should work. I usually select the ExFat format for the partitions because that seems to allow more flexibility in sizing than, say, MS-DOS FAT (the format shouldn’t be critical since it will be changed below). Alternatively, use the diskutil command line tool to create the partition layout.

2) Reboot using the Kubuntu 10.10 install disk and proceed with the installation.

3) At the “Allocate drive space” dialog, select “Specify partitions manually (advanced)”

4) In the “Prepare partitions” dialog, look for the Linux drive. It should contain a small ~200MB EFI partition followed by the Linux and swap partitions you created.

5) Select the partition you want to use as the main Linux partition. A small “Edit Partition” dialog should pop up. Select “Ext4″ from the “Use as:” menu, press the “Format the partition” check-box, and the mount point should be /.

6) Select the partition you want to use as swap. In the “Edit partition” dialog, select “swap area” as the “Use as:” choice.

7) Back at the Prepare partitions” dialog, select the “Device for boot loader installation”. You can choose the disk device, for Master Boot Record (MBR) installation or the Linux partition device for Volume Boot Record (VBR) installation (both seem to work, I usually use the MBR). For example, if your Linux disk is /dev/sdb and your Linux partition is /dev/sdb2, choose the /dev/sdb for MBR installation, /dev/sdb2 for VBR. Then press the “Install Now” button.

8) Continue with the installation till done, and reboot.

That’s it. Your Linux disk should now be an option appearing as “Windows” when you hold down the option key on boot.

Does your Mac have 64bit EFI?

Update: Actually, you might be able to install 64bit Linux on a Mac with 32bit EFI by including the “fakebios” GRUB2 option. I’ve updated the grub-efi tarball to include this and it works on my Mac Pro. Thanks to Martijn Broeders for this.

To install 64bit Linux onto a Mac using only EFI (and not MBR emulation) then your Mac must have a 64bit EFI. Run the following under OS X to discover whether you have 64bit or only 32bit:
ioreg -l -p IODeviceTree | grep firmware-abi

This should return something like:
| | "firmware-abi" = <"EFI32">

If you see “EFI32” like I do, then it means your machine can’t execute 64bit EFI loaders, so you’re stuck with 32bit, d’oh!. If you see “EFI64” then you should be able to install native 64bit Linux using EFI only, yay!

I discovered this while trying to load 64bit only my Mac Pro at work as an alternative to running Linux with multiple drives and MBR (which doesn’t really work) :-(

This is why the 64bit Fedora efidisk.img never worked on my Mac, but the 32bit one does.

-c

How to triple boot Mac Pro with OS X, Fedora, Windows

Here are some step by step instructions on how to triple boot a Mac Pro (and I guess any Intel based Mac) with OS X (Snow Leopard), Fedora 12 and Windows XP. I ran into trouble because of the Fedora 12 installer being clever and setting my Fedora partition to be bootable, which didn’t play nice with the MBR table and Windows.

Firstly, the Mac Pro I am using has a 500GB SATA drive, so the partition sizes that I choose reflect that fact. Your machine might be different, so adjust accordingly.

Step 1
Install OS X on single partition using the whole drive (insert DVD and boot with C key held down).

Step 2
Use the diskutil terminal command to resize the OS X partition and create one for Linux and Windows.

Open “Terminal” and then run:
sudo diskutil resizeVolume disk0s2 200G "MS-DOS" "Linux" 200G "MS-DOS" "Windows" 5G
(Note that the final number for the Windows drive doesn’t really matter, it will fill all remaining available space.)

Step 3
Under OS X, install rEFIt (a graphical EFI boot loader) and then bless the drive:
sudo /efi/refit/enable-always.sh

Step 4
Insert Fedora 12 disk and reboot, holding down the C key (or boot it from the Linux CD entry in rEFIt menu).
(Note: I had to install via FTP, because installing from DVD didn’t always work on my Mac Pro. If you have the same issue then at the boot menu hit the “Tab” key and add “askmethod” to the kernel line and boot the entry.)

Step 5
During the installer, select the 3rd partition for / (choose “Custom” partition), format ext4.

Next, switch to terminal 2 (CTRL+Alt+2) and toggle boot to off for the Linux partition, like so:
parted /dev/sda
toggle 3 boot
quit

Now sync the GPT and MBR partition tables:
gptsync /dev/sda
(Or you can do this step via rEFIt menu after the install if you prefer.)

Switch back to terminal 6 (Alt+6) and continue. Install the boot loader to /dev/sda3 (this is the default).

Complete Fedora install, reboot into OS X, eject disk, insert Windows XP install CD.

For reference, the GPT partition table should look something like this:

[chris@localhost ~]$ sudo parted -l

Model: ATA ST3500630AS P (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 20.5kB 210MB 210MB fat32 EFI System Partition boot
2 210MB 200GB 200GB hfs+ OS X
3 200GB 400GB 200GB ext4 Linux
4 400GB 500GB 99.9GB ntfs Windows

While the MBR table should look like this:

[chris@localhost ~]$ sudo fdisk -l

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xcce7cce7

Device Boot Start End Blocks Id System
/dev/sda1 1 26 204819+ ee GPT
/dev/sda2 26 24325 195181428 af HFS / HFS+
/dev/sda3 * 24341 48656 195311616 83 Linux
/dev/sda4 48657 60802 97556480 7 HPFS/NTFS

Step 6
Reboot, holding down C key (or choose the Windows CD entry from rEFIt menu), install Windows XP to 4th partition, format NTFS.
If the Windows installer sees a single partition and can’t detect the file system, re-sync the GPT and MBR partition tables via rEFIt or Fedora gptsync command. Also, ensure that the Fedora partition is not set to be bootable (Step 5, part 2). The installer should see multiple drive letters, with the 4th partition being the C drive. Yes, Windows has to be installed on the last partition.

After install, the rEFIt menu should see Windows on the hard drive. Boot it and continue your Windows install. Once installed, insert the OS X Snow Leopard DVD and install the system drivers, etc.

That’s about it.

Fedora, Macs and EFI

When installing Linux beside OS X, Fedora toggles the boot flag on for its partition. This causes GPT to see it as an “EFI boot partition,” rather than “Basic Data”. This appears to cause a problem if you want to triple boot with Windows and under OS X the disk utility will see it as one whole partition, with the Linux half missing.

To fix this, toggle the boot flag to off using parted and then sync the GPT partition table to the master boot record partition table. It’s easiest to do this while the installer’s running (switch to TTY2) else you’ll have to install anaconda under your install to get gptsync (or run it from the rEFIt menu).

Simply run the following:
parted /dev/sda
toggle 3 boot
quit
gptsync /dev/sda

The gptsync command should spit out the “Current GPT partition table” which should show something like:
EFI System (FAT)
Mac OS X HFS+
Basic Data
Basic Data (if you have a fourth partition for Windows)

The “Proposed new MBR partition table” should show something like:
EFI Protective
Mac OS X HFS+
Linux
FAT32 (LBA) (or NTFS, depending if it's already been formated)

Now Windows should install cleanly on the fourth partition (if you’re doing that) and the partition structure under OS X should be correct.

Linux on Mac Pro with multiple drives

Update: This is possible using EFI only installs, yay!

The Apple Mac Pro at work has four bays for 3.5″ hard drives. My plan was to have OS X on the main drive with Linux on a secondary drive for virtualised environments. Native Linux could run on drives in the other slots if necessary.

I installed OS X on the primary drive and install rEFIt to manage all operating systems. So far so good.

Next I installed Fedora 12 on the secondary drive, but no matter the installation layout (whether MBR or GPT) I couldn’t for the life of me get rEFIt to boot it.

The install would be detected and come up in the pretty menu, but booting it resulted in a completely black screen. Nothing I tried seemed to fix the issue (for some reason even a single drive with Linux and EFI only wouldn’t work).

At my wits end I decided to Google the issue and came across an entry in the Debian wiki which explains my issue:

rEFIt assumes that you have only one disk drive. If you try and install linux onto a secondary drive, you will probably have found that rEFIt lets you try and boot your newly-minted linux partition/drive, only for you to get a “Missing operating system” error message. This is actually a Syslinux error message. What happens is that rEFIt looks on the primary disk for an MBR record, fails to find one (obviously!), so sticks the syslinux MBR onto the primary disk, and tries to boot that.

So the problem appears to be with rEFIt :-( Hopefully this will be fixed at some point, because being able to boot the OS from any drive on a Mac Pro would be oh, so handy.

In the mean time, I’ve installed Fedora on the same drive as OS X and will then use the other drives for virtualisation. I guess in theory putting /boot on a small partition on the primary drive with OS X might also work.

-c