Monday, July 24, 2006

X11 Dual Head with nVidia

This is more a reminder for myself than a regular post. Because I have been fiddling around with the xorg.conf to get my Linux desktop right with dual head and the right resolution on each screen, I post my configuration here. If anybody finds it useful, they are welcome to copy it.

I am currently using Ubuntu 6.06 (Dapper Drake) which comes with X.Org 7.0. My machine has a GeForce 5600XT based graphics board by LeadTek. It has a DVI-I and a VGA port. I installed the closed-source nvidia driver to get hardware acceleration and extended features the X.Org nv driver does not provide. Moreover I could not get dual head right with the X.Org driver.

The following configuration sets up two screens, one for the left display (analogue TFT, 1280x1024) and one for the right (CRT, 1024x768).

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "Files"
 FontPath "/usr/share/X11/fonts/misc"
 FontPath "/usr/share/X11/fonts/cyrillic"
 FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
 FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
 FontPath "/usr/share/X11/fonts/Type1"
 FontPath "/usr/share/X11/fonts/100dpi"
 FontPath "/usr/share/X11/fonts/75dpi"
 # path to defoma fonts
 FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Section "Module"
 Load "i2c"
 Load "bitmap"
 Load "ddc"
# Load "dri"
 Load "extmod"
 Load "freetype"
 Load "glx"
 Load "int10"
 Load "type1"
 Load "vbe"
EndSection

Section "InputDevice"
 Identifier "Generic Keyboard"
 Driver  "kbd"
 Option  "CoreKeyboard"
 Option  "XkbRules" "xorg"
 Option  "XkbModel" "pc105"
 Option  "XkbLayout" "de"
 Option  "XkbVariant" "nodeadkeys"
EndSection

Section "InputDevice"
 Identifier "Configured Mouse"
 Driver  "mouse"
 Option  "CorePointer"
 Option  "Device"  "/dev/input/mice"
 Option  "Protocol"  "ExplorerPS/2"
 Option  "ZAxisMapping"  "4 5"
 Option  "Emulate3Buttons" "true"
EndSection

Section "Device"
 Identifier "nvidia0"
 BoardName "GeForce FX 5600XT"
 Driver  "nvidia"
 BusID  "PCI:1:0:0"
 Screen  0
 #SINCE NVIDIA VERSION 1.0-8756 YOU MUST USE UseDisplayDevice INSTEAD OF ConnectedMonitor TO GET XINERAMA WORK:
    #Option "ConnectedMonitor" "CRT"
    Option "UseDisplayDevice" "CRT"
    Option "NoLogo" "0"
    Option "RenderAccel" "true"
    Option "AllowGLXWithComposite" "true"
    Option "UseEdidDpi" "FALSE"
EndSection

Section "Device"
 Identifier "nvidia1"
 BoardName "GeForce FX 5600XT"
 Driver  "nvidia"
 BusID  "PCI:1:0:0"
 Screen  1
 #SINCE NVIDIA VERSION 1.0-8756 YOU MUST USE UseDisplayDevice INSTEAD OF ConnectedMonitor TO GET XINERAMA WORK:
    #Option "ConnectedMonitor" "CRT"
    Option "UseDisplayDevice" "CRT"
    Option "NoLogo" "0"
    Option "RenderAccel" "true"
    Option "AllowGLXWithComposite" "true"
    Option "UseEdidDpi" "FALSE"
EndSection

Section "Extensions"
 Option "Composite" "Enable"
EndSection

Section "Monitor"
 Identifier "H750"
 Option  "DPMS"
 
EndSection

Section "Monitor"
 Identifier "Amaga"
 Option  "DPMS"
EndSection

Section "Screen"
 Identifier "Screen0"
 Device  "nvidia0"
 Monitor  "H750"
 DefaultDepth 24
 SubSection "Display"
  Depth  24
  Modes  "1280x1024" "1024x768" "800x600" "640x480"
 EndSubSection
EndSection

Section "Screen"
 Identifier "Screen1"
 Device  "nvidia1"
 Monitor  "Amaga"
 DefaultDepth 24
 SubSection "Display"
  Depth  24
  Modes  "1024x768" "800x600" "640x480"
 EndSubSection
EndSection


Section "ServerLayout"
 Identifier "Dual Head Layout"
 Screen 0 "Screen0"
 Screen 1 "Screen1" RightOf "Screen0"
 InputDevice "Generic Keyboard"
 InputDevice "Configured Mouse"
 Option  "Xinerama" "On"
EndSection

Section "DRI"
 Mode 0666
EndSection

Wednesday, July 19, 2006

Fedora Core 5, Part 1

Now this is the late "Part 1 of 2" (Part 2 was published first). Took me longer than expected, but I finally got it done.

In the beginning there was Windows...

I have been working with all versions of Windows starting with 3.0 on a 386SX16. Over the years I have gained extensive knowledge about many aspects of the inner workings, the weaknesses and strengths. Up to now I have been using Windows XP as my "main" operating system. It certainly has its flaws, but all told it is a fine piece of software.

I also believe to have a somewhat profound insight into Linux. I started with Debian Potato and have since used both newer Debian versions (Woody and Sarge) as well as several flavors of Red Hat (beginning with RH9, up to FC5) and some SuSE, too. Right now I am using Ubuntu Dapper Drake 6.06 to write this. However the majority of the Linux systems I work with are servers, most of them without even running X11.

While I have always liked Windows as a desktop OS I have become more and more annoyed by the plethora of worms and viruses that have surfaced over the last few years. Moreover I do not like the direction that Microsoft is taking. I was skeptical when the first versions of XP required you to activate your copy, but I could live with that, because independent sources found it to be anonymous (enough). However this whole "genuine advantage" thing they are doing now, collecting more and more information about your hard- and software, hash-values of the BIOS and other stuff is just what people were careful about before, but now they seem to accept it. Well, I decided, I will not. As a Java developer I luckily do not necessarily have to work on Windows. All my favorite tools are there on Linux, too; Eclipse, MySQL and whatever else I need. Ok, I admit that I will probably not get rid of Windows completely, but maybe a VMware setup will do. Now that the VMware server is available for free, this could be an interesting alternative.

The question for me just was: Which distribution suits me best as a Windows replacement?

Fedora Core 5

Dual Boot

First I tried FC5 as a replacement, because from what I heard it was a good choice for up-to-date software and a broad community supporting it. So I installed it on a separate hard drive to see if I liked it.

Doing so I came across a number of issues that I think will make many people (continue to) think of Linux as not (yet) ready for the desktop. Most of those are really small things and quite easy to fix, but combined together they can really annoy people that are not too much interested in how the system works, but just want it to let them do their daily work.

The thing I found most annoying was that the setup program did not get the dual boot with Windows right. XP got integrated into the grub.conf file automatically, however the installer did not take into account that it was installing Fedora on a different disk. This produced a not-working grub menu entry. I could not boot Windows, except through changing the boot drive in the BIOS setup.
I had to manually make grub swap the drive order which finally allowed me to boot into Windows again; this is something the installer should definitely take care of! I do not want to know how many people managed to cause real damage while trying to get back to their other operating system(s). So for anyone interested, this is my config (grub.conf, Windows on /dev/hda and Linux on /dev/sda):

title           Microsoft Windows XP Professional
root            (hd1,0)
savedefault
makeactive
map             (hd0) (hd1)
map             (hd1) (hd0)
chainloader     +1

Graphics Setup

Concerning graphics, the installer set up a single monitor configuration, using the free nv driver. I was impressed to find a "Dual Head" tab in "System-Administration-Display" which offered to simply choose the type and resolution of the second monitor.
This however subsequently prevented the X server from starting again. That really annoyed me. After I had manually removed the dual head settings from the xorg.conf file I searched the web for the error message I read in the X server's log:

Fatal server error: Requested Entity already in use!

I quickly came up with lots of people having the same problem, all of them basically recommending to either leave dual head off (no option), recompile the driver from source (not sure why, as I was using just stock FC5 components) and installing the binary only nvidia driver, directly from nVidia. I went with the last option, taking the prepared rpm from http://rpm.livna.org.

Being (too) optimistic I went for the Dual Head settings again and got the same problem as before. The "left" card was configured to use the nvidia driver, the right one was set to nv again.
Now this is not what I expect from a state of the art distribution. I understand it is basically the hardware manufacturers' fault to not release their drivers so they can be included with the distributions. But hey, at least I would expect two things:

  1. Let the user test new settings first. Learn from Windows here: restore the previous settings if no confirmation happens within 30s.
  2. Do not mess up the config file again by putting in the default driver, but if in doubt, ask whether to use the same driver as for the first card.

I am not sure who exactly to blame for these problems, but frankly: I don't care! This is what keeps people from accepting Linux distributions for everyday use. It's 2006 and we are just used to not breaking something by wanting to switch on a second monitor.

Fonts

One more thing that has always been a very important issue to me is fonts. I know there are different opinions concerning font anti-aliasing and sub-pixel anti-aliasing ("ClearType" in Windows-speak). There are those who like it and those who don't. I count myself a member of the "like it" fraction.
Some weeks ago I saw a video about typography in Windows Vista on Microsoft's Channel 9 blog (see here). Before that I did not know about the very minute tuning and delicate tweaking that takes place to produce fonts that are readable both at very large and especially very small sizes where the automatic scaling of vectors produces many undesirable artifacts.

In Fedora I also chose to have my fonts anti-aliased on a sub-pixel level. Despite the fact that one of my first actions was to copy my Tahoma, Verdana and Trebuchet MS true-type font files from Windows to Linux it still looked wrong. It is hard to describe, but just looking at the desktop icons labels did not feel right. At a size of 8 the Windows screen looked much clearer and readable than the one on Fedora. Searching the web I learned even more about font rendering, especially concerning hinting and the patents connected with it. Well, maybe that's something you have to live with and get used to.

Sound

The "Anaconda" installer successfully detected both my Creative Labs SoundBlaster Live and the on-board Intel sound device. It even let me choose which one to use by default. I went for the SoundBlaster, because that's where the speakers are attached.
I ran into the same problem again that I had with FC4 (see this earlier post): Sound as root, but sad silence as a regular user.

I finally found what has probably been the issue with FC4, too: The setup had very well defined the SoundBlaster as my soundcard of choice, alas apparently it only did so for the root user. When logged in as a normal user it used the Intel sound device. So it was not a permissions problem as I suspected back then at all. That of course explains the lack of error messages and the complete uselessness of all volume sliders and muting switches; the sound was there, just there were no speakers to let me know.
It may be beneficial to be able to select different preferred devices per user, but hey, why not use the installation default for all users as a start? One more thing on the "need not be" list.

"Second Impressions"

I used FC5 for some weeks, only booting into Windows occasionally, mostly to do home-banking. Basically I liked it, but it still did not have the "ease of use" factor I would have liked. Package management with yum for example is way to slow for my taste. Especially at the beginning when I needed to install numerous packages as I went, I learned to hate the its progress indicator walking slowly while working through some XML files.

Ubuntu "Dapper Drake"

One day I downloaded the free VMware server and installed Ubuntu 6.06 (Dapper Drake) in a virtual machine. I immediately felt at home, probably because I have known Debian for so long. It only took a couple of days to purge FC5 and install Dapper as my "new primary" Windows replacement. The default setup is very well done. It's just one CD, so there is not as much choice as with the Fedora DVD (in fact, there is no choice at all in the installer, just like Windows). But hey, that's ok, because most of the stuff you need is either already there (Open Office, Firefox, GAIM...) or can easily be installed via apt-get or the very nice graphical software management tools (and apt is way faster than yum...).

Right now, after only three evenings, I am set up very nicely and finishing this article. I have to admit though, that my recent experience with the FC5 setup sped up the process somewhat. Please do not get me wrong: Fedora is a fine system, if you are looking for a distro to use, I definitely recommend having a look at it. But also be sure to give Ubuntu a try ;)

For me this could be the beginning of a very good relationship :)

Tuesday, July 11, 2006

Enhanced MySQL Administrator Graphs

Update: MySQL 4 and 5 behave differently.
In MySQL5 there is a steady activity on some handlers, probably caused by the status queries themselves. This does not happen in 4.1. I have issued a support call with MySQL and will see what to do about it.

Update 2: See the follow-up post for more information on how to work around this.

MySQL Administrator is one of the graphical tools MySQL provide to manage their database servers. Apart from other things like server daemon control and a log file viewer this tool includes visual controls to display the load of the database server.

Even though the out-of-the-box configuration already contains some useful diagrams, I added some new and modified the existing. If you'd like to use them, please feel free to do so, they can be downloaded here: mysqladmin_health.xml. Please notice, that this is not a java file, but I had to rename it to be able to upload it to JRoller. Just remove the ".java" from the filename.

There is a file in the Administrator installation directory that serves as a default. However for each user a copy is placed in his/her home directory. If this private copy exists, it will be used instead. On Windows you have to put it into the directory you reach by entering %userprofile% into the address bar of an Explorer window.

From there on the further path depends on your Windows language version. On a German Windows it is Anwendungsdaten\MySQL, on an English version it's Application data\MySQL. Please be sure that no instance of MySQL Administrator is running, because on exit it will overwrite that file with its currently running settings.

If you have useful customizations, please feel free to share them, too.

Here you can see the new graphs and a short explanation:

  • Individual counters for sent and received bytes
    Traffic Graph
  • InnoDB pages read/written ratio and number of temporary tables created and how many of them were on disk (as opposed to in memory)
    InnoDB reads and temp tables
  • History of threads in the server and their idle/working ratio
    Idle and working threads
  • Number and type of DML statements performed.
    History and type of DML statements
  • History of calls to the Read_First handler.
    History of Read First Handler calls
  • History of calls to the Read_Next handler.
    History of Read Next Handler calls
  • History of calls to the Read_Prev handler.
    History of Read Prev Handler calls
  • History of calls to the Read_Rnd handler.
    History of Read Random Handler calls
  • History of calls to the Read_Rnd_Next handler.
    Number of Read Random Next Handler calls

For more details on the different handler types, see the "Status variables" tab in MySQL Administrator or the MySQL manual (see the correct manual page for your MySQL version!)

MySQL 5.0, Bug 10210

In my previous post about enhancing the graphs the MySQL Administrator displays I added a remark that there seems to be a difference between MySQL 4.1 and 5.0.

As it seems this has already been reported as MySQL Bug #10210 and fixed, however only for 5.1. Summarizing the bug report is easy: They implemented Heisenberg (or better: the observer effect). You cannot query the counters for e. g. the number of temporary tables created without modifiying it as you go. In 4.1 all the SHOW STATUS... commands (see the manual page) could be executed without modifying the values displayed, because they were immediately sent to the client. In 5.0 a temporary table with the result is created and then sent. This allows the use of the data in stored procedures.

It is however very annoying, because it increases the noise in measuring significantly. One (somewhat clumsy) workaround is to modify the formula for the graphs you define in MySQL Administrator by subtracting the number that would otherwise be displayed on an idle server. This of course only works if you only have one instance of the Adminstrator connected to a particular server (otherwise the other sessions' increments still show up). Moreover this makes statistics on 4.1 servers wrong, so make sure you know how to read the data if you have a multi-version environment.