IMac Aluminum

From ArchWiki
Revision as of 06:52, 23 October 2008 by Handy (talk | contribs) (Added link to download backlight from my web site, until I get around to learning how to use ABS)
Jump to navigation Jump to search


Aluminium iMac Installation & Setup Guide:

I have written the following in the hope that it may help those investigating the installation of Arch on their iMac. Parts of this guide are specifically for the Alu' 20" & 24" iMac, though some of the following can also be used as a helpful guide for an initial Arch install on any computer.


I have an aluminium 24" iMac, on which I have just (at the time of writing) installed Arch 64bit, twice! I had a serious problem logging into Gnome & anything that required the root password failed. I worked around these problems but was never happy with the setup. I think that the iMac aluminium keyboard may have caused the problem, due to it not having a num-lock key, or an LED to indicate num-lock on/off; my passwords were numerical. Of course I may be wrong. My second install was done with an MS Digital Media keyboard & I don't have the above problem, also my ctrl-alt-Fkeys work now.


Deleting OS X?

Some people seriously consider dropping OS X altogether. I personally think that there is a good reason to keep a small OS X partition, as it allows you to be able to do firmware updates. Some people use an external USB or Firewire drive with which to boot OS X for the firmware updates, & I have heard that people have been able to do it via optical drive, from experience I do not know about these other methods. In the future I will find info' on those topics & supply links here.


rEFIt First

In preparation of an Arch (or any other Linux/BSD based OS for that matter) install, the first thing to do is install rEFIt [1] on your OS X partition. It is also possible to edit the refit.conf file so that Arch will be the default boot OS, see here: [2] it's the very last section of the refit.conf, basically you just uncomment legacyfirst. The only other option in refit.conf that most users will want to configure is the timeout number, (which is located quite close to the start of the refit.conf file) by default it is 20 seconds, I set it to 5 seconds.


Partitioning & Filesystems

There are multiple ways to repartition the iMac drive, my favourite (probably because it is the easiest & being graphical it is most likely the safest) is to boot the Ubuntu 7.10 (or later) LiveCD & run GParted from the desktop menu. I have shrunk the OS X, HFS+ partition, created Ext3, JFS & Linux Swap partition, deleted & moved partitions on the iMac using GParted & the Ubuntu LiveCD. Great stuff! The only present limitation that GParted has with the HFS+ file system, is that it can only shrink the HFS+ file system & can not enlarge it. I'm sure it won't be too long & this limitation won't exist either.

Just a note on using GParted, or any other GUI type of partition management tool, it is generally accepted to be good safe practice to only Apply ONE process at a time. What that means for those unfamiliar with GParted (& the other applications of it's ilk) is you can give it multiple instructions which it stores up until you hit the "Apply" button, after which it goes through the instructions one after the other. If this doesn't make sense now, it very quickly will on using GParted.


My iMac partition scheme is as follows:

Partition...Filesystem......Size.........Mountpoint

sda1 ........ *FAT32* ....... 200Mb .... EFI system partition - While the ESP looks like a FAT32 volume, it is actually an EFI file system, which you want to know how to replace before you delete it. This means don't delete it unless you are sure that you know what you are doing, as it may become essential to Apple firmware updates in the future. Currently the ESP is empty & the firmware boots OS X directly!? At least it is only 200Mb's wasted drive space, though more importantly it counts as one of the four partitions that can be seen by Apple's newly adopted GPT partitioning scheme. More on GPT in the following paragraph.

sda2 ......... HFS+ ........... 50Gb ..... OS X - After thinning out OS X some & keeping tools I use plus iWork, CrossOver Games & Guild Wars, I have about 25Gb of free space to play with here, & for the odd game that may arrive in the future (Guild Wars 2). :D

sda3 ......... Ext3 ............ 15Gb ...... / - Arch - there is currently 12Gb free, it is a new install though.

sda4 ......... JFS .............. 30Gb ...... /home - that should be more than enough space for me there, & I can always resize with GParted.

sda5 ......... Linux Swap .... 2Gb ..... swap - rarely if ever used, but I have the space. It is questionable as to whether this partition needs to exist at all.

sda6 ......... JFS ............ 200Gb ...... /thevoid - storage for video's music, unsafe backup, whatever...


The GPT partitioning scheme that Apple uses

[3] allows OS X to only see 4 partitions, so be sure to install your boot loader i.e. GRUB/Lilo, & any other partition that you may want OS X to see (like a shared FAT32 data drive) on sda3 & sda4, Windows must also be on sda3 or sda4. Partitions beyond Apple's imposed limit of 4 can still be created & used, e.g. Linux Swap, & other partitions, but they won't be accessible by OS X or directly bootable, though I see no reason why a boot loader like GRUB positioned on sda3 or sda4 could not boot other OS's on partitions numbered greater than sda4. This certainly does place limitations on what we can do. If you require more than this scheme will allow you, you could do away with OS X, & set up the drive on MBR only, using an external drive with OS X on it to update the firmware.

So just to sum up on all of this partitioning stuff, if you have need to use sda3 & sda4, be sure to put any swap partitions on a partition number greater than sda4. Also, it is worth considering not using a swap partition at all, as the only computers running Linux/BSD with 1 gigabyte of RAM that use their swap file are doing intensive specialized work such as video editing, sound recording/editing, 3D modeling...

When partitioning is finished you must restart the iMac & re-sync your partitions with rEFIt, which is quick & easy: You choose to start the partitioning tool in the rEFIt boot-menu & follow the very simple instructions there.

rEFIt may prefer to have partitions in numerical order on the drive, i.e. sda1, sda2, sda3, sda4, sda5, sda6 ... & not shuffled. This is unconfirmed, any feedback on the subject will be appreciated.

Then reboot & hold down the C key, or wait as I do for the rEFIt boot-menu to appear & choose to boot the Arch install CD.

Install Arch

I used both the Arch Beginners Guide [4] & the Official Install Guide [5]. I used the Core install from the CD & updated later, so I don't know how easy the FTP install sets up, the CD install & network setup went perfectly for me. The Beginners Guide has all that was necessary for my install, though I used the Official Guide to further my understanding, as well as other pages in the Arch wiki & elsewhere, many of which are linked to in this guide.


Installing & Configuring X

When installing the Xserver, [6] I installed as though I was not going to use the proprietary ATi drivers (now called Catalyst), this allowed me to use both the vesa & the xf86-video-ati open source drivers. I only did this out of what turned out to be a false sense of fear of the approaching fight to get ATi's Catalyst drivers to work. I think if I were installing a third time I would go with vesa first & then install the Catalyst drivers. I did find that there were some problems with both the vesa & the xf86-video-ati drivers, that may have been able to be fixed by someone who knows how to configure the xorg.conf file better than I. According to /var/logs/Xorg.0.log the size of the screen was a problem for the xf86-video-ati driver, I didn't look too hard for what was upsetting the vesa driver's colours when in an X session.

Prior to the installation of the ATi Catalyst driver I installed hwd ( pacman -S hwd ) & then used hwd to create my first xorg.conf, which worked well enough for me in both installs (see above) to progress to the installation of the ATi Catalyst drivers; you must use the aticonfig file (provided in the Catalyst installation) to install the drivers & create the new ATi xorg.conf. The command that most users would use is the following:

aticonfig --initial --input=/etc/X11/xorg.conf

I must say that my first installation of the ATi Catalyst drivers on Arch was faultless, on the second install I needed to edit the xorg.conf screen resolution from 1600x1200 to the correct 1920x1200. The refresh rate for the monitor is set at 60Hz, hopefully this is correct, I can find no information on the refresh rates of the iMac's 24" screen?

Even though the aticonfig generated xorg.conf needed an easy tidy up due to internal duplication of some sections both times I installed Arch, it worked, & booted Gnome, from where I did my xorg.conf editing to clean it up.

Finally, the Arch install of the ATi Catalyst drivers for the iMac works very well indeed, which certainly was an unexpected surprise to me! Though I must state that at the time of writing the ATi Linux drivers still have quite a way to go to reach the standard of those from nVidia.


Installation of Valuable Tools

  • Sudo

The sudo command is used to easily execute root commands: [7]

By entering visudo at the terminal you automatically open the sudoers file for editing.

The following is all you will need to know to use visudo (though it is a specific use of the vi(m) text editor an incredibly powerful & complex tool used by many programmers). Visudo is the default way to edit your /etc/sudoers file, (there is a command that allows safe use of other editors which I won't go into here):

After you start visudo (vim), you're in command mode.

* Switch between modes

1. From command mode to insert mode, press i

Enter some text.

2. from insert mode to command mode, press ESC

You are now in command mode. Vim is waiting for your commands. Notice if you try typing, you get weird and unexpected results, because, well, you need to learn some commands, and Vim is not in insert mode.

3. Press ESC again to make sure you are truly in command mode and press : (colon)

Now you are in ex, which will allow us to save your first file. Type:

wq

for write and quit.

Your file is written and vim will exit.

If you search sudo you will find a variety of things that can be done to configure the /etc/sudoers file to suit your needs.

To install: pacman -S sudo


Gnome Installation

The Arch Beginners Guide gives very good instructions for the installation & basic setup of Gnome, searching for Gnome in the Arch wiki will bring up more useful information regarding Gnome, & the following site [8] I found extremely helpful in vetting the available files supplied in the installation of Gnome via the pacman -S gnome & the pacman -S gnome-extra commands, if you are not a Gnome expert this site makes it so easy & safe to customize your Gnome install making sure that you know what is essential for Gnome to run; you can always add any of the packages that you left out at a later date by simply running pacman -S (whatever you want?).


Gnome Configuration Tips

Once Gnome is installed there are a few essentials that I like to use, the majority of which require installation; knowing about these can certainly save a new user a great deal of time:


GDM Setup

If you prefer an automatic login to Gnome then the easiest way is to use gdmsetup: run it, sudo gdmsetup go to the Security tab, & tick Enable Automatic Login, add the user name to the User: field. If you want to be able to Log Out of your normal user account & Login to Gnome as Root, then you need to go further down gdmsetup's Security panel & tick Allow Local System Administrator Login. Be very careful about any further editing of gdmsetup, it is possible to make things very difficult for yourself if you don't know what you are doing.

To install: pacman -S gdmsetup


  • gconf-editor

A powerful Gnome configuration editor which I use to bring back the directory column in Nautilus, as I don't like to use Nautilus without it (personal taste I know). To do this you can enter gdonf-editor in the terminal, or use the Gnome menu - Applications - System Tools - Configuration Editor: When running, expand the apps directory, then scroll down to nautilus & expand that directory, scroll down to preferences & select it, then in the right hand window find always_use_browser & place a tick in the box to select this type of nautilus display then close the dialog.

To install: It is part of your Gnome installation.


  • Alacarte Main Menu Editor

Is vastly superior to the default Gnome menu editor.

To install: pacman -S alacarte


Installation Of The (my) Essentials

Following are my personal essentials that must be installed before I consider my installation somewhere near complete. We all have our own favorite's I know, though hopefully someone may find the following helpful?

Sets up & manages Tor - The Onion Router - [10] beautifully & easily, I have been using vidalia on Linux & OS X for some time, it is worth investigating Tor with regard to your online anonymity.

Install via AUR


  • Firefox

The popular web browser.

To install: pacman -S firefox


  • VLC

The popular & powerful media player: [11].

To install: pacman -S vlc


  • libdvdcss

This library is required to play CSS protected DVD's (99% of commercial DVD's). It is illegal in the U.S. & possibly a few other countries, so check out the legalities if you think you must?

To install: pacman -S libdvdcss


  • bin32-wine

Wine: [12], I use Wine to run DVDShrink 3.2, as it is still the most reliable solution for ripping DVD's on my hardware. K9Copy is getting better all of the time, & it is only a matter of time before it is better than DVDShrink (on my system), I do look forward to that day. I also run Smartripper under Wine, as there are rare occasions that I need to use it to rip something that DVDShrink could not handle.

Install via AUR


  • NeroLinux

I use this commercial software for the same reason I use DVDShrink; from experience, on my hardware it is the most reliable solution. As K3B continues quickly developing the day is coming when NeroLinux will be superseded on my machine by a great OSS alternative.

Install via AUR


Controlling the screen brightness:

Below is the C code for a little program that adjusts the brightness on many LCD Apple screens. It is easy to compile & setup using the following instructions, if however you would prefer to just download the tiny precompiled file & continue following the instructions you can get it off my website:

http://www.users.on.net/~thehands/


The instructions follow:

Copy & paste the C code (found below these instructions) to your /home. Save the code as a file, backlight.c

Now open a terminal in the directory where backlight.c is located.

Type the following in the Terminal:

gcc -o backlight backlight.c

You now have a program called backlight. It should adjust the brightness.

To change the brightness, you have to have direct access to video memory, which means that you have to be superuser (root).

Type su, then your root password when prompted.

Now test the program by typing ./backlight 10 in the terminal.

You can give it values from 1 to 15. Find a value you like.

Now enter the following in the Terminal:

cp backlight /usr/local/bin.

Which copies the program to the standard location for user installed programs.

Next, to run it at startup. Still as root, edit /etc/rc.local. Add a line saying /usr/local/bin/backlight N, where N is the number code you want for the brightness.

That should do it.

Source:

/*
* Apple Macbook Pro LCD backlight control
*
* Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
* Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/

#include <stdio.h>
#include <sys/io.h>
#include <stdlib.h>

void init()
{
    if (ioperm(0xB2, 0xB3, 1) < 0)
    {
        perror("ioperm failed (you should be root).");
        exit(2);
    }
}

int get_current_value()
{
    outb(0x03, 0xB3);
    outb(0xBF, 0xB2);
    char t = inb(0xB3) >> 4;
    return t;
}

int calculate_new_value(const char *arg)
{
    int val, new = atoi(arg);

    if (arg[0] == '+' || arg[0] == '-')
        val = new + get_current_value();
    else
        val = new;

    if (val > 15)
        val = 15;
    else if (val < 1)
        val = 1;

    return val;
}

int main(int argc, char** argv)
{
    if (argc > 2)
    {
        printf("Usage:\n");
        printf("%s : read current value\n", argv[0]);
        printf("%s value : write value [0-15]\n", argv[0]);
        exit(1);
    }

    init();

    if (argc < 2)
    {
        printf("Current value : %d\n", get_current_value());
        exit(0);
    }

    if (argc == 2)
    {
        int value = calculate_new_value(argv[1]);
        outb(0x04 | (value << 4), 0xB3);
        outb(0xBF, 0xB2);
        printf("new value: %d\n", value);
    }

    return 0;
}


Getting sound to work in Arch for the Alu' iMac 20" & 24" models:

Add the following to /etc/modprobe.conf

options snd-hda-intel model=imac24

Then restart computer or the sound system.

Using the above gives a very workable alsamixer, the sound quality is still 2nd rate (as ALSA still has a way to go) so using VLC & its mixer is very helpful when watching DVD's. I have not tested the line out or mic, though I believe that they are working properly with this configuration.


A forum thread regarding installation of Arch Linux on the iMac can be found here:

http://bbs.archlinux.org/viewtopic.php?id=35355