Content here is by Michael Still mikal@stillhq.com. All opinions are my own.
See recent comments. RSS feed of all comments.


If you're interested in what patches I have submitted, and their status, then you really should be looking at this page.


Tue, 31 Jan 2017



Giving serial devices meaningful names

    This is a hack I've been using for ages, but I thought it deserved a write up.

    I have USB serial devices. Lots of them. I use them for home automation things, as well as for talking to devices such as the console ports on switches and so forth. For the permanently installed serial devices one of the challenges is having them show up in predictable places so that the scripts which know how to drive each device are talking in the right place.

    For the trivial case, this is pretty easy with udev:

    $  cat /etc/udev/rules.d/60-local.rules 
    KERNEL=="ttyUSB*", \
        ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", \
        ATTRS{serial}=="A8003Ye7", \
        SYMLINK+="radish"
    


    This says for any USB serial device that is discovered (either inserted post boot, or at boot), if the USB vendor and product ID match the relevant values, to symlink the device to "/dev/radish".

    You find out the vendor and product ID from lsusb like this:

    $ lsusb
    Bus 003 Device 003: ID 0624:0201 Avocent Corp. 
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 007 Device 002: ID 0665:5161 Cypress Semiconductor USB to Serial
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    


    You can play with inserting and removing the device to determine which of these entries is the device you care about.

    So that's great, until you have more than one device with the same USB serial vendor and product id. Then things are a bit more... difficult.

    It turns out that you can have udev execute a command on device insert to help you determine what symlink to create. So for example, I have this entry in the rules on one of my machines:

    KERNEL=="ttyUSB*", \
        ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", \
        PROGRAM="/usr/bin/usbtest /dev/%k", \
        SYMLINK+="%c"
    


    This results in /usr/bin/usbtest being run with the path of the device file on its command line for every device detection (of a matching device). The stdout of that program is then used as the name of a symlink in /dev.

    So, that script attempts to talk to the device and determine what it is -- in my case either a currentcost or a solar panel inverter.

    Tags for this post: linux udev serial usb usbserial
    Related posts: SMART and USB storage; Video4Linux, ov511, and RGB24 palettes; ov511 hackery; Ubuntu, Dapper Drake, and that difficult Dell e310; Roomba serial cables; Via M10000, video, and a Belkin wireless USB thing

posted at: 12:04 | path: /linux | permanent link to this entry


Fri, 21 Aug 2009



Who writes Linux?

posted at: 02:22 | path: /linux | permanent link to this entry


Mon, 08 Dec 2008



Upgrading Ubuntu Feisty now that its end of lifed

posted at: 20:28 | path: /linux/ubuntu | permanent link to this entry


Sun, 31 Aug 2008



TCP_DENIED/403 for cache accesses using squid

    I just spent some time debugging why squid wouldn't work for localhost, but seemed to work for other clients on my network. To cut a long story short, Linux for some reason wasn't using 127.0.0.1 for traffic to localhost. It was instead using the public IP address for the machine, which didn't match either the localhost ACL or the local network ACL. I am sure there is some fancy reason that this is the case, but if you see this problem, then consider checking your localhost ACL.

    Tags for this post: linux squid

posted at: 10:21 | path: /linux/squid | permanent link to this entry


Mon, 18 Aug 2008



The currently broken state of video for Linux

posted at: 08:55 | path: /linux/v4l | permanent link to this entry


Sat, 16 Aug 2008



Why sync twice on shutdown?

posted at: 12:26 | path: /linux | permanent link to this entry


Sun, 06 Jul 2008



v4l2 webcam software?

posted at: 23:55 | path: /linux | permanent link to this entry


Sat, 03 May 2008



A ssh quickie

    I tend to have lots of ssh tunnels running with port forwarding on my laptop. The problem with that is that there are of course different host keys for localhost then. That makes me sad. Luckily, the following config option disables host key checking for localhost:

    $ cat /home/mikal/.ssh/config 
    NoHostAuthenticationForLocalhost yes
    


    Too easy.

    Tags for this post: linux ssh
    Related posts: Slow git review uploads?; Andrew's SSH filtering causes me pain; Twisted conch; clusterssh

posted at: 11:38 | path: /linux | permanent link to this entry


Thu, 01 May 2008



What packages are taking all my disk?

posted at: 16:42 | path: /linux/ubuntu | permanent link to this entry


Sat, 29 Jul 2006



Nice touch

    Ok, so I don't know about you, but pretty much the only time I have a copy of Windows these days is when I take delivery of a new laptop like I did this morning, before I get around to installing Linux on it. To verify that my download and cdrecord had produced something valid, I just stuck the Ubuntu Dapper CD I just made into the CD ROM drive on this Windows laptop.

    It's really cool. It launches an application with the autorun stuff on Windows, and then offers to let me install open source on the Windows partition. It's like a small version of the OpenCD (and was in fact done with their help). Applications it offers to install:

    • Mozilla Firefox
    • Mozilla Thunderbird
    • Abiword
    • Gaim
    • The Gimp


    It's a nice touch that the CD can be used for this sort of thing as well. Like all ideas, it's so obvious now that I've seen it done, and it makes me wonder why other distros haven't been doing this for a while.

    Another on Mikal's rocks list for the day -- Ubuntu.

    Tags for this post: linux ubuntu windows opensource installer
    Related posts: HP iPaq GPS FA256A; Getting ASP.NET working on Windows XP Tablet PC edition; What packages are taking all my disk?; Installing Linux on a Dell Dimension e310; Foxtel iQ launch; MySQL Workbench

posted at: 15:07 | path: /linux/ubuntu | permanent link to this entry


Tue, 25 Jul 2006



Debian / Ubuntu packaging

posted at: 08:13 | path: /linux/ubuntu | permanent link to this entry


Sun, 19 Mar 2006



Ubuntu, Dapper Drake, and that difficult Dell e310

posted at: 22:03 | path: /linux | permanent link to this entry


Fri, 16 Dec 2005



About to resize my LVM

    When I created my USB2 mirrored LVMed disk array I go asked a few questions about performance of the disks, how long it took to setup, and stuff like that.

    At the time it was too late to get that data as I already had things I cared about on the disk array. Now it's time to grow the array so I've picked up two more disks. I've collected some data, so I now have data on the setup process for a new LVM from two USB 2 disks, and bonnie results for the filesystem on those disks. I don't have the date with me though, so I will write it up in the next few days.

    Is there anything else people would like to know before I put these disks into action?

    Oh, and yes this does mean that there is now a terrabyte of disk in that array. That brings the total amount of storage I have online at my house to 1.2 terrabytes. That doesn't include the old disk array still running in Australia either. Fun fun fun.

    Tags for this post: linux md lvm raid filesystem
    Related posts: Building my new disk array; Adding space to the disk array; Large inodes = faster samba; Linux USB quandary

posted at: 09:28 | path: /linux | permanent link to this entry


Thu, 24 Nov 2005



Adventures in Ubuntu Breezy Dovecot

    I mentioned the other day that I am having problems with Dovecot on Ubuntu Breezy. Now's the time to debug it, and here are my notes...

    No inetd.conf

      sed: can't read /etc/inetd.conf: No such file or directory
      


    This first error is because of this poorly implemented test:

      # The init script should do nothing if dovecot is being run from inetd
      for p in `sed -r "s/^ *(([^:]+|\[[^]]+]|\*):)?(pop3s?|imaps?)[ \t].*/\3/;t;d" \
        /etc/inetd.conf`
      do
        for q in `sed -r "s/^ *protocols[ \t]*=[ \t]*(([^\"]*)|\"(.*)\")/\2\3/;t;d" \
          /etc/dovecot/dovecot.conf`
        do
          if [ $p = $q ]; then
            exit 0
          fi
        done
      done
      


    You can see from the comment that the intention is that the init script doesn't do anything if dovecot is running from inetd. The error message is kinda bogus though, in that the code keeps executing after that failed line with the sed call in it. If you find the error annoying, then make it go away:

      touch /etc/inetd.conf
      


    In a perfect world, you'd hope that the packager would change the script to do something more like this:

      for p in `sed -r "s/^ *(([^:]+|\[[^]]+]|\*):)?(pop3s?|imaps?)[ \t].*/\3/;t;d" \
        /etc/inetd.conf 2> /dev/null`
      


    Moving right along...

    It doesn't start the service

    I had enabled the imap_listen variable in the dovecot.conf file, but not put it in the protocols variable. The init script checks this, and bugged out without an error message. I would think an error message would be nicer.

    And now it works.

    Tags for this post: linux ubuntu dovecot
    Related posts: Ubuntu Breezy and Dovecot hate me; Nice touch; What packages are taking all my disk?; Installing Linux on a Dell Dimension e310; MySQL Workbench; Old ImageMagick packages in Debian and Ubuntu

posted at: 20:40 | path: /linux/ubuntu | permanent link to this entry


Stuffit expander for linux, but open source

    I've been working with publishing people recently, and they're all Macintosh users. There is a trial version of Stuffit expander for linux, but they really want me to give them money after 15 days... I've googled for an open source alternative, but can't find one. Is that because one doesn't exist?

    Tags for this post: linux stuffit

posted at: 14:30 | path: /linux | permanent link to this entry


Wed, 23 Nov 2005



Ubuntu Breezy and Dovecot hate me

posted at: 14:54 | path: /linux/ubuntu | permanent link to this entry


Sun, 13 Nov 2005



Linux USB quandary

posted at: 02:07 | path: /linux | permanent link to this entry


Sat, 12 Nov 2005



SMART and USB storage

posted at: 00:27 | path: /linux | permanent link to this entry


Fri, 11 Nov 2005



Adding space to the disk array

posted at: 21:21 | path: /linux | permanent link to this entry


Tue, 25 Oct 2005



Building my new disk array

    I have an opportunity to build a new disk array for when I move house. I made a few mistakes when I built the last one (although perhaps they were because it was the best that could be done at the time), and I don't intend to repeat those mistakes. I put out a call for suggestions a little while ago, and now I've built an array I'm pretty happy with. Let's walk through it.

    First off, let's start with a reminder of the requirements. Here's what I said in the previous post:

    • Reliable: be that mirrored or RAIDed
    • Expandable: I want to be able to drop in a new disc when I run out of space. I don't mind needing to add two identical discs if that makes point 1 easier
    • Rethingable: I want to be able to remove unreliable discs from the set. If there are paired discs, then I can handle having to cycle out both at the same time.
    • Non-sucky


    The hardware

    I now have two identical USB 2.0 external hard disk enclosures, each with a 250gb Seagate Barracuda drive in it. I picked USB 2.0 because I want the disks to be easy to move, and I picked external enclosures in the hope that this would ruggedize the disks for the trip to the US just a little. They'll be travelling in my carry on luggage.

    The mirroring

    Both of the disks are part of a MD mirror pair, and I must say that MD is a lot nicer than last time I played with it. Here's all I needed to do to set it up (sdb2 and sdc2 are the partitions with the MD on them):

    mdadm --create /dev/md1
          --raid-devices=2
          --spare-devices=0
          --level=1
          /dev/sdb2 /dev/sdc2
    
    mdadm --detail /dev/md1
    


    No config files in /etc like you used to. No need to do more configuration. It just works. What happened to the first partitions on the discs? They're each an 8 megabyte FAT partition with nothing in it but a meaningful name. This is so that I can tell which disk is which no matter what if they end up falling out of their labelled cases or something.

    So, we have redundancy... Let's make it expandable and shrinkable

    Then I used LVM to create a volume group and a logical volume on md1, which is where I will store the data. This is so I can expand and shrink the filesystem as my storage needs grow and disks fail. I currently get a disk failure per year with the current disk array (which is currently four disks), and I currently consume a little over 230gb. Yes, I know I'm going to need to buy more disk real soon, but I thought I would wait until I am in the US.

    Creating the LV:

    pvcreate /dev/md1
    vgcreate data /dev/md1
    lvcreate -L<size> -ndatalv data
    vgdisplay data
    
    mkfs -text3 /dev/data/datalv
    


    And we're done. Any comments?

    Tags for this post: linux md lvm raid mirror storage filesystem
    Related posts: About to resize my LVM; Adding space to the disk array; 14 November 2003; LCA CD continues; Mirror traffic during the last day of LCA 2007; Life skills

posted at: 00:49 | path: /linux | permanent link to this entry