On Fri, 12 Oct 2007, Raimo Niskanen wrote:

> On Fri, Oct 12, 2007 at 08:01:13AM +0930, Edwards, David  (JTS) wrote:
> > > -----Original Message-----
> > > From: Nick Guenther [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, 11 October 2007 8:01 PM
> > > To: Edwards, David (JTS)
> > > Cc: misc@openbsd.org
> > > Subject: Re: Which remvable drive is connected to which USB port
> > >
> > > On 10/11/07, Edwards, David  (JTS)
> > > <[EMAIL PROTECTED]> wrote:
> > > > Hi again.
> > > >
> > > > Just a wrap up to this thread.
> > > > -----------------
> > [snip]
> > 
> > >> I'm not happy with the fact that the script uses dmesg output.
> > >> dmesg uses a ring buffer and that can fill very quickly
> > >> (say if you unplug a usb disk while something is writing
> > >> to it) which will break the above script totally.  However,
> > >> currently I don't have the time (or probably the expertise)
> > >> to go through the source to work out a better way to do
> > >> it.
> > 
> > > everything in dmesg is also dumped to /var/log/messages.
> > > disk naming *is* consistent in OpenBSD. devices are all named in a
> > > deterministic manner, so that they won't change on you without you
> > > realizing it / adding an extra layer of naming indirection.
> > >
> > > What are you actually trying to do here? boot from a USB disk?
> > 
> > Hi, thanks for responding.
> > 
> > I'm using USB disks for backups.
> > 
> > The problem I have is that there are multiple backup sets that
> > I need to keep for different purposes so I need to know which
> > physical USB port a disk device is attached to.
> > 
> > I've got three USB cables labelled with the names of the backup
> > sets (set 1, set 2...) and when I swap a disk on one of the
> > cables, I need to know the disk device to mount so that I can
> > dump the right set onto it..
> > 
> > It seems that the disk devices are named (sd1, sd2 etc) based
> > on which one is plugged in first (unrelated to the physical
> > port).  My testing shows that the disk device names are retained
> > as long as the box is not rebooted, but if it reboots, then
> > I can no longer be sure that the right disk is plugged into
> > the right port and my backup sets would get mixed up.
> > 
> > So, basically I need a tool where I can start with a physical port
> > description (seems /dev/usb# "addr #" works) and end with a disk
> > device (sd#).
> > 
> > The script I put together works fine, but it relies on dmesg (or
> > as you suggested /var/log/messages) which grates on my sense of
> > neatness (or maybe I'm being too precious :-)
> > 
> > I'll take the time to have a look at the sources one day.  I'm
> > sure it would be possible to write a tool that would be able to
> > work this out in a better way.  Would you have any pointers as
> > to where to start looking?
> 
> I would like there to be some kind of usb tool where you can 
> query interesting properties about the usb device, such as
> manufacturer and serial number. I think there is some kind
> of tools in ports, but do not think they can give the
> needed data...
> 
> Correction. The usbutil package has got a command usbctl that
> gives the needed data:
> # usbctl -f /dev/usb1 -a 2
> prints out a "DEVICE descriptor" containing:
>   iManufacturer, iProduct, iSerialNumber
> 
> BUT...
> 
> The problem is to map what hotplug/attach sees - sd0 class 2,
> scsibus1 class0 and umass0 class 0, to /dev/usb1 address 2.
> 
> Missing is still some way to find out what the kernel device
> tree looks like - the kernel must know that sd0 is attached
> to scsibus1 targ 1 lun 0 which is attached to umass0 which
> is attached to uhub1 port 1. The question is if there is
> a way of finding that without parsing dmesg.
> 
> I also can not see how to map uhub1 port 1 to /dev/usb1 address2.
> 

I can see an easy way to identify disks, without any dependency on the
physical stuff like cables etc.

Use the disklabel: it has a disk name field that can be edited. 

        -Otto

Reply via email to