Sunday, 30 March 2014

Connecting a USB 1.1 device to a USB 3.0 port

I upgraded my computer recently and the new motherboard has USB 3.0 ports throughout, which meant a great improvement in transfer speed for external hard disks.

However I have an ancient Canon flatbed scanner which I use for the occasional document. This was initialised by gscan2pdf, although very slowly, but scans failed with an I/O transfer problem.

Some probing with sane-find-scanner and scanimage, lower level utilities, showed that the scanner wasn't recognised properly, only the driver (plustek) could be ascertained (presumably from the USB vendor and device IDs), but no details about the scanner could be probed.

I remembered a similar situation a while back where a new workstation wouldn't recognise the keyboard and mouse at boot time although later the GUI system did. In that situation, interposing a hub solved the situation. So I put a USB 2.0 hub that I had handy between the motherboard port and the scanner, and lo and behold, everything worked fine from that point.

The specs at the Wikipedia page on USB 3.0 don't clarify whether 3.0 is always backward compatible with 1.1. So if you run into this problem try a hub.

Wednesday, 5 March 2014

CentOS/RHEL: dig axfr works but zone transfer fails?

I set up named as a secondary with a stanza like this:

zone "example.com" IN {
        type slave;
        masters { 10.0.0.1; };
        file "example.com.zone";
        notify yes;
};

When I restarted named the log messages in /var/log/messages told me that the transfer failed. However I could do:

dig @10.0.0.1 axfr example.com

just fine. What was the problem?

Looking in /var/named/chroot/var/named I saw that there was a directory named slaves. Should I be using that? Looking at the permissions, I saw:

total 88
drwxr-x--- 4 root  named 4096 Jan  7  2013 .
drwxr-x--- 6 root  named 4096 Jan  7  2013 ..
drwxrwx--- 2 named named 4096 Mar  4 23:23 data
-rw-r----- 1 root  named  208 Apr 28  2005 localdomain.zone
-rw-r----- 1 root  named  195 Apr 28  2005 localhost.zone
-rw-r----- 1 root  named  427 Apr 28  2005 named.broadcast
-rw-r----- 1 root  named  424 Apr 28  2005 named.ip6.local
-rw-r----- 1 root  named  426 Apr 28  2005 named.local
-rw-r----- 1 root  named 1892 Feb 26  2008 named.root
-rw-r----- 1 root  named  427 Apr 28  2005 named.zero
drwxrwx--- 2 named named 4096 Mar  5 00:59 slaves

Yes, I bet I'm supposed to use the directory slaves because that's writable by named but the top zone directory isn't, so I changed the line in the stanza to:

        file "slaves/example.com.zone";

and it worked.

You may see advice on the Web to change permissions of the top zone directory. Don't do that. Work with the structure and permissions that the distribution makers have developed.

Saturday, 14 December 2013

Adjusting the service shutdown sequence on Debian

I manage a few virtual Debian (Wheezy) machines that mount an iSCSI volume. These hold websites and mysql data.

The problem is that in the default shutdown sequence, umountiscsi.sh is called before shutting down cherokee (or apache2) and mysql. So the umount fails because the filesystem is busy and the machine doesn't shutdown properly from the CLI, requiring a reset at the VMWare console.

I searched around for the way to adjust the dependency based boot and shutdown sequence and after reading a lot of web and manual pages I finally understood the way to do it.

First edit /etc/init.d/cherokee (or /etc/init.d/apache2) and /etc/init.d/mysql so that the line:

# Required-Stop:

contains umountiscsi.sh

The logic of Required-Stop is that the services named on the line depend on the current service (webserver, database) being stopped first.

Now run:

insserv -d -v umountiscsi.sh

Despite the warnings on the man page that this is too low level, this is the right command to use. It will rebuild the symlinks in the runlevel directories as well as regenerate the files /etc/init.d/.depend.{boot,start,stop} Next time you shutdown, the webserver and database will be shutdown before unmounting the iSCSI volume.

This assumes that the default start and stop sequences expressed in the INIT lines are correct for you. If you have added services manually using update-rc.d at particular runlevels and sequence points then I cannot guarantee that you will get the desired result.

Saturday, 7 December 2013

Shrinking an ext4 filesystem from the CentOS 5.x CD/DVD in rescue mode

Unfortunately this cannot be done because the resize4fs program is missing from the rescue filesystem. You'll have to use a rescue distro, for example gparted-live, where the ext4 capabilities are already incorporated into the up to date resize2fs. CentOS/RHEL 5 ships with an old resize2fs and ext4 capabilities are in separate programs.

If it were a matter of expanding the filesystem this could be done on a live system.

If it were not the root filesystem you might be able to unmount the file system and do this on a live filesystem.

If it were not ext4 you could use resize2fs.

In any case a shrink involves downtime for that filesystem.

There is however a fsck.ext4 in the rescue filesystem so you can still do fscks in rescue mode.

Friday, 11 October 2013

DOS 6.22 printing to Samba fails with Path not found

My workplace wanted a NT server for DOS 6.22 clients replaced by a Samba server. No problem. Disk shares worked fine. But when it came to printing, this happened:

>net use lpt1 \\samba-server\printername
>copy con lpt1
Testing
^Z

Blah blah Path not found

I looked at the log file for the client in question and found these lines:

[2013/10/01 14:02:22.820899,3] smbd/vfs.c:905(check_reduced_name) check_reduced_name [DEV/LPT1] [/var/spool/samba]
[2013/10/01 14:02:22.820941,3] smbd/vfs.c:944(check_reduced_name) check_reduce_name: couldn't get realpath for DEV/LPT1 (NT_STATUS_OBJECT_PATH_NOT_FOUND)

Ah, was it trying to create a file called DEV/LPT1 in /var/spool/samba? But there is no subdirectory called DEV. So I did this:

# cd /var/spool/samba
# ln -s . DEV

Voila, printing worked from DOS. I can only surmise that DOS sends the whole path rather than just LPT1 to Samba or indeed any SMB server.

Hope this helps you if you need to convert any DOS clients to use Samba instead of NT.

Thursday, 5 September 2013

Dumont d'Urville time?

When adding a new entry into Google Calendar on my Android phone, I noticed it defaulted to Dumont d'Urville time (UTC+10), although Sydney/Melbourne was also offered. What?!

A search shows that this is the time zone of a French Antarctic station which happens to be in the same time zone as the Eastern Australian seaboard. When I went into settings and chose Use Home Time Zone, all was good again. Pretty bizarre but amusing bug. I'm glad my appointments are in warmer climes.

It seems somebody has hit this bug before. Maybe it's because my phone has a rather old version of Android.

Sunday, 1 September 2013

Installing phpMyAdmin 3 on RHEL/CentOS 5.9 running PHP 5.3

If you are running the PHP 5.3 (php53-*) packages on RHEL/CentOS 5.9 and try to install the phpmyadmin package from CentOS Base or RPMForge, you will get messages about installing the ancient PHP 5.1 packages. This was not what I wanted to happen, so I looked for a ready made phpmyadmin package that would work with PHP 5.3. I was prepared to install from a phpMyAdmin tarball, but I hoped to avoid that because an official package would stay up to date with patches.

It wasn't well publicised but the answer is to add the EPEL repository by downloading the epel-release RPM from here and installing that. After that you can do yum install phpMyAdmin3 (case important). This is the package you want.