Archive for February, 2009

* reorder partition numbering

Posted on February 26th, 2009 by jitu. Filed under Linux.


If you move partitions, change their sizes and create new ones, the numbering might get mixed up (e.g. with gparted). The partitions might look like these:

/dev/sda1 ntfs /media/win
/dev/sda2 ext4 /
/dev/sda3 ext3 /boot
/dev/sda4 extended
/dev/sda8 linux-swap
/dev/sda6 fat32 /media/programs
/dev/sda7 fat32 /media/testdisk
/dev/sda5 fat32 /media/stuff

If you want to reorder the partition numbering for whatever reason, fdisk will help. Execute fdisk /dev/sda (as you can see, I want to reorder the numbering of my first SCSI disk) after becoming root.

jitu:/usr/src/linux# fdisk /dev/sda

The number of cylinders for this disk is set to 19457.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

If m is entered at the prompt, the possible commands will be listed. Type x to activate the extra functionality (experts only). Press m again to see new expert options. Enter f (fix partition order) and w to write the changes to the disk and exit.

After changing the sequence, it might be necessary to reboot, since the drive could be in use. Before rebooting, you need to check (and change) the mounting options in /etc/fstab and the root= parameter for the kernel in /boot/grub/menu.lst. Otherwise you might ending up with a broken system. It is also a very good idea to make backups of valuable data, before trying out fdisk.

.



* how to get hibernation to work

Posted on February 26th, 2009 by jitu. Filed under Linux.


Unfortunately I upgraded my nvidia driver to 180.22 and now I am facing problems such as blank screen after resume. If you still have the .deb packages of 177.8x (nvidia-kernel-source, nvidia-glx, nvidia-glx-dev) please let me know. I could not find them anywhere in the net. [Update 07/03/2009] Suspend seems to work with the latest drivers from the experimental branch of debian (180.29). However it is difficult to say, if the removal of “quiet” (one of the kernel options) helped in resolving the issue, or not.[/Update]
As long as this issue is not solved, as a workaround I decided to hibernate the laptop instead of suspending it. However even this did not work. I changed the hard disk configuration some time back and the swap partition which usually contains the image, shifted (now /dev/sda5). The error message when I executed hibernate as root from the console was:

hibernate-disk: Running /usr/sbin/s2disk …
s2disk: Could not use the resume device (try swapon -a). Reason: No such device

But swapon -a did not have the promising effect, since the swap was already activated and available. Also mkswap did not lead to any solution. To fix the problem, perform the following steps:

  1. First I had to tell the hibernate script where to find the new partition. Go to /etc/hibernate/suspend2.conf and check the entry

    ## useful for initrd usage:
    SuspendDevice swap:/dev/sda5

  2. After that modify/create a file in /etc/initramfs-tools/conf.d/ named resume and check its content. It should look like this:

    RESUME=/dev/sda5

  3. Run dpkg-reconfigure uswsusp and answer all questions. A configurations file is generated located in /etc/uswsusp.conf. Its content could be like mine:

    # /etc/uswsusp.conf(8) — Configuration file for s2disk/s2both
    resume device = /dev/sda5
    compress = y
    early writeout = y
    image size = 427039211
    RSA key file = /etc/uswsusp.key
    shutdown method = platform

After these steps, hibernate (executed as root in the terminal) should save the image on the swap drive. However, hibernation consists of two parts: hibernation itself and obviously also resuming. If you are not successful in resuming and you only get error messages like

Unable to find swap-space signature

and

Invalidating stale software suspend images

during boot, the kernel continues with a normal boot and not with a resume. To fix that problem check, if the correct resume parameter is set in /boot/grub/menu.lst:

title Debian GNU/Linux, kernel 2.6.28.7-1
root (hd0,2)
kernel /vmlinuz-2.6.28.7-1 root=/dev/sda2 resume=swap:/dev/sda5 ro quiet
initrd /initrd.img-2.6.28.7-1

The swap: above can be omitted.

If you compile your own kernel, make sure that despite the fact that an initrd might not be necessary, since you might compile all needed modules into the kernel, the resume binary is not included in the kernel binaries. It is written to the initrd making it mandatory to define the initrd parameter. A initrd can be created with update-initramfs -u -k 2.6.28.7-1 with 2.6.28.7-1 being the kernel version (uname -a) and -u updating an existing ramdisk. If you need to create a new one, replace -u by -c.

.



* microcode sw/hw error

Posted on February 18th, 2009 by jitu. Filed under Linux.


If a huge amount of data is transfered using the WiFi connection of my notebook, it very often happens that the interface goes down due to a detection of a hardware or software error in the microcode.

Feb 18 12:56:30 jitu kernel: [56587.903516] iwlagn: Microcode SW error detected. Restarting 0×2000000.
Feb 18 12:56:30 jitu kernel: [56589.921886] phy0: failed to restore operational channel after scan
Feb 18 12:56:30 jitu kernel: [56589.921909] iwlagn: No space for Tx
Feb 18 12:56:30 jitu kernel: [56589.921915] iwlagn: Error sending REPLY_TX_PWR_TABLE_CMD: enqueue_hcmd failed: -28
Feb 18 12:56:30 jitu kernel: [56590.128931] Registered led device: iwl-phy0:radio
Feb 18 12:56:30 jitu kernel: [56590.128981] Registered led device: iwl-phy0:assoc
Feb 18 12:56:30 jitu kernel: [56590.129087] Registered led device: iwl-phy0:RX
Feb 18 12:56:30 jitu kernel: [56590.129129] Registered led device: iwl-phy0:TX

This error never occurs using normal browsing, email checking or working through SSH connection. But in a burst of a file transfer from another machine in the local network, the interface goes down after around 200MB and can only be reset by restarting the network. This error survived multiple kernel, mac, firmware, and iwlagn versions and still did not vanish. Just today I found a possible reason.

Basically there are multiple different revisions of the Intel Corporation PRO/Wireless 4965 AGN adapter and the newer ones do not have that problem. The problem might be caused by overheating of the hardware which fails after it crosses a temperature of around 60°C. IBM suggests to switch on the power management of Windows for the same adapter built in their Thinkpads. In Linux however this can also be done by

cat /sys/bus/pci/drivers/iwlagn/0000\:0c\:00.0/power_level

Replace 0000\:0c\:00.0 with your entry. My output looks like

SYSTEM:auto MODE:fixed INDEX:0

INDEX represents the power state of the adapter with 0 representing the highest power consumption. I am currently trying with a power state of 5 by executing

echo 5 > /sys/bus/pci/drivers/iwlagn/0000\:0c\:00.0/power_level

The lower power consumption results in a desirable lower temperature but at the cost of a higher latency. But for me the consistence is more important than some milliseconds. Unfortunately the INDEX variable is reset to 0 after restarting the network, by activating the kill switch or even from resuming after suspend. Therefore I wrote a little script (resetpowerwifi.sh) running in the background which checks the status of INDEX every 5 seconds. Start the script as a background job by copying it to a directory of your choice (e.g. /etc/init.d/). Put the lines

echo “Start background job to pull down the power level of wlan interface to avoid overheating…”
/etc/init.d/resetPowerWifi.sh &

into /etc/rc.local to start it automatically during boot up.

.



* how to change gnome-screensaver settings

Posted on February 3rd, 2009 by jitu. Filed under Linux.


One advantage of using gnome-screensaver is that it is nicely integrated into the Gnome environment. However in the configuration dialog of the screensaver, where the user can choose, which theme should be shown, one important option is missing: An option that let the user set specific settings for the theme. For instance, if you want to display something more interesting than “jitu Linux 2.6.28-7″ when GLText is selected, there is no way to do so. In previous versions of Gnome the button was there, but later it has been removed due to some reasons, I do not agree with.

However, fortunately gnome-screensaver is nothing else than Xscreensaver except the integration into the Gnome desktop environment. To change the text of GLText or, as described in this example, the settings and directory of the slideshow “Carousel”, the user has to pin point exactly the place where to do so manually. There is also a tool (xFX Screensaver Settings) which helps especially unexperienced users to make the changes. However I personally did not want to install the Mono environment just for this particular application which I may use once a month. But enough of talking….

How to change the settings?

You need to install Xscreensaver and the themes you want. For that you fire up the package manager such as aptitude on the console or Synaptic and select Xscreensaver to be installed. xscreensaver-gl contains themes which needs a 3D accelerating graphics adapter. After that open a terminal and type

xscreensaver-demo

The preferences dialog of Xscreensaver comes up and with it the first error message already:

Warning:
The GNOME screensaver daemon appears to be running.
It must be stopped for XScreenSaver to work properly.
Stop the GNOME screen saver daemon now?

Hit the cancel button and viola the next error message comes up:

Warning:
The XScreenSaver daemon doesn’t seem to be running on display “:0.0″. Launch it now?

Also here: click on the cancel button. I will explain the necessary steps with an example. I would like to configure a theme called “Carousel” which shows my favorite photos 3D animated in a carousel. First I have to give a directory that contains the photos. This setting can be found in the register tab “Advanced”. It should be self explanatory here.

Second step: I would like to configure the speed the carousel turns and the number of photos shown. For that I went back to the register tab “Display Modes” and clicked on “Settings” (below the preview window). Make the necessary changes, after that click on “Advanced>>” and all options are replaced by a “Command Line”: carousel -root -duration 19 -speed 0.6883 -delay 23404 -no-titles

Open another terminal and change the directory to:
cd /usr/share/applications/screensavers/

Locate the file carousel.desktop and open it in an editor with root permissions (e.g. sudo nano carousel.desktop or su). The file looks like this:

[Desktop Entry]
Encoding=UTF-8
Name=Carousel
Comment=Loads several random images[...]
TryExec=carousel
Exec=carousel -root
StartupNotify=false
Terminal=false
Type=Application
Categories=Screensaver

The red marked line is the important one. It tells the screensaver front-end, what it should start with what parameters. Replace everything after “Exec=” by the text given in the “Command Line:” of the still opened Xscreensaver preferences dialog. If you are unsure, what to do, you can make a copy of the line and comment it out with a # to keep an original (in blue in the example below). My changed file looks like this:

[Desktop Entry]
Encoding=UTF-8
Name=Carousel
Comment=Loads several random images[...]
TryExec=carousel
#Exec=carousel -root
Exec=carousel -root -duration 19 -speed 0.6883 -delay 23404 -no-titles
StartupNotify=false
Terminal=false
Type=Application
Categories=Screensaver

That’s it basically. A preview of Carousel in the gnome-screensaver-with-no-settings dialog should show the theme with your settings. If your theme just vanished from the list, then you made a mistake in the file. Check it again. Since the settings are overwritten when the screensaver package is updated, it might be a good idea to keep a copy of the file. Another idea is to create another theme with your settings and a different name in a new file, which is not modified by the update process.

A few interesting links:

.



* dogs, cats and the rainwater capacitor

Posted on February 2nd, 2009 by jitu. Filed under Abroad.


Between the blocks of the New Hostel Complex in the Indian Institute of Science there is a fountain. Well, once there was a fountain, now it is a capacitor for many things. Intentionally built to hold back rain water and to release it slowly into the drainage system, it also collects pillows, trash in general, mud, leaves and depending on the water level also cats and dogs. Not to mention that it is a perfect breeding ground for all kind of mosquitoes with a unique flora and fauna.

The rainwater capacitor between the blocks of the New Hostel Complex

The rainwater capacitor between the blocks of the New Hostel Complex

One day just before an exam, I did not sleep that well. At around 3AM in the night I heard a loud splash and the usually calm water of the rain water capacitor got disturbed. A dog jumped into the capacitor and swam happily around. Well, its happiness vanished at that point in time, when it realized, that a height of 1.5m from the water surface to the upper edge is a little bit too high to jump. Especially out of the 80cm deep water and when it could not touch the floor. So it started to scratch the walls whimpering. How to get it out without getting bitten (it was a stray dog)? The security boy said it is too early and I should let it swim (and eventually drown). The thing is that a dead body is always harder to get out than a swimming one, since you have to go to the corpse through the smelly water, while a living being is able to move to a better position.

Actually the water was so smelly that nobody volunteered to take a dip. So we organized a rope and a big bag from the junk in the hostel basement. We lower the bag to see, what happens. Surprisingly the dog was quite smart. It swam to the bag, turned it and pushed it under the water. Then it went into the bag and stopped doing anything. We lifted the bag and its 200 liters of water slowly out of the capacitor. Fortunately the bag was so old that it had lots of holes and the water could flow out. But it put a lot of strain to the bag handles. The dog was also so smart not to shake the water off in close proximity to us, when it jumped out of the bag on the safe land.

It seems that the capacitor is also attracting young cats which keep meowing all night since they cannot find an exit. Since the capacitor is fed by a pipe system from the roofs and surroundings of the hostel blocks the animals trapped in there, can go almost anywhere, being able to annoy all residents. If someone tries to catch them, they will escape into the pipes and come out at a far distant place. Usually the hunger will take care of the trapped animals and they begin to search for an exit more eagerly instead of being lazy and only crying for help. By that way, they will learn the lesson.

.