mod_jk configuration does not work anymore after upgrading to Ubuntu 10.04 LTS

I recently upgraded a well working Ubuntu server instance from 8.04 LTS to 10.04 LTS as the support for 8.04 LTS will end this April 2013. This server system uses a JBoss(+Tomcat)/Apache2.2 stack for delivering its services. The connection between Apache and JBoss has been realised using the mod_jk plugin for Apache which uses the AJP approach. In 8.04, this worked fine. After having performed the do-release-upgrade, this connection did not work anymore. Increasing the logging level of the mod_jk plugin to debug, the logfile contained "missing uri map for <servername>:<path>" messages.

Looking around for possible causes, I found this email conversation, suggesting to use the JkMountCopy All directive in the global Apache2 configuration file. This solved the problem.

Another result suggested even not using mod_jk anymore but using the newer mod_proxy_ajp.

Creating a USB Flash Drive to boot VMWare VMvisor 5.0 installer

There are lot of guidelines available on how to create a bootable USB stick with VMware installer. Some of them use manual copying e.g http://www.ivobeerens.nl or http://www.techhead.co.uk or use the UNetbootin tool in Windows to create a bootable USB stick: https://community.emc.com.
But one major thing is to be obeyed: The USB stick must be formatted in FAT32 file system and the partition must be made active. Formatting the USB stick in Windows, all of this is done more or less automatically, but if you have only Linux at hand, you must follow a few steps that are also described in the vSphere 5 Documentation Center:

2 Create a partition table on the USB flash device.
/sbin/fdisk /dev/sdb
a Type d to delete partitions until they are all deleted.
b Type n to create primary partition 1 that extends over the entire disk.
c Type t to set the type to an appropriate setting for the FAT32 file system, such as c.
d Type a to set the active flag on partition 1.
e Type p to print the partition table.

The result should be similar to the following text:
Disk /dev/sdb: 2004 MB, 2004877312 bytes
255 heads, 63 sectors/track, 243 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 243 1951866 c W95 FAT32 (LBA)

f Type w to write the partition table and quit.

3 Format the USB flash drive with the Fat32 file system.
/sbin/mkfs.vfat -F 32 -n USB /dev/sdb1

Re-scanning SCSI bus for new devices

It might be useful to re-scan the SCSI bus when a new device has been plugged in, e.g. via VMWare ESXi configuration changes, that has not been automatically identified by the OS. In Debian/Ubuntu you can do the following:
sudo apt-get install scsitools
sudo rescan-scsi-bus.sh

You can check the /sys/bus/scsi/devices/ directory before and after the re-scan and via dmesg to which device node in /dev directory e.g. the new harddisk has been added.

Don’t forget about the environment when you use cron

The commands that are executed via cron are started in a different environment than the one you have while you test the command in a shell. The blog entry of Mike Tremell explains the reasons and gives solutions to the problem. The easiest one is to set up the correct environment in a script that you call in a crontab:

. /etc/profile
. /home/user/.profile

%-sign in crontabs

The %-sign has a special meaning in crontab.

man 5 crontab:

“…Percent-signs (%) in the  command,  unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent

to the command as standard input. ”

So don’t forget to escape the %-signs with a backslash if you use them for example to format the date output:

`date +'\%Y\%m\%d'`

Writing udev rules to create symbolic link for Huawei E220 USB GSM/UMTS Modem

On an Ubuntu 8.04 server, I connected a Huawei USB modem to send SMS using SMSLib. Normally, the modem interface can be found under /dev/ttyUSB0. For some reason, the system decided to mount the modem interface using /dev/ttyUSB1. To avoid to always reconfigure SMSLib, if such a change occurs, I decided to use udev rules to create a specific symlink for the modem interface.

1. Check with lsusb if the device is connected:

prompt> lsusb
Bus 005 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem
....

2. Somewhere in /var/log/messages you should find an information, to which devices the different ports of the modem have been mapped to. In my case, it is:

Jul  9 08:50:07 server kernel: [4378805.151459] usb 5-5.1: airprime converter now attached to ttyUSB1
Jul  9 08:50:07 server kernel: [4378805.151488] usb 5-5.1: airprime converter now attached to ttyUSB2
Jul  9 08:50:07 server kernel: [4378805.151513] usb 5-5.1: airprime converter now attached to ttyUSB3

3. After checking with minicom that ttyUSB1 is the correct port, I used

udevinfo -a -p $(udevinfo -q path -n /dev/ttyUSB1) > ttyUSB1.info
udevinfo -a -p $(udevinfo -q path -n /dev/ttyUSB3) > ttyUSB3.info

to retrieve information about the different device information stored in the udev database.  Simply running diff on the information shows you some hints, how to differentiate the devices and only create a symbolic link for one of those ports. In my case, the diff showed following results:

8,9c8,9
<   looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-5/5-5.1/5-5.1:1.0/ttyUSB1/tty/ttyUSB1':
<     KERNEL=="ttyUSB1"
---
>   looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-5/5-5.1/5-5.1:1.0/ttyUSB3/tty/ttyUSB3':
>     KERNEL=="ttyUSB3"
12c12
<     ATTR{dev}=="188:1"
---
>     ATTR{dev}=="188:3"

4. Using the information ATTR{dev}==”188:1″ and ATTRS{product}==”HUAWEI Mobile” in a parent device, I came up with the following udev rule that I put into /etc/udev/rules.d/98-modem.rules:

KERNEL=="ttyUSB*", ATTR{dev}=="188:1", ATTRS{product}=="HUAWEI Mobile", SYMLINK+="ttyS20"

According to the great tutorial Writing udev rules by Daniel Drake, it is not possible to mix attributes from different parent devices. This is why I used the ATTR{dev}==”188:1″ and not ATTRS{port_number}==”0″ as I already used ATTRS{product}==”HUAWEI Mobile” in a different parent device. (You could also ATTRS{idVendor}==”12d1″ and ATTRS{idProduct}==”1003″ to specify the modem instead of the product attribute.)

5. Simply let udev know about your newly created rule and check, if the system created the correct link:

promtp> sudo udevtrigger
prompt> ll /dev/ttyS20
lrwxrwxrwx 1 root root 7 2009-07-10 08:12 /dev/ttyS20 -> ttyUSB1

Now you can use the device /dev/ttyS20 in your SMSLib configuration. To be used in SMSLib, the symbolic link should be named to something resembling a standard serial port, like /dev/ttyS*. If you do not so, it is possible that SMSLib (or the used RXTX lib) does not correctly recognise the serial port. It my first try, I named the symbolic link /dev/huawei_modem. Minicom was fine with that, but SMSLib did not like it.