The Debian Universe


/read/online

^contents

4: Installing The X Window System

The modularity of Linux is one of it's strengths: if you want to run a headless server (that is, without a monitor) you don't need to install a graphical environment at all. However, that modularity can also be very confusing when you first start to use Linux because you may have trouble figuring out what things you need to install to get things working.

If you followed my basic Woody installation in the previous edition you'll probably be running a very sparse system now with nothing but an ugly (to some!) white-on-black text console, no graphical interface and no clue as to how to get one. If you'll be using your Debian machine as a desktop workstation that's probably not really what you want.

Never fear, Linux uses a very powerful and customisable graphical environment called the X Window System. The current version is 11R6, generally referred to as 'X11' or just 'X'.

Client-Server Architecture

X11is not really a product or even a software package, it's a standard that defines how a window system should operate. As a result there are implementations of X for just about every platform including Windows, MacOS, BSD, Linux, and the traditional Unix variants such as Solaris and Irix.

Unlike the graphical interfaces used on systems such as Windows and MacOS which have the interface tightly bound to the machine they are running on, X is split into 2 parts: a client and a server.

The 'X server' part runs on a machine with a monitor, keyboard and mouse, and performs the job of serving the graphical environment to the user. It's the bit that users actually see and interact with, or the 'face' of the system.

The 'X client' part runs on the machine that runs the software, and communicates with the X server to tell it what to display. However, it doesn't have to care about things like where a window is located on the screen, what the cursor looks like, or what kind of mouse the user has. That's all taken care of by the X server.

In most cases of course the X server and X client are actually on the same machine, but the fact that they are separated means you can do same really cool things like run a piece of software on one machine, but have its display appearing on a totally different machine. We'll get to that later.

Choosing A System

The dominant implementation for Linux is called Xfree86, which has been around forever and is also used on many other platforms. Some time ago Xfree86 went through a transition from version 3 to version 4, so at the moment there is a choice of whether to use v3 or v4. V4 is generally considered a little more experimental and offers a number of major improvements over previous releases, but it's been around long enough now that there's no real reason to consider v3 unless you are running very old hardware. For any halfway decent machine I recommend v4, which is what I'll step you through here.

The major reason I mention v3 here is that it's actually possible to have both installed at once, and that can lead to enormous confusion if things aren't working as you expect them too.

Just for future reference, or in case you've already got packages installed as a result of selecting them in tasksel or dselect, it's handy to know how to figure out which version is selected in your system. The choice of X server is done by pointing the symlink '/etc/X11/X' to the correct location. From the command line, type

ls -l /etc/X11/X

It will see it pointing to either '/usr/bin/X11/XFree86' (if v4 is selected) or something like '/usr/X11R6/bin/XF86_SVGA' (if v3 is selected). There are actually a number of different server binaries for v3 depending on what video card it has been optimised for so that destination may not exactly match your system, but it will at least be in the same directory. The binary I've listed above is for the default SuperVGA driver.

You can change which version is launched by deleting the symlink and recreating it with the correct destination.

In pretty much all cases though I'd suggest sticking to v4 for now.

Checking Your Hardware

Getting X going for the first time can be one of those hair-tearing experiences for a first-time Linux user, so I'll go through this in some detail.

The very first thing to do is make a note of what hardware you have. In particular, you will need to know:

o Make and model of your video card
o How much memory your video card has
o What sort of connection your mouse uses (eg: serial, PS/2, USB)
o Make and model of your sound card

There are some tools you use to help you find out these things if you aren't sure, so before we get started on installing X itself you should install a number of supporting packages:

apt-get install xutils discover mdetect

'Xutils' provides a variety of X-related utilities, 'discover' is a multi-purpose hardware detection tool, and 'mdetect' is a mouse detection utility. Parts of these packages can be used by the X installer if it detects them at the right time, so installing them now can make things easier for you later.

One of the most critical things before you go on to the next step is to confirm that you know what kind of video card you have. Included with the 'xutils' package is a handy little tool called 'scanpci', which will check your PCI bus to determine what cards you have installed. Note that this works for onboard video as well: your motherboard may have video on it directly rather than on a separate card, but as far as the system is concerned it will still behave as if it were a card.

If you aren't 100% sure what type of video card you have, type 'scanpci' as root to see a complete list of installed cards. This will show you all the PCI cards in your system, including some that aren't actually cards at all but are part of the motherboard, and one of them should have a description that matches your video card.

Installing Xfree86 v4.0

Now to start the actual X install: as root, type

apt-get install x-window-system

to fetch the main packages. The 'x-window-system' package doesn't actually contain anything itself, it's a meta-package that depends on a lot of other packages so you don't have to install them one by one. At this point you should see it install about 25 packages.

Once the packages have been downloaded you will be asked a series of questions about how X should be configured. The questions themselves are quite verbose, so I'll just paraphrase them here for simplicity.

Note also that if you installed xutils, discover and mdetect as I suggested you may not even be asked many of these questions at all: the system may be able to autodetect a lot of your hardware and just merrily skip over some things that it would otherwise have to ask you about. If you feel like trusting the system to handle some things automatically you can answer "Yes" when it asks if you want autodetection.

So, on to the questions!

Driver Settings

"Manage X server wrapper configuration file with debconf?"

There are several ways the configuration of X can be managed, but unless you know what you are doing it's best to have it managed by debconf for now. Answer Yes.

"Select the X server driver"

This question probably won't be asked if you chose to use hardware autodetection. Xfree86 supports a lot of different video cards through use of drivers optimised to suit each card. The list of drivers is quite long and some of the names may be a bit cryptic, so if you can't see one that directly matches the name of the card you use you may need to do a bit of research to find the right one. The best place to start is http://www.xfree86.org/current/Status.html, which lists the current driver status for a huge range of video cards grouped by manufacturer. Select the desired driver from the list, tab to "OK" and hit enter.

"Manage Xfree86 4.x server configuration file with debconf?"

See the comments above about managing the wrapper config with debconf. Answer Yes.

"Use kernel framebuffer device interface?"

There are several ways the system can talk to your hardware. I generally answer yes here, but if you have problems later you may have to come back and change it to no.

Keyboard And Mouse

"Please select XKB rule set to use"

This is basically asking you whether you want to use a different keyboard rule set. Leave it at the default: xfree86.

"Please select your keyboard layout"

This question lets you tell X what kind of keyboard you have (such as a 104 key keyboard, a 101 key keyboard, etc). Almost all modern keyboards are 104 key keyboards, even the ones that have extra multimedia keys on them, so most people will want to leave the answer as the default 'pc104'.

The next question about keyboard layout then asks you how you want the keys arranged on the keyboard: standard Qwerty, Dvorak, etc. When we were installing the initial Debian system it asked for a keyboard layout, but that only effects the settings for the console so we need to tell X what layout to use as well. As mentioned in the previous installment I use the Dvorak layout, so I'll enter 'dvorak' here, but most people will want a standart Qwerty layout with US-style currency symbols so you should probably just leave it at the default setting of 'us'.

"Please choose your mouse port"

Your mouse can be connected in a variety of ways: USB, PS/2, a serial port or as a bus mouse.

If you have a USB mouse, select /dev/input/mice.

If you have a PS/2 mouse, select /dev/psaux.

If you have a serial mouse, you need to know which serial port it is connected to. Linux uses its own way of labeling serial devices, so to figure out the equivalent to your PC's COM port you can convert it using this table:

/dev/ttyS0 = COM1
/dev/ttyS1 = COM2
/dev/ttyS2 = COM3
/dev/ttyS3 = COM4

Yes, I know, it starts the numbering from 0 not 1, but that's just the way programmers think. Something you'll find is that most things in Linux are done the way some programmer thinks is logical, not necessarily the way you may have seen it in the past.

Anyway, it's most likely that your mouse will be connected to either COM1 or COM2, so select /dev/ttyS0 or /dev/ttyS1 as appropriate.

"Choose your mouse type"

There are a number of models of mouse, with different numbers of buttons, scroll wheels, etc. Select the one that most closely describes your mouse. Unfortunately the labels in the list can be a bit confusing. For example, if you have a PS/2 mouse and selected /dev/psaux on the last screen, you need to choose PS/2 here if your mouse doesn't have a wheel, or ImPS/2 if it does. If you have an older mouse connected by a serial port, the choice should be more obvious.

Most modern mice use a PS/2 connection with a scroll wheel and mimic the behavior of the Microsoft Intellimouse, so most people will want to select "ImPS/2" here.

Monitor Selection

"Is your monitor an LCD device?"

If you have an LCD monitor, X can do sub-pixel smoothing to make everything look nicer. If you have an LCD, say yes. If you have a normal (CRT) monitor, say no.

"Method for selecting monitor type"

At this point the installer diverges down one of three tracks, depending on how much information you have about your monitor and your level of expertise.

If you have no idea what the parameters of your monitor are, choose simple and you will then be asked a very basic question about how big your monitor is. This system will then pick a conservative configuration that should at least get you working, even if not at the best possible settings.

If you know a bit about your monitor, such what resolutions it supports, choose medium to select the supported resolutions from a list.

If you know all the details of your monitor, such as the maximum horizontal and vertical refresh rates, select advanced. The trickiest one to work through is the advanced option so I'll do that here as an example: if you don't know all the details of your monitor you should choose simple or medium, which you should be able to work through by yourself.

"What is the horizontal scan frequency of your monitor?"

I won't even bother trying to explain what this means, but what you need is a rating for your monitor that looks something like "30-90". Your monitor will have both horizontal and vertical scan frequencies, and they'll be similar but not identical so make sure you enter the right one in the right place! Getting the scan frequency wrong can actually cause physical damage to your monitor in extreme cases, so if you're at all unsure about this you should choose the simple or medium setup option and let the installer pick conservative defaults for you.

"What is the vertical scan frequency of your monitor?"

As before, you need the actual rating for your monitor, and it will look something like "50-160".

"What resolutions do you want to use?"

You can tell X to support a number of different resolutions, and allow you to switch between them at will. You will see a list of possible resolutions with an asterisk next to the ones that will be enabled by default. Use the arrow keys to select resolutions and the space bar to toggle the selection, then tab across to "OK" and hit enter.

The resolutions you select will depend on the size of your monitor, your video card, and your eyesight, but for a typical 17" monitor with a recent video card you'll probably want to select 640x480, 800x600 and 1024x768as a minimum. Many people run their monitors at higher resolutions to fit more on the screen at once, so if you have a recent video card and don't mind small text you could also select 1280x1024 and perhaps 1600x1200.

"What color depth do you want to use?"

The colour depth determines how many colours the system can display on screen at one time. A higher colour depth means more colours, which makes colour graduations much smoother and everything generally look better. Greater colour depth means your video card needs more memory though, so unless you've got a card with a decent amount of memory you may need to make a trade-off between colour depth and resolution.

The colour depth options worth considering are 24 and 16 bit. 24-bit colour gives you the equivalent of millions of colours, and 16 will give you less colours while still looking fairly decent. As a general rule of thumb, any recent video card should have at least 16MB of memory and support 24 bit colour at a resolution of 1280x1024. If you have less memory, such as 8MB, you could drop to 16 but colour or a lower resolution, but if your card has less than 16MB of memory it's really about time you bought a new one. 16MB and 32MB video cards are dirt cheap nowadays.

After all those nasty questions the installer will grind away for a while putting everything in place, then you'll end up back at the command prompt and still not have a working graphical interface! Don't worry, we're almost there.

At this point you could actually run a basic X session, but it would be very sparse and you'd probably still be totally lost because you won't have a desktop manager to help you find your way around. Next we'll install the things you need to have a complete graphical desktop environment.

While they are not the only options, there are two major desktop manager projects for Linux: Gnome and KDE. I don't want to start another religious war here, both have their strengths and weaknesses but my personal preference is for Gnome so that's what I'll take you through.

The Gnome Desktop

The Gnome desktop is a large project that encompasses a lot of sub-components, and provides you with all the things you would expect from a graphical desktop: icons you can click on, folders you can open, and menus to launch software.

Installation

To install all the different components for a basic Gnome desktop, type:

apt-get install gdm gnome-session gnome-core gnome-control-center gnome-panel sawfish-gnome

Once again that will also cause a whole pile of other packages to be installed as well, and you'll be asked some configuration questions.

One of the first questions will be what to use as the default display manager. Xdm (the X Display Manager) will probably already be installed as a result of installing basic X components, but we want to switch to gdm (the Gnome Display Manager) so select gdm from the list and hit OK.

"Default papersize"

Default (a4) is good enough for me.

After that your machine will busily amuse itself for quite a while as it unpacks all the packages it needs. There is a lot of software in Gnome.

Once it's finished you are about ready to start your graphical desktop for the first time. First we need to make sure we can get out of it if things go wrong, so we're going to stop gdm from starting up every time the machine boots. We can do that by going to the directory that controls the startup scripts that Linux will run by default, and telling it not to start gdm on boot:

cd /etc/rc2.d/
mv S99gdm K99gdm

I won't explain the system initialisation scripts just yet, it should be enough for you to know that anything in this directory with a name starting with "S" is run on startup while anything starting with "K" is not.

The reason for doing this step is that if everything goes screwy and X ends up in a very broken state, you can restart the machine and have it come back up to a plain old console so you can debug it. Then, when everything is working fine, you can go back into the same directory and rename the file back to "S99gdm" if you want X to start automatically whenever the machine boots up.

OK, ready to give it a try? Cool. Type

/etc/init.d/gdm start

and watch what happens.

The screen should go black, and after a second or two you should see the gdm login screen appear. If so, you can give a little cheer!

Debugging

However, if it didn't actually work and instead you've ended up with a blue screen (please don't point out the irony!) telling you it couldn't start the X server, it's time to do a bit of debugging. Accept the system's offer to show you the X server output and scroll to the end to have a look at any lines starting with (EE). That's the error that caused X to abort. Above it will be information that may help you determine what caused the error.

At this point there is no way I could predict all the possible things that could have gone wrong with your particular system, so you'll just have to Google for people that had similar error messages and how they solved the problem.

Hit enter to dismiss the error log, then the next screen will ask if you want to run the X configuration program. I've never been able to get it to give me any sensible assistance, so I always so "No" to that, then "OK" to the next screen that says X will be disabled for now. You'll then end up back at the console.

One thing I've seen a few times though is that the use of the kernel framebuffer device interface (remember that question all those pages ago?) can make X fail inexplicably at this point, so it may be worth trying again with it turned off.

From the console, you can re-run the X configuration by typing

dpkg-reconfigure xserver-xfree86

You'll then be run through all the questions again, with the difference that it won't attempt hardware autodetection and it will pre-enter the previous answer to each question. As a result you'll probably see a lot more questions than last time, but they should have reasonable answers already entered.

Once you've gone through it again and changed what you need to, type

/etc/init.d/gdm restart

to tell gdm to try starting again.

Logging into GDM

Whew! Hopefully you are now looking at a screen with a window in the middle asking for your username. Type in the username you selected for your normal (non-root) user when you installed the basic system, and hit Enter. Then type your password and hit Enter again.

You'll now see the Gnome splash screen, followed by the actual gnome desktop along with a startup hint, menu bars etc.

Copyright 2003-2004Jonathan Oxer. All rights reserved.
-:Site powered by Internet Vision Technologies:-