Archive for the ‘Linux’ Category

* autofs, automount and umount

Posted on January 20th, 2011 by Alex. Filed under Linux.


Recently I am playing around with autofs and configured my laptop such that a plugged in pen drive will be automatically mounted into well-defined mount points. I always disliked the way Ubuntu mounts devices: Since I am working on consoles most of the times, I have to figure out the name of the device that I just connected, each and every time, before I am able to jump to the according directory. To be honest, it also has an advantage: You know immediately which drive is mounted at which mount point in case multiple devices are plugged in at the same time. But that is not a problem for me.

I configured udev and autofs according to the following wiki entries:

But instead of udevadm info --query all --path /sys/block/sdb/sdb/ as suggested, I am using udevadm info --name=/dev/sdb --attribute-walk which shows much more information (and sometimes it is hard to find the right entry).

Everything worked fine and whatever I plugged into the USB ports, the drives got mounted to the configured mount points. However I ran into a problem that is not solved as the many unanswered threads in several forums of helpless users nicely demonstrate: If a drive is mounted by autofs, how does the normal user umount it without the necessity to change to root (if that is an option at all)?

As normal user and after autofs mounted the device, you will get usually something like:

alefel@jitu:~$ umount /media/usb0
umount: /var/autofs/removeable/usb0 is not in the fstab (and you are not root)

Ok, the /etc/fstab entry can be solved, so you add a line looking like this one:

/dev/sdb1 /media/usb0 auto noauto,noatime,nodiratime,users,rw,exec,suid,async,uid=1000,gid=1000, umask=0072 0 0

Please note the option users ensuring that other users apart from the one who actually mounted the device, can umount it. Try it out:

alefel@jitu:~$ umount /media/usb0
alefel@jitu:~$

You also have to set the options in the auto.removable right. E.g.:

usb0 -fstype=auto,noatime,nodiratime,users,rw,exec,suid,async,uid=1000,gid=1000,umask=0072 :/dev/usb0

To ease your configuration, I am adding my relevant files at the end of this post.

However it might be helpful to know, how autofs actually works. After reading and following the wiki entries given above, you will have something like

/var/autofs/removeable /etc/auto.removeable –timeout=2

in your /etc/auto.master. The man pages about timeout say that it “sets the global minimum timeout, in seconds, until directories are unmounted.” (man automount) or “sets the default mount timeout” (man auto.master). This entry is a little bit misleading. To explain the purpose of the timeout directive, shut down autofs:

root@jitu:/# /etc/init.d/autofs stop

and start it manually:

root@jitu:/# automount -v -f

(-v means, be verbose and tell us what autofs is doing and -f starts autofs in the foreground. Crtl+c will stop autofs again. You can also try -d instead of -v to see even more.)

Plug in your USB pen drive. What will happen in the console that shows the output of autofs? Surprisingly apart from text printed during the start of autofs

Starting automounter version 5.0.4, master map /etc/auto.master
using kernel protocol version 5.01
mounted indirect on /var/autofs/removeable with timeout 2, freq 1 seconds

nothing else is happening. Open another console and do an ls onto the supposingly mounted drive:

ls /media/usb0

Then autofs will print something more:

Starting automounter version 5.0.4, master map /etc/auto.master
using kernel protocol version 5.01
mounted indirect on /var/autofs/removeable with timeout 2, freq 1 seconds
attempting to mount entry /var/autofs/removeable/usb0
mount(generic): mounted /dev/usb0 type auto on /var/autofs/removeable/usb0
mounted /var/autofs/removeable/usb0
1 remaining in /var/autofs/removeable
1 remaining in /var/autofs/removeable

And exactly 2 seconds later, some lines will be printed additionally:

Starting automounter version 5.0.4, master map /etc/auto.master
using kernel protocol version 5.01
mounted indirect on /var/autofs/removeable with timeout 2, freq 1 seconds
attempting to mount entry /var/autofs/removeable/usb0
mount(generic): mounted /dev/usb0 type auto on /var/autofs/removeable/usb0
mounted /var/autofs/removeable/usb0
1 remaining in /var/autofs/removeable
1 remaining in /var/autofs/removeable
expiring path /var/autofs/removeable/usb0
unmounting dir = /var/autofs/removeable/usb0
expired /var/autofs/removeable/usb0

That means that the drive was idle for 2 seconds and hence got umounted. Therefore a manual umount does not make any sense, since most of the time, it is already umounted. If you do an ls /media/usb0; umount /media/usb0 (basically a back-to-back execution of commands), the drive is umounted successfully and the last 3 lines are not printed. In fact, if I do an cd into /media/usb0 the line “1 remaining in /var/autofs/removeable” is printed by autofs every second.

The configuration files:

.



* purge removed debian packages

Posted on August 23rd, 2010 by Alex. Filed under Linux.


The package manager on Debian based systems differs between removing a package and purging it. When a package is removed, the executable files and libraries (if not shared by others) are deleted from the hard disk. However the configuration files remain so that, if you reconsider your decision and reinstall a package, it does not need to be configured anymore. If a package is purged, all files belonging to the package are removed.

For many years I used to remove packages only. The recent problem was that over the time some changes were done to udev and it started to complain about an old format of a configuration file.

udevd[8055]: SYSFS{}= will be removed in a future udev version, please use ATTR{}= to match the event device, or ATTRS{}= to match a parent device, in /lib/udev/rules.d/someFile.conf

However this file belonged to a package that was removed a long time ago and hence not updated along with udev. I wanted to clean up my system and purge all removed packages. This can be time consuming task, if the package count of removed packages crosses some hundreds. Use

dpkg --get-selections | grep deinstall

to show removed packages and use

dpkg --get-selections | grep deinstall | wc -l

to count them.

Fortunately the package manager provides an easy command to purge all removed packages at once:

aptitude purge ~c

.



* installation of ati hd 3650 in lenny

Posted on March 7th, 2010 by Alex. Filed under Linux.


I replaced my nVidia GT8600M with an ATI Radeon HD 3650. The installation of the fglrx driver is a complete mess. Maybe this posting will help you to enable the driver in your Debian/Lenny box.

My setup

At my workplace I have a external monitor (max resolution: 1280 x 1024@60Hz). However the DDC database reports this monitor to also support 1400 x something, which results in the display of “Cannot support current resolution” on the screen.
The LCD of my laptop has a resolution of up to 1680×1050 (Lovely, isn’t it? :D Btw, 15.4″, nice NON-glossy screen etc.)
At work I have to give a presentation sometimes, so the LCD screen should be mirrored at a resolution of 1024×768. Otherwise I would like to have a big desktop stretched over 2 screens, so that I can move windows from one side to the other.

At my home there is no external monitor and I rely only on the LCD.

Installation

I installed the proprietary drivers downloaded from ATI (fglrx, version 10.2). I tried to use kernel 2.6.33 (which was released a week ago), but despite a patch, the compiled module did not load due to some missing symbols. So I downgraded to 2.6.32.9. But even then, the installation failed. As far as I remember, the ati-installer script was complaining about a missing directory in /usr/X11R6/lib/modules or similar.
Soon I found a description which resulted in a flawless packaging and kernel module compilation. Despite the fact, the fglrx is in version 10.2, following the steps mentioned for 10.1 lead to success.

Configuration

The configuration was pretty easy and straight forward. However fglrx is heavily using xrandr and since I had nVidia earlier, I was not used to that nor did I know. The nVidia configuration relied heavily in xorg.conf and I thought the same about fglrx.

Issues

There are some issues with fglrx.

  1. The external monitor does not show the proper resolution despite the fact Modeline etc are mentioned in xorg.conf.

    Solution: The problem seems to be that fglrx is not interested in the data reported by the monitor at all. Even if a ModeLine is forced by UseMode, it is completely ignored by fglrx and the highest reported resolution is used (which is incompatible with this monitor as mentioned earlier). Here is an example of that section.

    Section "Monitor"
    Identifier "Monitor1"
    HorizSync 30.0 - 80.0
    VertRefresh 50.0 - 76.0
    Option "VendorName" "Dell"
    Option "ModelName" "E177FP"
    Option "DPMS" "true"
    ModeLine "1280x1024_60.00" 108.9 1280 1360 1496 1712 1024 1025 1028 1060 -hsync +vsync
    Option "PreferredMode" "1280x1024_60.00"
    UseModes "1280x1024_60.00"
    EndSection

    The solution is to alter the resolution bt xrandr while GDM is loaded. For that I added the lines
    EXTERNAL_OUTPUT="CRT1"
    INTERNAL_OUTPUT="LCD"
    xrandr |grep $EXTERNAL_OUTPUT | grep " connected "
    if [ $? -eq 0 ]; then
    xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
    fi

    before gdmwhich () (right at the beginning) in /etc/gdm/Init/Default. These additional lines switch off the external monitor (anyway it does not have to show anything) only if it is connected. My xorg.conf is available at the end of this post.

  2. After the user logged in, the attached monitor should be automatically detected and switched on.

    Solution: Thanks ThinkWiki there is a solution for doing so. To ease the switch between externalMonitorOff, mirror and bigScreen I created 3 executable files in /usr/local/bin/xrandr that allow me to switch the mode instantly. To access the files, you have to create starters in Gnome (e.g. right click on desktop -> “Create Launcher”)

  3. After suspend to RAM and resume, the external monitor is switched off and I have to execute something like
    xrandr --output LCD --auto --output CRT1 --off
    xrandr --output LCD --auto --output CRT1 --left-of LCD --mode 1280x1024

    to reinitialize my desktop and to power up my external monitor.

    Solution: A post in the Ubuntu forum leads to the solution. Put the commands into a file in /etc/pm/sleep.d/.

  4. Now the fglrx driver is installed, what about Compiz?

    Compiz should work without any problem, however the resize issue (nVidia, but nevertheless same issue) resurfaced here again. It is very much annoying and I do not use compiz and the moment. I really look forward for the driver radeonhd to support 3D acceleration so that I can discard the whole fragile installation of fglrx.

Download

The zip file contains

  • my xorg.conf. This also includes the old xorg.conf of the nVidia card. The xorg.conf can be found in /etc/X11/.
  • the scripts that allow me to switch between the modes rapidly. Depending, what is executed, I get a my desktop stretched of 2 displays, a mode with the external VGA port switched off or with the content displayed on my LCD mirrored. To figure out the names of the --output parameter, use xrandr in the console.
  • /etc/gdm/Init/Default
  • /etc/X11/Xsession.d/45custom_xrandr-settings. Do not forget to make this file executable. It is called by the next file.
  • /etc/pm/sleep.d/restoreScreen.sh. This file also needs to be executable.

Download!

.



* 2.6.33, debian lenny, nvidia and vbox

Posted on February 25th, 2010 by Alex. Filed under Linux.


Today kernel 2.6.33 became stable. This post describes, how to get 2.6.33 running on a Debian box running on Lenny (the stable version).

  1. If you use make-kpkg (like me) to compile the kernel, you have to get a newer version of the the package “kernel-package”. In Lenny the current version is 11.015. The compilation works with the version that is shipped with testing (currently 12.032). So download the package from a server of your choice and install it with dpkg -i <packageName>. All dependencies are already met.
  2. Obviously the nvidia-kernel-source will create problems as usual:

    /usr/src/modules/nvidia-kernel/nvacpi.c: In function ‘nv_acpi_methods_init’:
    /usr/src/modules/nvidia-kernel/nvacpi.c:511: error: too few arguments to function ‘acpi_walk_namespace’
    make[5]: *** [/usr/src/modules/nvidia-kernel/nvacpi.o] Error 1
    make[4]: *** [_module_/usr/src/modules/nvidia-kernel] Error 2
    make[4]: Leaving directory `/usr/src/linux-2.6.33′
    make[3]: *** [modules] Error 2
    make[3]: Leaving directory `/usr/src/modules/nvidia-kernel’
    make[2]: *** [binary-modules] Error 2
    make[2]: Leaving directory `/usr/src/modules/nvidia-kernel’
    make[1]: *** [kdist_build] Error 2
    make[1]: Leaving directory `/usr/src/modules/nvidia-kernel’
    Module /usr/src/modules/nvidia-kernel failed.

    The patch from this thread in the nVidia forum helped and it works without any problems (apart from all the warning during compilation).

  3. The kernel module for VirtualBox is quite aged and currently at version 1.6.6. The compilation process complains about missing files:

    In file included from /usr/src/modules/virtualbox-ose/include/VBox/types.h:34,
    from /usr/src/modules/virtualbox-ose/SUPDRV.h:39,
    from /usr/src/modules/virtualbox-ose/linux/SUPDrv-linux.c:35:
    /usr/src/modules/virtualbox-ose/include/iprt/types.h:87:30: error: linux/autoconf.h: No such file or directory
    /usr/src/modules/virtualbox-ose/linux/SUPDrv-linux.c: In function ‘VBoxDrvLinuxCreate’:
    /usr/src/modules/virtualbox-ose/linux/SUPDrv-linux.c:734: error: ‘struct task_struct’ has no member named ‘euid’
    /usr/src/modules/virtualbox-ose/linux/SUPDrv-linux.c:735: error: ‘struct task_struct’ has no member named ‘egid’
    kmk[2]: *** [/usr/src/modules/virtualbox-ose/linux/SUPDrv-linux.o] Error 1
    kmk[2]: Leaving directory `/usr/src/linux-2.6.33′
    kmk[1]: *** [_module_/usr/src/modules/virtualbox-ose] Error 2
    kmk[1]: Leaving directory `/usr/src/linux-2.6.33′
    kmk: *** [binary-modules] Error 2
    kmk: Leaving directory `/usr/src/modules/virtualbox-ose’
    make[1]: *** [kdist_build] Error 2
    make[1]: Leaving directory `/usr/src/modules/virtualbox-ose’
    Module /usr/src/modules/virtualbox-ose failed.

    Fortunately it is easy and fast to be fixed either by applying virtualbox-ose-2.6.33.patch.zip or by replacing

    #include <linux/autoconf.h>

    by

    #include <generated/autoconf.h>

    in the files SUPDRV.h, r0drv/linux/the-linux-kernel.h and include/iprt/types.h.

.



* shuffled characters in console, no x

Posted on December 24th, 2009 by Alex. Filed under Linux.


On 22nd of December I did an apt-get update & dist-upgrade. Since then I faced strange problems with the output of my graphics adapter. First I thought, it aged (there is a bug in the packaging of my model: nVidia GT8600M) and I have to replace it. But sometimes it worked after a reboot without any problems. The output showed mixed up characters in tty starting from the boot of the kernel or even earlier during the loading of GRUB. Some characters got replaced by other symbols.

The X server aborted with:

(II) NVIDIA(0): Support for GLX with the Damage and Composite X extensions is
(II) NVIDIA(0): enabled.
(EE) NVIDIA(0): Failed to initialize the NVIDIA graphics device PCI:1:0:0.
(EE) NVIDIA(0): Please check your system’s kernel log for additional error
(EE) NVIDIA(0): messages and refer to Chapter 8: Common Problems in the
(EE) NVIDIA(0): README for additional information.
(EE) NVIDIA(0): Failed to initialize the NVIDIA graphics device!
(II) UnloadModule: “nvidia”
(II) UnloadModule: “wfb”
(II) UnloadModule: “fb”

and the kernel log told me something like this:

Dec 23 12:48:23 jitu kernel: [ 32.945818] nvidia: module license ‘NVIDIA’ taints kernel.
Dec 23 12:48:23 jitu kernel: [ 32.945827] Disabling lock debugging due to kernel taint
Dec 23 12:48:23 jitu kernel: [ 33.205990] nvidia 0000:01:00.0: power state changed by ACPI to D0
Dec 23 12:48:23 jitu kernel: [ 33.206017] nvidia 0000:01:00.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
Dec 23 12:48:23 jitu kernel: [ 33.206573] NVRM: loading NVIDIA UNIX x86 Kernel Module 185.18.36 Fri Aug 14 17:18:04 PDT 2009
Dec 23 12:48:24 jitu kernel: [ 34.051075] ACPI Exception: AE_TIME, Returned by Handler for [EmbeddedControl] 20090521 evregion-424
Dec 23 12:48:24 jitu kernel: [ 34.051092] ACPI Error (psparse-0537): Method parse/execution failed [\_GPE._L02] (Node f702ee64), AE_TIME
Dec 23 12:48:24 jitu kernel: [ 34.051145] ACPI Exception: AE_TIME, while evaluating GPE method [_L02] 20090521 evgpe-568
Dec 23 12:48:24 jitu kernel: [ 34.051386] NVRM: RmInitAdapter failed! (0×26:0xffffffff:1096)
Dec 23 12:48:24 jitu kernel: [ 34.051392] NVRM: rm_init_adapter(0) failed
Dec 23 12:48:29 jitu kernel: [ 39.355725] NVRM: RmInitAdapter failed! (0×26:0xffffffff:1096)
Dec 23 12:48:29 jitu kernel: [ 39.355740] NVRM: rm_init_adapter(0) failed
Dec 23 12:48:35 jitu kernel: [ 44.665717] NVRM: RmInitAdapter failed! (0×26:0xffffffff:1096)
Dec 23 12:48:35 jitu kernel: [ 44.665732] NVRM: rm_init_adapter(0) failed

If the machine was booted in Windows, the graphics adapter was not recognized and a standard driver was loaded.

The following packages and version numbers have been updated:

  • acpid 1.0.8-1lenny2
  • libldap-2.4-2 2.4.11-1+lenny1
  • libexpat1 2.0.1-4+lenny2
  • libexpat1-dev 2.0.1-4+lenny2
  • libmozjs1d 1.9.0.16-1
  • xulrunner-1.9 1.9.0.16-1
  • xulrunner-1.9-gnome-support 1.9.0.16-1

Currently I suspect ACPI for the problem and it seems that somehow the IRQs get messed up. Since I added pci=routeirq to the boot parameter of my kernel in /boot/grub/menu.lst, I do not experience this behavior anymore. It took several reboots and retries by the X server to bring back the IRQs in order.

[Update 20/01/2010]: Even pci=routeirq did not work. Sometimes it was right there from the start. Sometimes it happened after 3 days of continues execution of a simulation. Although I reverted to the previous version of acpid, the problem still persisted. Currently I am trying out an older kernel and nvidia-glx version (2.6.31.2 instead of 2.6.32.2 and 185.18.36-2_i386 instead of 190.42-3_i386). Today it is the fourth day without that the problem occurred again. Let’s see. I am sure, my graphics adapter is getting ready to fail just after updating the post. Threatening it to be replaced (the laptop has a standardized MXM interface between mainboard and graphics adapter), will make it to work again (at least it seems so) :D

[Update 21/01/2010]: As I stated above: A few hours after I wrote updated this post, the graphics adapter failed again. Let’s see, where I can get a replacement from.

.



* convert ogg files to mp3

Posted on November 28th, 2009 by Alex. Filed under Linux.



Unfortunatley and despite of its advantages the majority of handheld devices do not support ogg format so far. Music collections have to be converted into mp3 before copying them to the handheld device. However many devices read out the ID3 tag in the mp3 files to sort them internally into a library. Most conversion methods and tools convert the ogg file into mp3 format flawlessly, but they do not transfer the tag information that is eventually stored in the ogg file.

The little script (copyIDOgg2MP3.pl) attached to this post, helps in that case. It also contains an shell script example (ogg2mp3.sh), how a whole folder can be processed in a single shot.

Usage/Installation

There is no installation as such. Untar the downloaded archive and execute copyIDOgg2MP3.pl OggFile MP3File
Both audio files must exist. So far only ID3 tags in the version 1.1 are supported.

License

The script is published under GPLv3 and comes without any warranty.

Download

copyIDOgg2MP3.tar.bz2

.



* slow usb pen drive in linux

Posted on November 16th, 2009 by Alex. Filed under Linux.


I experienced slow USB mass storage devices such as USB pen drives, attached to a USB2.0 port. The writing speed usually did not cross 600KB/sec. To solve the problem I am mounting the pen drive with the async option set.

The manual of mount in NetBSD says about async:

All I/O to the file system should be done asynchronously. In the event of a crash, it is impossible for the system to verify the integrity of data on a file system mounted with this option. You should only use this option if you have an application-specific data recovery mechanism, or are willing to recreate the file system from scratch.

Since I am using pen drives to move data only e.g. for a presentation, it is no big issue to reformat the pen drive in case of a crash. With async set the writing speed increases to around 8MB/sec. To make the change persistent, add async in your fstab:

/dev/sdb1 /media/usb0 auto noauto,noatime,nodiratime,user,rw,exec,suid,async,uid=1000,gid=1000,umask=0072 0 0

Or, if you use usbmount to mount the pen drives automatically add async to the MOUNTOPTIONS in /etc/usbmount/usbmount.conf

It is always a good idea to sync or to umount the drives before you unplug them.

.



* bluetooth segfaulting in debian

Posted on October 14th, 2009 by Alex. Filed under Linux.


In my Debian box the Bluetooth Applet segfaulted whenever a USB Bluetooth dongle was inserted. The relevant log entry (e.g. dmesg|tail) looked like this:

Oct 6 14:04:41 jitu kernel: [ 90.400199] usb 7-2: new full speed USB device using uhci_hcd and address 3
Oct 6 14:04:41 jitu kernel: [ 90.686465] usb 7-2: New USB device found, idVendor=0a12, idProduct=0001
Oct 6 14:04:41 jitu kernel: [ 90.686473] usb 7-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Oct 6 14:04:41 jitu kernel: [ 90.686646] usb 7-2: configuration #1 chosen from 1 choice
Oct 6 14:04:41 jitu hcid[3085]: HCI dev 0 registered
Oct 6 14:04:41 jitu hcid[3085]: HCI dev 0 up
Oct 6 14:04:41 jitu hcid[3085]: Device hci0 has been added
Oct 6 14:04:41 jitu hcid[3085]: Starting security manager 0
Oct 6 14:04:42 jitu hcid[3085]: Device hci0 has been activated
Oct 6 14:04:42 jitu kernel: [ 91.208984] bluetooth-apple[3333]: segfault at 0 ip b70e2e18 sp bfffbefc error 4 in libc-2.7.so[b706d000+155000]

Here the bluetooth-apple(t), a part of gnome-bluetooth, crashed. Hence no user friendly symbol showed up next to the clock allowing the easy transfer of files to a Bluetooth device. However in the console hcitool scan and sdptool browse worked and displayed the correct data.

The solution was to include the current user into the group netdev. You can check your membership of the groups by typing groups in the console. If netdev is not listed, execute a adduser netdev as root and restart the x-server to update this information.

.



RSS Feeds:

Search:


Pages:

Categories:

Archives: