Gentoo Installation Guide

Orginally found on the Gentoo Wiki, the GNU Free Documentation license allows me to copy/paste it here.

Introduction
This guide should help you install and configure the proprietary graphics drivers from ATI. This guide applies for ALL versions of fglrx - it was made before the (rather dramatic) 8.8.25 January 05 release, but it is maintained such that all versions should work.


 * Note: If you are using an ATI 7500 Mobility (or such card that isn't supported by the ati-drivers) this HOWTO will not help.  Instead use the ATI kernel drivers. See also: http://forums.gentoo.org/viewtopic-p-2137276.html#2137276

Kernel Configuration
Get into menuconfig (cd /usr/src/your-kernel && make menuconfig) and check the following:

Sync your kernel menuconfig with the selected portions posted here. (note: you can compile /dev/agpgart & your agp chipset [most likely ati-agp] into the kernel if you want.)

Please be aware that -mm and -rc(1,2,3,4,...) kernels often break fglrx due to unexpected changes in syntax, etc. If you want to use ati-drivers, use the stock gentoo-sources or at the very least, a STABLE 2.4 or 2.6 kernel!

Don't forget to compile, install, and reboot into the kernel. Directions for this are beyond the scope of this file; if you need help recompiling the kernel, click here.

Preparation
Note: All next commands at a shell must execute as root!

For installation it will be easier to drop out of X to a command prompt. Do this using whatever command your Window Manager uses. I use fluxbox so it's just rightclick -> fluxbox menu -> exit. For KDE or GNOME it's probably just a matter of logging out. When all else fails, hit CTL+ALT+BACKSPACE to kill the X server ungracefully.

If the X server only reboots or for some reason you've disabled this hotkey bring the system run level down with: init 3

There is also the possibility to stop the xdm service: /etc/init.d/xdm stop

To prevent start at next reboot prevent the run script from execution with: rc-update del xdm

If you have not already done it recently, start by synchronizing your portage tree:

emerge --sync

Installation
Now let's install the drivers. Note: ati-drivers-extra is not available anymore.

emerge -av ati-drivers

The next step is switch to the ATi OpenGL subsytem:

eselect opengl set ati

Configuration of X
First, move your old configuration file (or delete it). cd /etc/X11 mv xorg.conf xorg.conf.old

This point was not necessary at my last tests, but do this if something failed. Make a standard config file: cd /etc/X11 Xorg -configure cp xorg.conf.new xorg.conf

Now lets make aticonfig the rest of configuration.

For a single screen:

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

For a dual head, second screen is {left|right|above|below}

aticonfig --initial=dual-head --input=/etc/X11/xorg.conf --screen-layout={left|right|above|below}

Adapt input with your path to xorg's conf file

If for some reason this command doesn't work, then try manually executing from its default location:

/opt/ati/bin/aticonfig [...]

Test your graphics card
Now, let's get back into X.

startx

Or start with init script and login:

/etc/init.d/xdm start

Open up a command prompt and run:

glxinfo

If the OpenGL vendor string says "ATI Technologies," then congrats! You've got the drivers working and hardware acceleration going great. If not...read on...

Test latest drivers
Getting the latest drivers will probably mean unmasking them before emerging.

echo "x11-drivers/ati-drivers ~arch" >> /etc/portage/package.keywords

Replace with your system architecture; it's going to be either  or, the only two CPU architectures supported by the ATI driver.

Wrong resolution
Often the EDID information can't read correctly from monitor. Therefore first remove all kms, hdmi switches or hdmi matrices between your monitor and output of your graphic card.

Config Files
By default, the driver uses the Internal AGPGART. Sometimes the internal one doesn't work, and you will have to use the one provided with the kernel. Search your xorg.conf for the line that has the option "UseInternalAGPGART." Simply change the "yes" to "no."

Now simply add the modules to where x is your kernel version.

Add the following (ORDER IS VERY IMPORTANT);

Finally, run

modules-update

Then you can reboot and everything should work. If you have are having problems, check dmesg and /var/log/Xorg.0.log for more info.

Blank screen or monitor turning off after startx
Versions of ati-drivers >= 8.16.20 (and probably <= 8.20.8) have an issue with this that's easily corrected by inserting:

in the device section of xorg.conf (discussed here: http://bugs.gentoo.org/show_bug.cgi?id=103028)

Check if you have a non-DDC monitor connected via VGA/HD15 connector. If so change your xorg.conf:

where HSync2 and VRefresh2 are your monitor parameters.

Also, try changing the MonitorLayout option. The default is "AUTO, AUTO", which is to say X will attempt to autodetect what kind of monitor you've got on the first and second display heads. This can theoretically fail (though I have never observed it). Try changing it around a bit. For example, if you have an LCD and no secondary monitor, change the line to read:

if you have a CRT, simply replace "TMDS" with "CRT".

Crashes on startup
If you are unable to use any 3d applications and get this error instead:

FGLTexMgr: open of shared memory object failed (Function not implemented) __FGLTexMgrCreateObject: __FGLTexMgrSHMmalloc failed!!! fglX11AllocateManagedSurface: __FGLTexMgrCreateObject failed!! FGLTexMgr: open of shared memory object failed (Function not implemented) __FGLTexMgrCreateObject: __FGLTexMgrSHMmalloc failed!!! fglX11AllocateManagedSurface: __FGLTexMgrCreateObject failed!! FGLTexMgr: open of shared memory object failed (Function not implemented) __FGLTexMgrCreateObject: __FGLTexMgrSHMmalloc failed!!!

Then you do not have tmpfs mounted on /dev/shm, which the driver requires. Make yourself sure you have tmpfs support compiled into kernel. It's under

File systems --> Pseudo filesystems --> [*] Virtual memory file system support (former shm fs)

To mount this, add to following line to (if it isn't there already):

Then just do a: mount /dev/shm

If the drivers still crap out on you, or for example you get a black screen on X init, try going into your system BIOS and change graphics-related stuff around. Believe it or not, for me my 9800 gives a black screen on X init if I have the AGP Aperture set at anything other than 128MB. I don't know what causes this, and I don't care; I'm just relating to you how I overcame my problem ;)

Also, whenever you update your compiler, you must recompile your kernel otherwise you won't be able to insert the fglrx module. Note that recompiling your kernel means you must also unmerge/emerge ati-drivers!

Duplicate symbol errors in X log
If you are unable to start X or X fails to load the fglrx driver and you have multiple symbol errors in your Xorg log, chances are that you have compiled X with the dlloader flag. This flag can not be used with the fglrx driver. To fix this problem, remove the dlloader flag by editing your /etc/portage/package.use file as follows:

Now re-emerge the xorg-x11 package and reinstall the fglrx driver.

Crashes on the exit of X.org / X won't shutdown
Perform the following if you can get the fglrx drivers working with hardware acceleration, but are suffering from a complete system crash when trying to quit X. You should boot into your system, login, then start on this. You don't need to boot into X, and shouldn't need to edit your xorg.conf file (as fglrx is already setup as the driver and working)

You've emerged the "stable" version of the ati-drivers, these are out of date -- remove them (emerge --unmerge ati-drivers), to add the most recent you should either add them to the keywords file (/etc/portage/package.keywords) or emerge your local ebuild (emerge /usr/portage/x11-drivers/ati-drivers/ati-drivers-8.22.5.ebuild) if you're told it requires a dependency, emerge the local e-build for that, then try again. (usually eselect-opengl is required.) Once you have the most recent ati-drivers emerged, run (eselect opengl set ati). Now you can (startx) and hopefully quit without any problems.

glxinfo says "error: failed to open DRM: Operation not permitted"
If a check with the glxinfo fails for ordinary users though works fine for root it might be related to filepermissions of the device-file. Here is how to solve it:

Make sure that the filepermissions on the card-device allows the video-group to read and write. The common group in gentoo with X is "video". All normal users should be part of this group. Also, the device must have permissions for this group to read and write the card-device.

Check the permissions on the card-device:

root:/#ls -lcF /dev/dri/card0 crw-rw 1 root root 226, 0 Oct 5 16:19 /dev/dri/card0

It can be changed with:

root:/dev/dri#chgrp video card0

Check if user is part of video:

paddlaren:~>id paddlaren uid=1000(paddlaren) gid=1000(paddlaren) groups=1000(paddlaren),10(wheel),11(floppy),18(audio),19(cdrom),80(cdrw),85(usb),100(users),35(games)

To add a user to the video-group:

root:~#gpasswd -a my_user video

paddlaren:~>id paddlaren uid=1000(paddlaren) gid=1000(paddlaren) groups=1000(paddlaren),10(wheel),11(floppy),18(audio),19(cdrom),27(video),80(cdrw),85(usb),100(users),35(games)

Logoff and on to ensure that the membership of the group is known to the system.