Slow or hanged login
August 19th, 2005
Login in Mac OS X could stall when nameservers don’t respond to queries or do it slowly. This can happen during network outages, for example.
I discovered this today, with Mac OS X 10.3.9, while trying to log in. It took forever: the Dock started up, but finder would hang. Accidentally, I found that turning off all network interfaces (like AirPort), solved the problem, Further investigations revealed that my ADSL router had stopped forwarding packets and thus, it was impossible to reach any nameserver.
After a reboot, everything started working properly. However, I was intrigued about the reasons of the stalls during log in. By using “tcpdump” to capture traffic, I discover that my PowerBook was sending out some spureous queries against my ISP’s DNS nameserver:
16:05:33.975493 IP 192.168.0.xx.49152 > 195.235.113.3.domain: 30686+ PTR? 91.0.168.192.in-addr.arpa. (43)
16:05:34.034175 IP 195.235.113.3.domain > 192.168.0.xx.49152: 30686 NXDomain 0/1/0 (120)
192.168.0.xx is the IPv4 address assigned to my AirPort Express NIC, while 195.235.113.3 is my ISP DNS IPv4 address.
Why my system is sending out this PTR query is still a mistery to me and I haven’t been able to block it. It turns out that some component of Mac OS X is also sending out IPv4 (A) and IPv6 (AAAA) queries for “idisk.mac.com”. These can be easily blocked by adding the following entries to “/etc/hosts”:
# Mac OS X queries for these entries during log in,
# which can cause stalls if there is no Internet
# connectivity.
17.250.248.77 idisk.mac.com
::1 idisk.mac.com
Now, login is a little bit faster, but I guess it will hang the next time my router stops working properly.
SMC 2835W V3 and SMC 2802W V2
August 19th, 2005
Yesterday I bought a SMC EzConnect 54g Wireless CardBus adapter for my Linux laptop. There are, at least, two different and incompatible versions of this card. The SMC 2835W V2 uses the Intersil 3890 Prism54 chipset, which is supported natively by Linux Prism54 driver. The SMC 2835W V3, which is the one I bought, isn’t. Fortunately, ndiswrapper fully supports this card by wrapping native Windows NDIS drivers around a linux kernel driver. Also, the same happens with the EzConnect 54g Wireless PCI adapter I bought for my Pentium IV machine, which sports the SMC 2802W V2 chipset. The Prism54 Linux driver doesn’t support this card yet.
The SMC 2802W card I bought looks like this:

The SMC 2835W V3 CardBus NIC I bought looks like this:

In order to use these cards, I downloaded the latest tarball for ndiswrapper from the ndiswrapper site which, at this time, was version 1.1. The tarball comes with a Red Hat .spec file that requires no tweaking, except updating the version tag to 1.1.
rpmbuild -ba ndiswrapper.spec
This will compile the ndiswrapper userspace tools and kernel module against the current kernel source tree which must be available under “/lib/modules/`uname -r`/kernel” (for Fedora Core 4 and later, there exists a kernel-devel package which contains all kernel source files needed to compile out-of-tree kernel modules).
Once compiled, I installed the resulting ndiswrapper and kernel-module-ndiswrapper RPM packages. Next, I copied the Windows XP NDIS driver directly from the CD-ROM supplied with the card itself to the hard disk. The driver is fully contained within the \Utility folder inside the CD-ROM:
cd /tmp
mount /media/cdrom
cp -Rdp /media/cdrom/Utility .
cd Utility
ndiswrapper -i SMC2835W.INF
These steps are required to pick the Windows NDIS driver and firmware and make them available to the ndiswrapper kernel module. In fact, the driver files will get copied into “/etc/ndiswrapper/
NOTE: The SMC 2835W V3 Windows driver can also be obtained from this link if desired. The SMC 2802W V2 Windows driver can be obtained from this link.
The last step consists in removing the prism54 module that gets autoloaded by udev/hotplug when the card is plugged into any CardBus slot, then modprobing the ndiswrapper kernel module:
modprobe -r prism54
modprobe ndiswrapper
If everything is ok, something like this should get logged to the kernel dmesg ring:
ndiswrapper version 1.1 loaded (preempt=no, smp=no)
ndiswrapper: driver smc2835w (SMC,04/29/2004, 3.0.11.1) loaded
ndiswrapper: using irq 10
wlan0: ndiswrapper ethernet device 00:04:xx:xx:xx:xx using driver smc2835w, configuration file 1260:3890.5.conf
wlan0: encryption modes supported: WEP, WPA with TKIP, WPA with AES/CCMP
Also, it’s possible to use the following command to check the driver loaded:
ndiswrapper -l
Once everything is working, the last steps try to find a wireless network, associate with it and configure the network stack:
iwlist wlan0 scan | grep ESSID
We should choose among the listed ESSIDs or, if the ESSID broadcasting is disabled, an specific, known ESSID.
iwconfig wlan0 essid
ifconfig wlan0 up
dhclient
To make the changes permanent, the following command should be used:
ndiswrapper -m
This last command usually appends the following line to “/etc/modprobe.conf”:
alias wlan0 ndiswrapper
This tells the initscripts to modprobe for the ndiswrapper module when trying to bring the wlan0 interface up. Usually, the initscripts do a modprobe
It’s also recommended to add prism54 to udev/hotplug’s blacklist to prevent it from loading on systems where both ndiswrapper and prism54 kernel modules are present:
echo prism54 >> /etc/hotplug/blacklist
Numeric iPod battery display
August 19th, 2005
Although the little battery icon in the upper right corner of the iPod’s screen is cute, it provides only a very general idea of the iPod’s remaining battery charge. It is possible, however, to tell iPod that the battery voltage should be displayed instead.
To force the iPod to do this, create a file called _show_voltage inside the Device folder located under the iPod_Control folder. Just attach the iPod to your Mac and make sure it is mounted as a removable hard drive before running the following command:
touch /Volumes/My\ iPod/iPod_Control/Device/_show_voltage
Removing that file will make iPod battery charge get displayed as the little battery icon.
nVidia GeForce FX5200
August 19th, 2005
The new nVidia GeForce FX5200 is an AGP 8X, 256MB DDR2, DVI-enabled speed-demon that, when used together with KDE 3.4 translucency effects, gives an incredible, nice-looking, awesome desktop full of window drop shadows, translucent windows and fadding effects.
However, in order to be able to get the last bit of performance out of it, I must use the propietary nVidia drivers.
The propietary nVidia drivers consist of a binary-only blob that implements the video driver that talks to to the graphics board, plus a linux kernel wrapper. The wrapper has it’s source code available, and must get compiled against the running kernel. The process of installing the nVidia driver is painless.
Installing the nVidia propietary driver.
- Download the latest Linux IA-32 drivers from http://www.nvidia.com
- Make sure the kernel sources used to build the current kernel are available, either in /usr/src/linux or /lib/modules/`uname -r`/build
- Run the driver, usually in the form of a self-extracting shell script.
- The driver will try to find a suitable, precompiled module for the current kernel or else will compile it by itself.
After the driver is installed successfully, some modifications need to be done to /etc/X11/xorg.conf.
Configuring X.org
- I did replace the “nv” X.org’s built-in nVidia driver, which lacks DRM/DRI support, with the “nvidia” propietary driver.
- I had to set the “AllowGLXWithComposite” option to “true” in order to get GLX to coexist with the Composite extension. If this option is missing, or set to false, the Composite extension will be disabled and GLX acceleration will prevail.
- Also, I had to comment out “Load” “dri” to stop GLX-accelerated applications from crashng.
My full /etc/X11/xorg.conf looks like this:
Section "ServerLayout"
Identifier "Single head configuration"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
EndSection
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/TTF"
FontPath "/usr/share/fonts/default/Type1"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "fbdevhw"
Load "glx"
Load "record"
Load "freetype"
Load "type1"
# Load "dri"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
Option "XkbOptions" "altwin:meta_win, ctrl:nocaps"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "no"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "BenQ"
ModelName "FP937s+"
HorizSync 31.5 - 67.0
VertRefresh 50.0 - 75.0
Option "DPMS" "false"
EndSection
Section "Device"
# Option "AGPMode" "4"
Identifier "Videocard0"
Driver "nvidia"
VendorName "AOpen"
BoardName "FX5200"
Option "RenderAccel" "true"
Option "AllowGLXWithComposite" "true"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
Section "DRI"
Group 0
Mode 0666
EndSection
Section "Extensions"
Option "Composite" "enable"
EndSection
That’s all.
Case-insensitive filename completion with BASH
August 19th, 2005
If you use bash as your shell and use filename completion a lot, you can get bash to ignore the case of filenames just like HFS does.
Just put this in your ~/.inputrc file:
set completion-ignore-case on
Then, when you type ls /appli in the shell and force filename completion, you’ll get ls /Applications like you ought to.
ALPS GlidePoint under Linux with X.org
August 19th, 2005
Recently, I have been able to make the ALPS GlidePoint PS/2 Touchpad of my Packard Bell laptop to work properly under Linux and X.org X11R6 Server, including edge scrolling and tap-to-release drag lock.
The support for ALPS GlidePoint Touchpads seems a relatively recent addition, both to Linux kernels and X.org X11 servers. The first thing to check for is whether the kernel has properly detected the touchpad. The following lines should appear in the kernel message ring:
# dmesg … ALPS Touchpad (Glidepoint) detected Enabling hardware tapping input: AlpsPS/2 ALPS TouchPad on isa0060/serio1 …
In second place, make sure the synaptics X.org driver has been installed. For Fedora Core systems, this usually means installing synaptics-0.13.5-5 or a newer version:
# yum install synaptics
will usually install the synaptics RPM package which contains the X.org synaptics driver:
# rpm -qil synaptics … /usr/X11R6/lib/modules/input/synaptics_drv.o …
Once the required pieces are all set up, the X.org configuration file must be changed in order to use the new synaptics input driver. This can be easily achieved by replacing the “InputDevice” section in “/etc/X11/xorg.conf” file for the mouse with the following:
Section "InputDevice" Identifier "Mouse0" Driver "synaptics" Option "Protocol" "auto-dev" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "yes" Option "LeftEdge" "120" Option "RightEdge" "830" Option "TopEdge" "120" Option "BottomEdge" "650" Option "FingerLow" "14" Option "FingerHigh" "15" Option "MaxTapTime" "180" Option "MaxTapMove" "110" Option "EmulateMidButtonTime" "75" Option "VertScrollDelta" "20" Option "HorizScrollDelta" "20" Option "MinSpeed" "0.2" Option "MaxSpeed" "0.5" Option "AccelFactor" "0.01" Option "EdgeMotionMinSpeed" "15" Option "EdgeMotionMaxSpeed" "15" Option "UpDownScrolling" "1" Option "CircularScrolling" "1" Option "CircScrollDelta" "0.1" Option "CircScrollTrigger" "2" Option "LockedDrags" "1" Option "SHMConfig" "on" EndSection
Finally, the section “Module” must be modified to manually load the “synaptics” input driver provided by the synaptics RPM package:
Section "Module" Load "dbe" … Load "synaptics" EndSection
Problems with udev and my USB printer
August 18th, 2005
After upgrading my Compaq laptop from Fedora Core 2 to Fedora Core 3, CUPS printing stopped working due to some problems caused by udev. After the upgrade, the /dev/usb directory, which usually held devices files for printers and scanners, has turned itself into a device file.
Now, udev is unable to create /dev/usb/lp0, since /dev/usb is not a directory anymore, and since it’s missing, CUPS is unable to print to my HP DeskJet 970Cx printer configured at /dev/usb/lp0.
I haven’t been able to find why /dev/usb has suddendly become a device file:
ls -l /dev/usb
crw------- 1 root root 180, 0 ene 30 12:28 /dev/usb
I have been searching in Google and have found an interesting page that describe how udev rules work . Basically, a udev rule tells udev how to extract information about devices from the sysfs filesystem and how to dynamically create device files for those devices.
Although I have been unable to fix my problems with /dev/usb being a device file, I have been able to create an specific udev rule for my printer that creates /dev/lp? and /dev/printers/hp970 device nodes for me. The rule is as follows:
BUS="usb", SYSFS{serial}="ES9981103BJQ", NAME="%k", SYMLINK="printers/hp970"
and must be placed inside the file /etc/udev/rules.d/10-local.rules.
BUS states the bus which the device is attached to. SYSFS{serial} references the device serial number (in this case, the USB printer serial number). NAME is the device file name that will get created, where “%k” means the standard device name assigned by the kernel (lp0, lp1, and so on). SYMLINK allows creating aliases, or different names, for this device, which in turn are just symlinks to the device NAME (in this case, a synlink named /dev/printers/hp970 will be created pointing to /dev/lp0).
By default, udev rules are stored inside /etc/udev/rules.d as individual files, and are processed in alphabetical order. For every device attached, rule files are checked alphabetically, and once a rule file is found to contain a matching rule for the device being processed, no further rule files for the same device are read. Thus, my custom rule must be inside a rule file that gets read and processed before rule files for the default rules. udev places default rules in a file called 50-udev.rules so in order for the previous custom role to take precedence over the default ones, it must be placed inside a file starting with a numer lower than 50.
After running udevstart or rebooting, the /dev/lp? and /dev/printers/hp970 device nodes should be available and accesible. The last step is reconfiguring the HP DeskJet 970Cxi printer in CUPS to point to /dev/printers/hp970. This can be done by editing /etc/cups/printers.conf, then restarting or reloading CUPS.
Preventing X11.app from automatically opening an XTerm on launch
August 18th, 2005
Mac OS X X11 Server, called X11.app, is configured to open a new xterm on launch by default. This default behavior can be pretty annoying, but can be easily disabled.
In order to stop Mac OS X X11.app from launching a new and empty xterm when launched for the first time, one must install a customized .xinitrc file into $HOME.
During start, X11.app looks for $HOME/.xinitrc and, if no one is found, it executes /etc/X11/xinit/xinitrc. It’s the /etc/X11/xinit/xinitrc script the one that launches an empty xterm.
To stop X11.app from launching an empty xterm:
cp /etc/X11/xinit/xinitrc $HOME/.xinitrc- Edit $HOME/.xinitrc and remove the line that reads
"xterm &"
This will prevent X11.app from starting useless client applications, like xterm, on launch.
XEN
August 18th, 2005
Xen implements paravirtualization to allow for software partitioning.
Xen is an hypervisor that allows running several partitions, called “domains”. Each domain is totally independent, virtualized and solated by the Xen hypervisor, which controls access to the hardware and shares the physical resources among all running domains.
There are two domain classes:
- Privileged domain: has some limited access to the hardware, and is used to provide for virtual driver support for all the non-privileged domains. There can only be one privileged domain running on a machine at any time and its called “domain0″.
For example, the privileged domain has access to the video frame buffer and can run an accelerated X server, and has limited access to real devices, like eth0, hda, and so on.
- Unprivileged domain: has no direct hardware access, and all the I/O operations are virtualized by using virtual devices, like the virtual block device or virtual network device, which are in turn hooked to the privileged domain. There can be as many unprivileged domains as system resources allow for.
Unprivileged domains don’t have a video frame buffer and, thus, all GUI support must get implented using software like VNCserver or FreeNX, then remotely controlling the session from another domain or machine.
Xen selects a random hardware MAC address if not specifically told to use a particular one. This causes problems with networking since the MAC address for the domain virtual interface (called vif) changes between domain reboots and switches and computers keep the corresponding entry on their ARP caches for a few minutes.
Let be A a virtual unprivileged domain running under Xen’s control. After A has started, any other domain or real machine, will be unable to talk to A until the moment A forces an ARP cache update by sending out a packet (for example, an ICMP packet).
I see two solutions to this problem:
- When domain A starts, it initiates an ARP cache refresh of other domains or machines.
This can be achieved by sending a gratuitious ARP cache on interface wakeup, which not every Linux distribution does, or send some ICMP echo request packets to force sending ARP requests. This can be easily implemented in init scripts.
- Forcing domain A to use a fixed MAC address.
This can be achieved by using the following line in A domain configuration file:
vif = [ 'mac = XX:XX:XX:XX:XX:XX' ]The latter solution is the easiest and, usually, the preferred one.
NOTE: This also covered in the Xen FAQ.
iTunes 4.7.1 doesn’t like Hymn-unprotected AAC music files
August 18th, 2005
After upgrading to iTunes 4.7.1 from iTunes 4.7, DRM-protected files that were unprotected with Hymn, refuse to play. However, using JHymn seems a partial solution, as some files still refuse to get copied back to my iPod.
I have found the following page from the Hymn Project:
http://www.hymn-project.org/jhymndoc/
In this page, the reader is instructed to remove the following atoms from unprotected M4A files in order to be playable under iTunes 4.7.1:
(apID)
(cprt)
(iods)
To do so, we will use JHymn. We must instruct JHymn to re-scrub the entire music library, looking for M4A files that were already unprotected, in order to remove any left atoms that trigger iTunes protection countermeasures.