Installing Debian Squeeze on XServe 3.1

This tutorial is using a custom ISO of Ubuntu downloaded from here.

The Challenges

We have Apple XServe 3.1 servers here. They are equipped with a JBOD, Promise VTrek E610F. It connected via Fibre Channel. We have configured them for RAID6 28 TB.

The best part of the challenge is that XServe 3.1 use EFI. Some people would suggested us to use rEFIt and chainload it to GRUB2. We could use “bless” command from OSX.

The problem is, we have stripped the original 150 GB harddrive. The reason was because it was only had one drive without RAID. Data integrity was in question so we have to use only the JBOD.

Another problem is because PC BIOS couldn’t handle more than 2 TB. We just have to use GPT. Besides, GPT is the part of EFI.

So, I took the challenge to not use the OSX but to install directly from GNU/Linux installer from EFI to a GPT partition.

The Preparation

I got this challenge from my friend because he gave up on installing the XServe. From his previous attempt, I got 64 Bit Mac (AMD64) alternate install CD downloaded from Ubuntu. I don’t know where he got the ISO. Please download here. Not bad, I can use it to debootstrap the partitions.

To start, boot the CD and choose Expert Install. The Expert Install mode would let us select few things manually. Here’s the things that I’ve selected:

  1. Language: Indonesia – Bahasa Indonesia
  2. Keyboard: USA :: Macintosh :: No Compose Key
  3. Installer component from CD: [*] choose-mirror: To select mirror [*] network-console: To enable SSH server, I can configure from remote. [*] parted-udeb: To manually create partition.
  4. Configure the network.

If you don’t want to have remote install, you could disable network-console. In my case, I don’t like to be in the server room and to move XServe with its JBOD is daunting. I would like to configure everything from my nice warm room office.

After configuring the network jump to the run shell option. Or, after we have configure SSH credential, we could SSH to the machine with username “installer”. And choose to start a shell. Either way, we would be presented with a little console program: BusyBox. It isn’t feature-rich like BASH, but it serves right with compact size.

On The Shell

First, we partition our drive. We are using parted instead of fdisk because the later doesn’t support GPT partition type. The Apple’s EFI specification needs a FAT32 partition to load the EFI binary. That partition should be at the range of the first 2 TB disk. It doesn’t have to big, just few megs actually would do. So, here’s my partition:

  1. 20 MB FAT32 partition at the beginning with BOOT flag on.
  2. 20 GB partition for our GNU/Linux partition.

We have lots of RAMs, so we disable swap partition. But, yours might differ. From my research, the semantic web/4th paradigm world, it seems people prefer XFS because it is optimized for big data. So, from the beginning I choose XFS. Again, yours might differ. So, here’s the two commands:

I have difficulty to format the FAT32 partition, I think the Installer CD is dying. So, I decided to format it later. Now, let’s install it via bootstrap it and copy the files that were configured earlier from the installer:

BusyBox can’t do the array like the above. You have to parse it one by one (copy fstab, then hostname, and so on). I just put that way for convenience. Next, we mount the important filesystems and chroot to our new system. I explicitly use BASH instead of DASH, the default shell in Ubuntu.

On Chrooted Shell: The Basic Packages

First thing to do is to add other repositories to “/etc/apt/sources.list”.

I put away the “>”  so you could just copy and paste above. Use a mirror near you. KAMBING is the nearest for me. Then, update and upgrade:

Install essential applications. I’m using XFS, that’s why I install xfsprogs. Adjust it with your own filesystem tools. The dosfstools are for FAT32 and so on. I too put SSH server there.

I’m use ViM. So, optionally, I do this:

Next, we are going to change the preferences of our system.

On Chrooted Shell: Personalizing System

Let’s add a user with admin privileges. The default system, sudo is not installed. So, we must get it first

Install and configure our language. Mine is “id_ID.UTF-8″. Also, configure clock (Timezone). Mine is “Asia/Jakarta”.

Time is crucial for server. Install NTP server to have our server clock right. Don’t forget to edit the editor to get our nearest NTP server.

We can check the avaibility of the NTP servers.

Last thing, let’s install our Linux kernel.

The next one is the most challenging one: making our server boot from EFI on GPT partition.

Building GRUB2 from Unstable

I have many failed attempts using the default grub-efi 1.98 from Squeeze. As I realize, the Natty installer is using 1.99 version of GRUB2. I decided to go to that route.

GRUB2 1.99 is available at unstable and must get backported to Squeeze. We must compile it ourselves. So, here’s how to.

Get all the requirements for GRUB2 in Squeeze. There is another optional package we need: libfuse-dev for building grub-mount. It can be skipped, but it’s not that bad to add few bytes on that functionality. We need also autogen because the GRUB2 source is taken from Bazaar.

Next, add Debian source repository for unstable/SID. Don’t add the binary, it will upgrade your system to unstable/SID.

Get the source.

We could build the package manually, but I prefer the Debian way. Fortunately, the showstopper of doing the Debian way is only the GCC requirement. Unstable/SID  is using gcc-4.5 while Squeeze using gcc-4.4. The solution is simple, find all the occurrences and change all of them.

There are three files that affected. You could use sed/awk, or using your favorite editor to change all of the gcc-4.5 to gcc-4.4. I’m using ViM with regex. Of course, it is advised that we change the version also. I’m not doing it because we are not trying to publish it. This build has bug, yet sufficient for our need. 😛

Okay, the next thing is to build all of the packages.

All of the Debian packages are built on the top of our source directory. Let’s install all of the EFI versions. But wait, before you could install, the package needs to install efibootmgr, an application for setting the default drive to boot on UEFI (Universal EFI) compatible board. Unfortunately, XServe is using Apple’s own EFI implementation, so the application is useless. We must use bless, an application on OSX for that purpose. Oh, btw, install the ucf and os-probes.

Now, we are ready to get into the show.

Installing GRUB2 EFI

Before we take further, I want to say something. I am gratefully to the developer of the grub-install for making an undocumented parameter  –debug. That parameter saves me and made me to see what’s going on.

Okay, now we need to prepare our partition for EFI. It should be FAT32 and mounted at “/boot/efi”. Let’s create one.

Next, we run the GRUB installer.

The parameter “–bootloader-id=BOOT –removable” is what I found out after I analyze “/usr/sbin/grub-install” script. Basically, I want  GRUB2 installs its EFI file at “(hd0,gpt1)/EFI/BOOT/BOOTX64.EFI” (in its FAT32 partition). Some UEFI board may have other vendor such as Ubuntu, GRUB, etc. But, XServe doesn’t understand other vendor, yet. We could only use the default prefix where XServe’s EFI would search for EFI binary.

Don’t restart yet, because next is the most important one.

Fix GRUB2 EFI

You know why I used the “–debug”? It was because I kept on going to the GRUB Rescue mode with error message telling that GRUB could not found the proper disk. In the GRUB Rescue, I’ve found out that the prefix was wrong. The prefix was pointing to ” ((null),gpt2)/boot/grub”. Wew, that was wrong.

After I’ve found the problem, it seems that the “/usr/sbin/grub-install” didn’t generate the right prefix. From the debug, I’ve found the culprit:

I couldn’t found out what went wrong. The solution is to generate the EFI binary manually.

These two lines were the thing that the “/usr/sbin/grub-install” used incorrectly.

Configuring GRUB2 Settings

We need to add lines so that the screen won’t messed up. We disable the modeset and keep the screen resolution. Use:

and add  “nomodeset  gfxpayload=keep” to the “Linux command line:” option. Or edit “/etc/default/grub and put the string to GRUB_CMDLINE_LINUX.

THE END

After we install, we can do two things. First, we call update-grub to detect all of available kernels. And, we could add “/boot/efi” to “/etc/fstab”.

Last step is reboot and having your new system shines.

FIN.

UPDATE

As Isaac Alcocer pointed out on his comment, using the LTS Ubuntu 12.04 might be the easiest way. With it, you would only have to edit the GRUB.