Wednesday, May 31, 2006

Power Management

Fedora Core 5 comes with the new "gnome-power-manager" which is rather good, as it provides a few more features than the old battery applet such as suspend-to-ram (suspend) and suspend-to-disk (hibernate). However, I can't get my Compaq Presario 2104EU to suspend-to-ram properly; it suspends ok, but powering on just gives me a blank screen. I'd tried to add boot options such as 'acpi_sleep=s3_bios', but to no avail. Either it's a flaky bios or I need to remove some modules before putting the laptop into suspend. What does work is hibernate, though I do have to run 'service network restart' upon resume as it seems to loose its network settings.

For FC5 you can update the 'gnome-power-manager' to the lastest version by adding this file to /etc/yum.repos.d/ and running:

# yum -y update gnome-power-manager.i386

Restarting your gnome session you get this new applet:



Choosing "information" from the menu displays extra's that aren't on the official FC5 release:





Tuesday, May 30, 2006

Loopback file systems

I had to mount a hard disk image today and found this excellent guide for loopback filesystems on Linux.

Saturday, May 27, 2006

Picasa for Linux

Picasa, the google photo manager, has been released for Linux. It's not a fully native port as it runs using WINE, but even so the performance doesn't seem to suffer for it and I've not noticed any missing features. Download and further information from here .

I'd suggest setting the 'Folder Manager' to only scan /home as by default it scans the whole file system, which makes Picasa take forever to load subsequently!

For anybody that doesn't like the ugly 'winfile' when you 'Locate on Disk' in Picasa just create a script called 'picasa-hook-filemanager.sh' with the following content somewhere in your path (this only works for Gnome):

#/bin/bash
nautilus `dirname "$1"`

This is from the Picasa/Linux FAQ.

"You may be surprised that Picasa can't locate files on your Gnome system. Unfortunately, we weren't able to find a way to make Nautilus to open with the correct file highlighted."

I couldn't get the highlight working either even though this link suggests it may be possible on 2.14.

Friday, May 26, 2006

Fix that eject button!

On Linux systems there really is no need to have the cd-rom drawer locked when a disc is inside and having to run the "eject" command to open the tray. This behaviour can be easily fixed with:

# echo "dev.cdrom.lock=0" >> /etc/sysctl.conf

Followed by a reboot. To have it take effect immediately:

# sysctl -w dev.cdrom.lock=0

Nautilus Actions

As much as I like the Gnome desktop there are times when I want to perform a specific action (send a file via bluetooth for example) on a file or directory and have to use gnome-terminal because nautilus (the gnome file manager) doesn't support what I'm trying to do. Forunately I have now discovered two ways around this; the package nautilus-actions and the native nautilus scripting. I prefer the first method which allows custom right-click actions on objects in nautilus, and here is how you go about it (tested on FC5):

1. Install "nautilus-actions"

#yum -y install nautilus-actions

2. Launch the nautilus-actions configurer from the Gnome panel

Desktop/Preferences/More Preferences/Nautilus Actions Configuration

3. Nautilus-actions will start with no preconfigured actions so we must click on "Add"

4. I'm using "Send files via bluetooth" as an example



Here is the definition of the editable values:

"Label"
How this will appear on the right-click menu

"Tooltip"
An optional descriptive text that will appear at the bottom of the nautilus window

"Icon"
Optional icon to precede the label

"Path"
The executable or script that we wish to perform the action (full path is only necessary if the executable is outside of your normal path ie /sbin )

"Paramters"
Paramters passed to the executable




I'm using "%M" which will pass the full name and path of the files selected to the executable, in this case "gnome-obex-send".

5. Configure the conditions and advance conditions. These allow you to set the actions behaviour so that it will only work on certain file types, or if the action applies to local or remote (network) file systems.

6. Click ok to save then close the application.

7. Test by opening a naultilus window, selecting a file and right clicking:



We have a new nautilus action!

I also tried to add an action to send files via thunderbird (I don't like evolution much) by using this command:

thunderbird -compose "attachment='file:///%M'"

It seems that Thunderbird 1.5 is broken at this time and doesn't process its command line arguments properly.

Thursday, May 25, 2006

Ext3 and full data journaling

Ext3 is a stable and mature file system, offering a good balance of speed and reliability. But what many people do not realise is that the default journaling support is only for meta-data, not all data. Here is the relevant section from 'man tune2fs':

journal_data
When the filesystem is mounted with journalling
enabled, all data (not just metadata) is committed
into the journal prior to being written into the
main filesystem.

journal_data_ordered
When the filesystem is mounted with journalling
enabled, all data is forced directly out to the main
file system prior to its metadata being committed to
the journal.

journal_data_writeback
When the filesystem is mounted with journalling
enabled, data may be written into the main filesys-
tem after its metadata has been committed to the
journal. This may increase throughput, however, it
may allow old data to appear in files after a crash
and journal recovery.

So the default mount option is with "journal_data_ordered". This is considered the fastest option, but at the expense of full data recovery in the event of a power outage etc. You can look at many of the tunable parameters with 'tune2fs -l /dev/hdx' or in my case as I'm using LVM:

# tune2fs -l /dev/mapper/VolGroup00-LogVol00
tune2fs 1.38 (30-Jun-2005)
Filesystem volume name:
Last mounted on:
Filesystem UUID: b0c69d9c-234f-444d-ba95-f979a4902f4d
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options:
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 19005440
Block count: 19005440
Reserved block count: 950272
Free blocks: 5362926
Free inodes: 18381437
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 32768
Inode blocks per group: 1024
Filesystem created: Wed Jul 6 20:23:44 2005
Last mount time: Thu May 25 10:03:33 2006
Last write time: Thu May 25 10:03:33 2006
Mount count: 226
Maximum mount count: -1
Last checked: Wed Jul 6 20:23:44 2005
Check interval: 0 ()
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
First orphan inode: 695882
Default directory hash: tea
Directory Hash Seed: 11dc53e2-545c-4880-a6a6-792557a40a3d
Journal backup: inode blocks


The value 'Default mount options: ' is empty meaning its only using the meta-data journaling. To set a new value here we run:

# tune2fs -o journal_data /dev/mapper/VolGroup00-LogVol00

NOTE: I've run this command on a mounted file system (in fact on the root file system / ) with no ill effects. However, if you are concerned about your data (and I suggest you always have backups) then only run this command on file systems after they are dismounted; either boot in rescue mode or from a bootable cd like Knoppix.

Also, we can edit our /etc/fstab to set the default mount option there by adding the "data=journal" option:

/dev/VolGroup00/LogVol00 / ext3 defaults,noatime,data=journal 1 1

Thats it. We now need to reboot the system (for / ) or remount (for any other file system) to begin taking advantage of full data journaling.

I've not noticed any performance degredation with "journal_data" and have heard reports that it is actually faster in some circumstances .

Encryption with LUKS, Gnome and HAL

I've been playing around with the various disk/file encryption methods for Linux and I'm particulcarly impressed by LUKS on the Gnome desktop as described here. LUKS is a standard for hard disk encryption using the linux kernel (2.6) crypto API and dm-crypt mapper.

What I really wanted from disk encryption was ease of use and cross platform portability. I have tried out truecrypt which fits the bill for being cross platform but I found is still a little tedious for use on the desktop (perhaps I'll do another post about my adventures with truecrypt).

Anyhow, LUKS/HAL only just made it into Fedora Core 5 (without much fanfare) and really does make linux disk encryption easy; encrypt your partition, create a file system, plug in your device! The instructions below were based of the how-to from here .

1. Identify the volume you will be encrypting with dmesg. In my case the partition is /dev/sda1 on an external usb2 hard disk which I had previously created with fdisk.

2. Make sure the device is not mounted:

# umount /dev/sda1

3. Create the LUKS partition on the usb drive:

# cryptsetup --verbose --cipher "aes-cbc-essiv:sha256" --key-size 256 -verify-passphrase luksFormat /dev/sda1

Enter and confirm the passphrase for the volume. I suggest using a long passphrase (at least 10 characters, but the more the better obviously!) with a mix of case and numbers.

4. Create a device mapping from the virtual crypto volume to the physical device:

# cryptsetup luksOpen /dev/sda1 usbdisk

This will create a block device /dev/mapper/usbdisk.

5. Make a new file system on our new device:

# mkfs.vfat -v -F 32 -n "20GB USB" /dev/mapper/usbdisk

This will create a FAT32 file system on my external usb disk (I hope to use this with windows too at some point!)

6. Now we just unplug and re-insert the usb disk and:



Up pops the password dialogue box for our disk! Enter the passphrase for the volume and the disk will be mounted in /media with a conveniant shortcut on the desktop.





Wednesday, May 03, 2006

Sony Ericsson K750i


I've recently bought myself a new mobile phone, and I'm pleasently surprised by how well it works with Linux. Below is the output from dmesg after pluging the phone into a usb port:

May 3 16:21:07 poseidon kernel: usb 7-1.3: new full speed USB device using ehci_hcd and address 10
May 3 16:21:07 poseidon kernel: usb 7-1.3: configuration #1 chosen from 1 choice
May 3 16:21:07 poseidon kernel: cdc_acm 7-1.3:1.1: ttyACM0: USB ACM device
May 3 16:21:07 poseidon kernel: cdc_acm 7-1.3:1.3: ttyACM1: USB ACM device
May 3 16:21:07 poseidon kernel: scsi4 : SCSI emulation for USB Mass Storage devices
May 3 16:21:12 poseidon kernel: Vendor: Sony Eri Model: Memory Stick Rev: 0000
May 3 16:21:12 poseidon kernel: Type: Direct-Access ANSI SCSI revision: 00
May 3 16:21:12 poseidon kernel: SCSI device sdb: 126912 512-byte hdwr sectors (65 MB)
May 3 16:21:12 poseidon kernel: sdb: Write Protect is off
May 3 16:21:12 poseidon kernel: sdb: assuming drive cache: write through
May 3 16:21:12 poseidon kernel: SCSI device sdb: 126912 512-byte hdwr sectors (65 MB)
May 3 16:21:12 poseidon kernel: sdb: Write Protect is off
May 3 16:21:12 poseidon kernel: sdb: assuming drive cache: write through
May 3 16:21:12 poseidon kernel: sdb: sdb1
May 3 16:21:12 poseidon kernel: sd 4:0:0:0: Attached scsi removable disk sdb
May 3 16:21:12 poseidon kernel: sd 4:0:0:0: Attached scsi generic sg2 type 0
May 3 16:21:15 poseidon kernel: SELinux: initialized (dev sdb1, type vfat), uses genfs_contexts

The on-board memory stick (which I must upgrade as it's only 64mb!) is automatically mounted by gnome with a removable file-system icon on the desktop. Gthumb even starts and asks if I wish to import photo's! I can even use the phone as a modem (dev/ttyACM0) when connect via the supplied usb cable. Presumably I'll be able to use the K750i as a modem over bluetooth as I was with my previous T610, but I've not tried yet...

Sendmail, dovecot, squirrelmail and Maildir

I had to advise somebody today on how to configure sendmail/dovecot/squirrelmail with Maildir. There really is no excuse not to switch to Maildir; it's both faster than mbox and supports sub directories!
I know this works on Fedora 4/5 so I just thought I'd post the config before I forget:

/etc/procmailrc (just the one line needed)
DEFAULT=$HOME/Maildir/

/etc/dovecot.conf (replace the appropriate line in your existing config)
default_mail_env = maildir:/%h/Maildir

/usr/share/squirrelmail/config/config.php (this section is near the beginning of the file)
$domain = 'yourdomain.com';
$imapServerAddress = 'localhost';
$imapPort = 143;
$useSendmail = true;
$smtpServerAddress = 'localhost';
$smtpPort = 25;
$sendmail_path = '/usr/sbin/sendmail';
$pop_before_smtp = false;
$imap_server_type = 'courier';
$invert_time = false;
$optional_delimiter = '.';
$encode_header_key = '';