Kategorie: Linux


Gentoo on a Mac Mini Server 2010

This is a how to install Gentoo on a brand new Apple Mac Mini Server 2,1. It turned out to be a bit tricky (in fact i wasted 5 days). So if you want to follow my guide, you should already be experienced with linux. I still provide a step by step tutorial. But please READ ALL THE MENTIONED DOCS first, before you start! How to read the following text:

# italic is a command line you enter in a terminal
italic is a line you add to a config file

blockquote is a config file

Well, to install an unencrypted linux on the Mac Mini was easy, but i wanted to install an RAID 1 with DM-CRYPT and LVM2 on the 500gb disks.

-1.) Howto install a regular Gentoo on a Mini
Now if you don’t need RAID, encryption and the logical volume manager, then its quite simple to install Gentoo. Just
- Install rEFIt
- Boot Live CD and install Gentoo according to the manual.
- Use LILO instead of GRUB and reboot.

0.) Now lets start with the tricky part.
But to add all the other features to the mac mini installation was not that simple. More or less we work with the three following HOWTOS

[1] The Gentoo Handbook
[2] HOWTO for LVM2, RAID, DM-Crypt
[3] HOWTO for GRUB2

And i will just refer to them as [1],[2],[3]. Something like “[1] / 10.b. Default: Using GRUB” refers to the section of document 1 ;) Again: Read them first and my article before you start anything. Also you should read the rEFIt documentation and all man pages of unknown commands.

1.) Preparing EFI
Apple does not use a regular BIOS, but an Extensible Firmware Interface (EFI). That means we have to tell the EFI, to boot other OS as well.

Boot your Mac Mini, download rEFIt from their website, open the .dmg file and install rEFIt.mpkg. Now you can switch between your OS when pressing “ALT” (on a windows keyboard) before starting the mac.

2.) Booting from a Live CD
Welcome to the first problem: The Mac Mini (4,1) , Mac Mini Server (2,1) and the new Mac Book Pros (Generation 8 ) use the nVidia MCP89 SATA Chip. It is not really supported by the kernel [UPDATE: SINCE 2.6.37 A PATCH FOR EHCI USB HOST IS PROVIDED, THERE IS NO NEED TO APPLY THE PATCH ANY MORE], so if you boot e.g. a regular Gentoo Install CD (or Debian), then you won’t find any drives or harddisks at all. A workaround is provided by Kernel >=2.6.36. Also Ubuntu 10.10 patched their 2.6.35 kernel to find this chip. Thats the Live CD i used.

Get the Ubuntu 10.10 Live CD from here. Boot your Mac while pressing “ALT”, in rEFIt choose “Windows CD” (yeah ;) ). Don’t just hit enter to boot Ubuntu, you’ll end at a black screen. Instead, in the first menu hit F6, activate “nomodeset” and then boot up Ubuntu.

3.) Installing additional things & stuff
Perhaps you want to change your keyboard first, but i’ll stick with the necessary informations: Ubuntu does not know LVM2 and RAID, but thats what we need for [2]. Open a terminal and install

# sudo apt-get install lvm2 mdadm

Now lets deal with the Hard Disks. Apple uses Guid Partition Table (GPT), i just have Gentoo running on the hard disks, no boot option for Mac OS X any more. So there was no need to keep any GPT signatures. I later deleted the 200MB EFI partitions as well.

# sudo parted /dev/sda and mklabel msdos

repeat for the second hard disk:

# sudo parted /dev/sdb and mklabel msdos

4.) Follow instructions
Until you have entered the chroot environment, don’t forget to use sudo, if you stick to my way (booting from Ubuntu). In case you are booting from any other cd and got a real root account, then of course you don’t need sudo.

After using parted, you can can just follow instructions from the HOWTOs. Start with [2] / Partitions till you have reached the Point [2] / Installation. Then you continue with [1] / 4.d. Don’t forget to activate the swap partition after making file systems!

# sudo swapon /dev/mapper/vg-swap

Mount all your partitions, unpack the stage3 file, portage tree, until you reach [1] / 7.b.

5.) Kernel configuration
You need at least a Kernel >= 2.6.36, get it from here. Keep in mind, you’re still in the chroot environment:

# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.tar.bz2
# tar xvjf linux-2.6.36.tar.bz2
# ln -s linux-2.6.36 linux
# cd /usr/src/linux
# make menuconfig

[2] / Installation tells you, that you need the Device Drivers + Crypt Support. But as you have no PS2 Keyboard, you also need USB + FULL HID installed, otherwise you have no chance to enter you password. Yeah, that happened to me… ;)

Device Drivers —> Multiple device drivers -> Device mapper support
Device Drivers —> Multiple device drivers -> Crypt target suport
Cryptographic API —>
Device Drivers —> HID Devices -> full HID support
Device Drivers —> USB support -> EHCI HCD (USB 2.0)
Device Drivers —> USB support -> OHCI
Device Drivers —> USB support -> UHCI

Yes, i got all three activated. When i got some time, i will update this howto and provide a minimal kernel config for the mac mini server.

# make && make modules_install
# cp arch/i386/boot/bzImage /boot/kernel-2.6.36

6.) Follow [1] until [1] / 10
Until you got to the point of installing a boot loader. If you really stick to the partition scheme from [2] you use this /etc/fstab:

/dev/md1 /boot ext3 noauto,noatime 1 2
/dev/mapper/vg-root / ext3 noatime 0 1
/dev/mapper/vg-swap none swap sw 0 0
/dev/mapper/vg-home /home ext3 defaults 0 2
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
proc /proc proc defaults 0 0

7.) Install Bootloader
Now it gets a bit tricky: Because GRUB does not know how to handle EFI, LiLo is easy to configure as long as you don’t use RAIDS, LVM and DM-Crypt. So we have to install GRUB2 and more or less continue with [3]. For now just tell /etc/portage/package.keyword to install grub-1.98 (don’t get confused, thats Grub2). Grub2 doesn’t like premounted /boot partitions. So we leave chroot, umount /mnt/gentoo/boot, reenter chroot and mount it from there:

# exit
# sudo umount /mnt/gentoo/boot
# sudo chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
# mount /boot

Furthermore Grub2 can’t really handle LVM volumes, so we have to patch it. Get the PATCH

# cp lvm-detection.patch /usr/portage/sys-boot/grub/files

Tell the ebuild to use the patch file:

# nano /usr/portage/sys-boot/grub/grub.198 ebuild

add the following line to the src_unpack section

epatch “${FILESDIR}”/lvm-detection.patch

then tell portage not to complain about the new file size

# ebuild /usr/portage/sys-boot/grub/grub-1.98.ebuild manifest

now finally install grub2:

# emerge -vat grub

8.) Create Initrd before installing grub
Follow [2] / Packages to create the initramfs. But there is one important modification:
/dev/mapper/vg-root is only a symlink to ../dm-1. If you just use the line from the HOWTO

cp -a /dev/console /dev/sda2 /dev/sdb2 /dev/null /dev/urandom dev

you end with an unbootable initramfs (sth. like “cannot open / create device node”). To avoid this, use

cp -a /dev/console /dev/sda2 /dev/sdb2 /dev/null /dev/urandom /dev/dm-* dev

instead! Then you can continue according to [2] and create the initramfs.

9.) Configuring Grub2
Thats where i became a bit lazy and tired of rebooting and rebooting all the time, so this is a quick and dirty work around, not really clean. First

# grub-mkconfig -o /boot/grub/grub.cfg

Then edit /boot/grub/grub.cfg

# nano /boot/grub/grub.cfg

(YES, i can READ: “DO NOT EDIT THIS FILE” -> it just means, you have to do this step every time you reconfigure grub2. Any helpful comment for a clean and neat solution is appreciated!).

and scroll till you find

linux /kernel.2.6.36 root=/dev/mapper/vg-root ro

below (but within the {} ) add:

initrd /initramfs

Now we install grub on both MBR (in case one of the disks fails we can still boot the raid from the second one:

# grub-install /dev/sda
# grub-install /dev/sdb

10.) Thats it!
Just leave the Chroot, umount everything and reboot. Don’t forget to hit “ALT” for rEFIt – then hit ENTER on any of the two partitions. Wait a bit, enter you password and then enjoy your new system. ;)

11.) Helpful commands & advices
If you screw anything up and you have to reenter the Chroot enviroment:

Press ALT, boot Ubuntu Live CD (nomodeset), then

# sudo apt-get install lvm2 mdadm
# sudo mdadm –assemble /dev/md1 /dev/sda1 /dev/sdb1
# sudo mdadm –assemble /dev/md2 /dev/sda2 /dev/sdb2
# sudo cryptsetup luksOpen /dev/md2 vault
# sudo vgchange -ay vg
# sudo mkdir /mnt/gentoo
# sudo mount /dev/mapper/vg-root /mnt/gentoo
# sudo mount /dev/mapper/vg-home /mnt/gentoo/home
# sudo swapon /dev/mapper/vg-swap
# sudo mount -t proc none /mnt/gentoo/proc
# sudo mount -o bind /dev /mnt/gentoo/dev
# sudo chroot /mnt/gentoo /bin/bash
# env-update
# source /etc/profile
# mount /boot

Also if anything goes wrong during the boot process, it helps to slow down the init file in the initramfs by adding a sleep 10 after every line.

So far so good, hope i was able to give something back to the linux community.

c7temp module

Friday night it took me several hours to get lm_sensors to work. Somehow Genkernel didn’t compile my modules the way i needed them, so i started to configure everything with make menuconfig && make. But thats another story…

My Hardware:Commell 66AD Mainboard, Via C7 1.5Ghz
Distribution: Gentoo x86.
Kernel: 2.6.27.5

Of course you don’t have to use the same kernel version as i did, but according to Debian Bug List, you need some Kernel >=2.6.24 !!!

Step by step tutorial:
1.) Install lm_sensors, emerge -vat lm_sensors.
2.) Run sensors-detect and let sensor-detect write the config file.
3.) Get the kernel source: wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.5.tar.bz2
and copy it to /usr/src/
4.) Unpack it tar xfvj linux-2.6.27.5.tar.bz2
5.) Link /usr/src/linux to your kernel version, ln -s /usr/src/linux-2.6.27.5 linux
6.) Download C7Temp Kernel Patch and copy it to /usr/src/linux .
7.) Patch the Kernel: cd /usr/src/linux/ && patch -p1 < attachment.bin
8.) Configure Kernel: make menuconfig
9.) You need I2C and Hardware Monitoring support: (Device Drivers —> I2C / Device Drivers —> Hardware Monitoring support), compile them as modules, in DD—>HMs —> check “VIA C7 temperature sensor” – that gives you the wanted c7temp kernel module
10.) Compile your Kernel make… ;)
11.) Update modules: update-modules
12.) Start /etc/init.d/lm_sensors, and if that worked, add it to Runlevel rc-update add lm_sensors default

If you want to patch your existing kernel, start with 6, and instead of recompiling the whole kernel in 10 just run make modules && make modules_install.

More to read:Lm_Sensors Mailing List

Via C7 Cflags

Just when i decided to move my Linux Computers from Debian back 2 Gentoo, the most helpful site – Gentoo – Wiki – is unavailable. If someone would be so kind and could tell me CFLAGS for VIA C7 cpus? That would be really helpful!

Furthermore i am actually redesigning my backup concept due to what happened to G-W.

UPDATE:
I found a copy of Gentoo-Wikis CFLAGS List at downpour.egloos.com. Problem solved…

CHOST=”i686-pc-linux-gnu”CFLAGS=”-march=i686 -mmmx -msse -msse2 -msse3 -O2 -pipe -fomit-frame-pointer”CXXFLAGS=”${CFLAGS}”

Follow

Bekomme jeden neuen Artikel in deinen Posteingang.