Re: : Which remvable drive is connected to which USB port
On Tue, Oct 16, 2007 at 12:32:21PM +0930, Edwards, David (JTS) wrote: I was hoping to use physical lables on the USB disks with labelled USB cables but I've just found out during testing that the connection between a USB device and a physical cable is not as simple as I first thought. I unplugged all the disks and plugged one back into a labelled port. That port used to be /dev/usb4 addr 5. but it seems it's now /dev/usb4 addr 3 and addr 5 doesn't seem to exist anymore. Looks like I'm going to have to use disklabel to label each disk and hotplug to mount them. The backup script will have to check the mount point to make sure the disk is mounted and unmount it after the backup is finished. In other words, the script I posted earlier is useless folks.. My problem now is to figure out how to get our people to work with this. Preparing a new USB disk is not going to be easy for them. I'm probably going to have to write a web interface for it sigh. As far as I know, every time you put a filesystem on a device, you can lable it but it will also be assigned a UUID. Whoever first uses a USB disk/stick can either give it a name from whatever namespace you specify or note the UUID that it gets assigned and put that on a physical label on the device. Then, make a set of mount points, one for each device and put a line for each in fstab. Stick the devices into whatever USB slots you like, and have the backup script mount all the devices at which time it can verify that all devices have mounted successfully. Then it can go ahead and run the backup and umount them at the end. I don't see, and never have seen, a use for hotplug, especially if things are scripted anyway. As for preparing a new USB disk, write a new-disk script that tells people step by step what to do. like (psudocode) get tail /var/log/syslog print plug new device into any USB port get tail /var/log/syslog diff the two, grep for sd*, if more than one device print more than one device showed up, lets try again loop back to top print This device is showing up as /dev/sde and is listed as a Seagate super-duper 100 TeraByte pocket USB drive. Is this correct? Y/N Y print placing new filesystem on device... print UUID is DAKA90Q20KA002IWWA2IWREKA print creating mount point and fstab entry print New device is now registered with the backup system. print Create a physical label with the UUID and place it on the drive. Or: print The printer is now printing out a barcode UUID label. print Please affix this this to the drive and then store the drive. print Thank you. Doug.
Re: : : : Which remvable drive is connected to which USB port
On Fri, Oct 12, 2007 at 10:25:51AM -0400, Nick Guenther wrote: On 10/12/07, Stuart Henderson [EMAIL PROTECTED] wrote: On 2007/10/12 11:47, Raimo Niskanen wrote: Use the disklabel: it has a disk name field that can be edited. Great proposal! I may be blind, but can not find an editable name field. Which is it? And how can I edit it? Label - you can edit it with disklabel -e. But I thought the problem was that he wants the first USB cable to always be the first USB backup--with constant churn of USB keys (so that there are many). Each key is only used once. How does editing the disklabel help in that case? Ouch! My reading was too sloppy - I thought I recognized an old problem of mine. Well,... to make editing the disklabel useful, one would have to change strategy and tag the disks to which set they belong, and not use the USB cable as set identifyer... -Nick -- / Raimo Niskanen, Erlang/OTP, Ericsson AB
Re: : Which remvable drive is connected to which USB port
Hi, I haven't followed this thread but this sounds like similar to the problem I had with USB printers. I had several and turning them randomly on made them have different ulptX device. I made a script for hotplug that creates symlink that points to the right device node. So, if you modify my script and use disklabel and labels beforehand, maybe it will help you. See for more details: http://users.openbsd.fi/iku/opensource/hotplug-1.1.tar.gz Sorry if I interpreted your message incorrectly and this isn't what you're looking for. -- Antti Harri
Re: : Which remvable drive is connected to which USB port
On Mon, 15 Oct 2007, Edwards, David (JTS) wrote: -Original Message- From: Otto Moerbeek [mailto:[EMAIL PROTECTED] Sent: Friday, 12 October 2007 5:53 PM To: Raimo Niskanen Cc: Edwards, David (JTS); misc@openbsd.org Subject: Re: : Which remvable drive is connected to which USB port On Fri, 12 Oct 2007, Raimo Niskanen wrote: [snip] 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 agree that's my problem in a nutshell. 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. Thanks for the idea but unfortunately it doesn't help. Take three USB disks, plug them in and then tell me how to put the right label on the right physical disk? Plug them in one by one and label them. That would be a manual process. It would work of course if our restore procedure went: for each backup disk available Plug in the disk and check the lable to see if it's the right one if it is the right one Restore from the disk end fi end I suspect this would get a bit tedious.. It's easy to make a script that produces the sdX - label mappings and vice versa. -Oto
Re: : Which remvable drive is connected to which USB port
On Mon, Oct 15, 2007 at 11:54:12AM +0300, Antti Harri wrote: Hi, I haven't followed this thread but this sounds like similar to the problem I had with USB printers. I had several and turning them randomly on made them have different ulptX device. I made a script for hotplug that creates symlink that points to the right device node. So, if you modify my script and use disklabel and labels beforehand, maybe it will help you. See for more details: http://users.openbsd.fi/iku/opensource/hotplug-1.1.tar.gz Sorry if I interpreted your message incorrectly and this isn't what you're looking for. Thanks for that. It, if anything, proves an idea of mine that i've yet to implement. It's an idea which I took from the udev filesystem on linux. I intended on using amd(8) and hotplug (making the symlinks) to attach usb disks/etc to the correct mountpoint. With that and some magic for wireless networks (under design), I planned to make all of the automagicall configured stuff possible for laptops. When I finally get around to scripting this I'll post it to [EMAIL PROTECTED] -- Antti Harri -0- -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Re: : Which remvable drive is connected to which USB port
-Original Message- From: Antti Harri [mailto:[EMAIL PROTECTED] Sent: Monday, 15 October 2007 6:24 PM To: Edwards, David (JTS) Cc: misc@openbsd.org Subject: Re: : Which remvable drive is connected to which USB port Hi, I haven't followed this thread but this sounds like similar to the problem I had with USB printers. I had several and turning them randomly on made them have different ulptX device. I made a script for hotplug that creates symlink that points to the right device node. So, if you modify my script and use disklabel and labels beforehand, maybe it will help you. See for more details: http://users.openbsd.fi/iku/opensource/hotplug-1.1.tar.gz Thanks for that. I didn't actually want to use hotplugd if I could help it as I was trying for a different approach. I was hoping to use physical lables on the USB disks with labelled USB cables but I've just found out during testing that the connection between a USB device and a physical cable is not as simple as I first thought. I unplugged all the disks and plugged one back into a labelled port. That port used to be /dev/usb4 addr 5. but it seems it's now /dev/usb4 addr 3 and addr 5 doesn't seem to exist anymore. Looks like I'm going to have to use disklabel to label each disk and hotplug to mount them. The backup script will have to check the mount point to make sure the disk is mounted and unmount it after the backup is finished. In other words, the script I posted earlier is useless folks.. My problem now is to figure out how to get our people to work with this. Preparing a new USB disk is not going to be easy for them. I'm probably going to have to write a web interface for it sigh. Thanks for the help everyone! ciao dave --- Dave Edwards
Re: : Which remvable drive is connected to which USB port
-Original Message- From: Otto Moerbeek [mailto:[EMAIL PROTECTED] Sent: Friday, 12 October 2007 5:53 PM To: Raimo Niskanen Cc: Edwards, David (JTS); misc@openbsd.org Subject: Re: : Which remvable drive is connected to which USB port On Fri, 12 Oct 2007, Raimo Niskanen wrote: [snip] 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 agree that's my problem in a nutshell. 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. Thanks for the idea but unfortunately it doesn't help. Take three USB disks, plug them in and then tell me how to put the right label on the right physical disk? It would work of course if our restore procedure went: for each backup disk available Plug in the disk and check the lable to see if it's the right one if it is the right one Restore from the disk end fi end I suspect this would get a bit tedious.. ciao dave --- Dave Edwards
Re: : Which remvable drive is connected to which USB port
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. ciao dave --- Dave Edwards -- / Raimo Niskanen, Erlang/OTP, Ericsson AB
Re: : Which remvable drive is connected to which USB port
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
Re: : : Which remvable drive is connected to which USB port
On Fri, 12 Oct 2007, Raimo Niskanen wrote: On Fri, Oct 12, 2007 at 10:23:16AM +0200, Otto Moerbeek wrote: 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. Great proposal! I may be blind, but can not find an editable name field. Which is it? And how can I edit it? use the e command in disklabel interactive editor (started with disklabel -E). -Otto
Re: : : Which remvable drive is connected to which USB port
On Fri, Oct 12, 2007 at 10:23:16AM +0200, Otto Moerbeek wrote: 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. Great proposal! I may be blind, but can not find an editable name field. Which is it? And how can I edit it? -Otto -- / Raimo Niskanen, Erlang/OTP, Ericsson AB
Re: : : Which remvable drive is connected to which USB port
On 2007/10/12 11:47, Raimo Niskanen wrote: Use the disklabel: it has a disk name field that can be edited. Great proposal! I may be blind, but can not find an editable name field. Which is it? And how can I edit it? Label - you can edit it with disklabel -e.
Re: : : Which remvable drive is connected to which USB port
On 10/12/07, Stuart Henderson [EMAIL PROTECTED] wrote: On 2007/10/12 11:47, Raimo Niskanen wrote: Use the disklabel: it has a disk name field that can be edited. Great proposal! I may be blind, but can not find an editable name field. Which is it? And how can I edit it? Label - you can edit it with disklabel -e. But I thought the problem was that he wants the first USB cable to always be the first USB backup--with constant churn of USB keys (so that there are many). Each key is only used once. How does editing the disklabel help in that case? -Nick
Re: Which remvable drive is connected to which USB port
On 10/11/07, Edwards, David (JTS) [EMAIL PROTECTED] wrote: 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#). 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? disklabel will also tell you the label for a disk, which you could use to determine the port.
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. - Disk naming seems to be consistent after you first plug the device in. So: The first disk plugged into a port (say addr 2) gets sd1 (if your SATA disk is sd0) The second disk plugged into another port (say addr 3) gets sd2, etc If you unplug the first and the second and then plug the second in again first (to the same port of course addr 3 :-) it still seems to get sd2. But I doubt you can rely on this. Also at boot time, it's unclear which disk device will be allocated to which physical port. 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? -Nick
Re: Which remvable drive is connected to which USB port
-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? ciao dave --- Dave Edwards