-   Linux - Laptop and Netbook (
-   -   MacBook dual Linux installation ...and if you want many others! (

valebilris 01-06-2008 11:41 AM

MacBook dual Linux installation ...and if you want many others!
After having big troubles with installing Linux on my new macbook I decided to post a simple (and incomplete :cry:) howto.
Googling around and spending much much time erasing and installing and erasing and installing ... I found some interesting things:
  1. an apple machine that borns with an os will never run an older os (macbooks included)
  2. rEFIt is only able to boot oses from the first 4 partitions on the internal disk (and from dvd-drive, and maybe from usb)
  3. leopard, which you pay for when you buy a macbook, and which you want to use, wants to be installed in one of the first 4 partitions
  4. leopard uses the first partition with a fat fs in it but leaves it empty (maybe for windows!? ...don't know)
  5. leopard needs to format your drive with EFI GPT UUID partition table (or whatever it is called :D )
  6. windows needs of course to be in a privileged position, and at this time I'm trying to install it... :study:
  7. a boot partition for grub, which makes all your Linux work, must be within the first 4 partitions

My problem was that EVERY howto is for installing a single linux in only ONE partition :(, which can be a problem for many reasons, unless you install osx and/or windows on an external drive or things like that which I din't like.

My configuration now is 9 GPT partition with Slackware-current, Ubuntu 7.10, osx and an empty partition for windows (which I haven't installed yet). The 3 are booting and running, but I'm still configuring them, so this guide won't help you configuring your macbook; for that you can google around.

What you need:
  • Slackware install dvd
  • Ubuntu 7.10 cd (NOT ALTERNATE, it didn't work for me!)
  • rEFIt (dmg version for osx)
  • a macbook, of course :)
  • kernel source
  • a working Linux console
  • lots of patience and time

I assume you know how to:
  • make a bootable custom slackware dvd
  • burn your bootable cds/dvds
  • compile a kernel
  • use vi
  • do many other things that I don't remember by now :o
If you don't, maybe you also don't need a 9 partition macbook =)

Before starting:
  • compile the kernel with support for GPT partitions and all mac stuff, with all your needs. Don't forget usb support which you'll need for backups etc!
    If you don't know what you need you can open extended info in osx (preinstalled or after step 1) or by putting in Ubuntu cd, booting it and "lspci -v" from a terminal, which, of course, is the better way :)
  • make a custom Slackware dvd with kernel just compiled
  • try it by putting it into dvd-drive and pressing alt (option key) when booting, it should boot and give you a console. try also parted (fdisk and cfdisk don't support GPT partitioning so, forget them.
  • please read all the steps before starting. There are missing parts for which I apologize.
  • I am not responsible for damages you do to your hardware/software and listed below is what functioned for me, I simply don't know how and if it will work on other configurations.

Let's start!
First step: Install osx.
By doing this you have to use DiskUtil, osx's tool for partitioning disks, which is available after agreeing with license from the upper menu. With that tool you have to make your partitions as would be in your final configuration.
Personally I made 8 partitions in my 250gb disk, with different sizes, for different needs. This is the result:
  • sda1 - 200MB fat32; well, actually I didn't, leopard's diskutil did...
  • sda2 - 300MB ext3; /boot partition with grub and kernels
  • sda3 - 70GB hfs+; this one is for osx
  • sda4 - 40GB xfs; /home
  • sda5 - 80GB xfs; this is for all other files
  • sda6 - 15GB xfs; this is Ubuntu's root
  • sda7 - 13GB ntfs; xp
  • sda8 - 1GB swap; this should have been greater (I have 4gb ddr2...)
  • sda9 - 20GB xfs; last but not least Slackware's root
The first one is hidden and made by default by leopard.
Note that diskutil leaves some empty space around the disk, between partitions (of course you'll notice that later, not within apple's tools).
You can leave future Linux partitions unformatted (in leopard they have taken away the possibility to create Unix partitions, so leave them empty), we'll format them later.
Using Tiger for partitioning and then installing leopard would end to a waste of time, because leopard needs (as said above) certain things for installing (tried also that way).
After partitioning your disk you have to install leopard and configure that, do whatever you want but do steps below

Second Step: Install first boot loader.
Download and install rEFIt just like any other osx application but remember to do
sh /efi/refit/
which blesses your drive.

Third Step: Install Slackware.
Put your brand new Slackware dvd into the drive and boot it (it should appear as a choice from rEFIt's menu; if not, reboot).
make a backup of your osx installation or the entire drive with dd.
save your partition table:
dd bs=512 count=10 if=/dev/sda of=/<somewhere-in-some-external-drive>
count=1 should be enough but I love doing space-wasting secure things :cool:.

dd bs=2048 if=/dev/sda of=/<somewhere-in-some-external-drive>
if you want all your drive, if=/dev/sda1 2 3... takes only one partition (which at this point is faster and safe, but remember sda with count).

After backing up you have to mount your Slackware partition somewhere
mkdir /mnt/linux /mnt/cdrom /install
mount /dev/sda9 /mnt/linux # sda9 is my Slackware /
mount /dev/hda /mnt/cdrom
cd /install
tar xzf /mnt/cdrom/slackware/a/pkgtools*.tgz
tar xzf /mnt/cdrom/slackware/a/tar*.tgz
export PATH=$PATH:/install/sbin:/install/bin
cd /mnt/cdrom/slackware
for dir in a ap d f k l n x xap; do cd $dir; installpkg -root /mnt/linux *.tgz; cd ..; done

Now you have to create your fstab, copy some stuff (like your kernel):
cd /mnt/linux
echo "/dev/sda9 / xfs defaults 1 1" > etc/fstab
mount /dev/sda2 boot
cp -r /boot/* boot/ ## initial kernel from live cd
cp -r /lib/modules/* lib/modules/

and run all necessary scripts, which I apologize, i don't remember but it looked like:
chroot /mnt/linux
passwd root

etc. I'm sorry I can't find the bookmark with the appropriate howto, but I'm sure you'll find it on the web =)

Fourth Step: Install second boot loader.
Boot from Ubuntu cd and open a terminal.
mount /dev/sda2 /boot
cd /boot && mkdir grub
echo "(hd0) /dev/sda" > grub/

create a file /boot/grub/menu.lst like this:
title slack12
kernel /MB2.6.23.9v0.1 root=/dev/sda9 ro
root (hd0,1)

and other stuff that you will find around like timeout=321 etc.
Note that (hd0,1) stands for /dev/sda2, which is the partition with your kernels, grub files, etc.

Install grub:
grub-install /dev/sda2

Grub must be installed on your boot partition and must be chainloaded from rEFIt. For me that was the only way it worked properly.
Reboot and you will find in rEFIt a penguin icon with the words "Boot Linux from Partition 3". enter it, wait few seconds and grub should appear. You should also be able to boot your Slackware Linux. Boot it and make a copy of /dev/sda2 (your boot partition) with dd as above, before moving to step five.

Fifth Step: Install Ubuntu.
Boot your Ubuntu cd and follow the installation being careful of three things:
  1. set manually your partitions;
  2. install the boot loader in your boot partition (not /dev/sda because this would take you to a non-booting system);
  3. let the installer format your /boot partition (that's why we did the backup!);

In the way you like (eg. by booting your Slackware dvd, which is by far faster than the Ubuntu one) restore your /boot partition simply inverting "if" and "of" in the command you typed to back it up.

Sixth Step: Setting up loaders.
Reboot using your Slackware dvd and enter in parted:
parted /dev/sda

Now you have to do nothing but write your partition table, for example by unsetting a flag that is not set: set 8 boot off
This is done because partitioning tool from Ubuntu does something I ignore and changes the partition table in a strange way.
Set up all your kernels in /boot/grub/menu.lst.
Note that for me changing root=/dev/sdax with root=UUID=really-not-human-understandable-thing (which is Ubuntu's default) ended in a kernel panic, so I changed all default UUIDs in /dev/sdx. Also tried grub 1.95: it compiled and installed ok but it stuck waiting in its shell when booting.

Reboot again in osx by holding alt key at boot time and restore refit using as above.

Reboot again and enter rEFIt's partitioning tool to update AGAIN your partition table.

Seventh Step: Installing windows.
I tried booting xp's cd but it found only the first 3 partitions on my drive. I Said the first three because xp sees some empty space (few MB, left by diskUtil) as a partition
I tried installing it into a different dirve and then copying with dd the entire partition over sda7 but I've only ben able to mount it in Linux, not to boot it as rEFIt boots only oses from first 4 partitions and grub simply didn't do the job.
I tried mapping the drive but the only thing happened is that grub restarted himself.
I tried mapping drives and booting the cd but somehow grub doesn't let me do that... googling around I found that you can only boot cds from other bootloaders by chainloading them after grub, so
I tried one of them and it did the same as rEFIt, it somehow canceled grub's mapping and booted the cd.

Yesterday I have bought a huge disk for backup and I'm going to remake all paritions, like this:
  • sda1 - 200MB fat32; EFI
  • sda2 - 13GB ntfs; xp
  • sda3 - 67GB hfs+; leopard
  • sda4 - 300MB ext3; /boot
  • sda5 - 20GB xfs; Slackware /
  • sda6 - 30GB xfs; /home
  • sda7 - 15GB xfs; Ubuntu's /
  • sda8 - 90GB xfs; this is for all other files
  • sda9 - 4GB swap; I have 4gb ddr2
By this way windows partition is moved to the first three, resolving (hope) that problem. Better in partition 2 because it sees your disk as a strange ...thing.
Swap partition has grown to 4GB because of the hibernate feature and because they say so :rolleyes:.

Eighth Step: Enjoy.
I hope this will be appreciated by someone, who, like me, bought a macintel and messed up with those stupid limitations imposed for some strange reason by a company that wants to make unhappy Linux users. :tisk:

valebilris 01-06-2008 02:59 PM

If you want to restore all your stuff or just try another configuration, leopard's diskutil crashes when trying to modify partitions. Fortunately dd comes to help! use it to overwrite the first kb of your drive that magically becomes writable. I'm doing this by the time I'm writing and guess what? ...this is not the only thing that doesn't work. After that you have to reboot because the installer is not able to see changes made...

Installing it again I found that diskutil don't let you make partitions smaller than 1GB, so I think at the time I did that I left empty space on the drive and partition it with parted... let me try...

...done partitioning, waiting for osx installer...

ok, it sees all partitions made (with parted) and after erasing the third partition (look at my second partition table posted) it finally became green!

after reinstalling the whole thing I found Ubuntu installer to install grub properly, and installing it from Slackware extras leaded me to a "Loading stage 2..." stuck grub...

Sorry for having said wrong things.

angel115 01-24-2008 12:40 PM

Hi Valebilris,

This is quite a nice one, however I still have few unanswered questions.
If you may help to answer them that would be wonderful :)

If I follow you correctly:
1 Does that mean that the SDA2 is the default boot partition even after a "rest PRAM"?

2. I've installed Linux on my iMac, every thing was fine until I reset the PRAM. now it keep booting on Mac OS and I can't access my Linux partition (which have a boot flag and was working fine before the reset PRAM)

Here is my partition table:
1 sda1: EFI
2 sda2: OSX Leopard (~40Gb)
3 sda3: ubuntu (~190gb)
4 sda4: SWAP (1Gb)

PS: I know this is a crappy design for partitions, I'll improve it later.

Anyway, using the beautiful Apple "startup disk" he doesn't see my Linux bootable partition (which I've boot on it many time until I reset the PRAM)
so here is my question:
how can I make my iMac to boot on the "sda3" partition?

Best regards,

valebilris 01-25-2008 01:17 PM

well, actually I've heard the first time about PRAM from you :scratch: but from what I've found here it contains simple infos.
Maybe just reinstalling rEFIt (you didn't mention if you've installed it) with "sh /efi/refit/" would do the job.
This is the first thing I would have tried.

For me the only partition with boot-flag set is the first, from what I can see in parted. other partitions have no flags.
rEFIt finds the other 3 partitions (sda2 3 4) and boots them with no problem.

angel115 01-29-2008 05:30 AM

Hi Valebilris,

I finally found the solution to my problem "rEFIt"

So every one which has the same issue can use it, it just work.


Best regards,

All times are GMT -5. The time now is 09:14 PM.