Re: Re: scsi device names, symbolic names, devfs/sysfs

Tony Godshall <[email protected]> Sat, 23 Aug 2003 14:49:13 -0500
Newsgroups gmane.linux.hardware.sony
Message-ID <20030823194912.GA11386@sanity>
According to Frank Edwards,
> On Fri, 22 Aug 2003 [email protected] wrote:
> > From: Thomas Jakobi <[email protected]>
> >
> > hi,
> 
> Hi, fake.  (Say, is that your real name? <grin>)
> 
> > On Thu, Aug 21, 2003 at 10:29:50PM -0400, Frank Edwards wrote:
> > > Unfortunately, this means that your device names can change depending on
> > > what's hooked up to the box.  I never understood why partition names
> > > aren't assigned to logical devices.  For example, on my circa 1986 Amiga
> > > each partition was assigned a label by the OS (such as "Work:") and the
> > > user could assign their own name as well (such as "Backup:").  Even if
> > > drives were re-ordered on the scsi bus, they kept their user-assigned
> > > names the same and if the user only used those names, they were isolated
> > > from configuration changes on the machine.
> >
> > in devfs: /dev/scsi/hostX/busX/targetX/lunX/{disc|cd|generic|partX}
> > same for ide, just replace scsi with ide ;)
> >
> > i can't understand why so few people use devfs, it solves not only this,
> > but a whole other heap of 'flaws' of the old /dev-system.....
> 
> Devfs doesn't help.  What if the lun# changes?  Then the name of the
> drive changes.  Or what if the target id should change?
> 
> No, the user should be given a way of autonomously naming their storage
> devices.  For example, imagine naming your floppies:  Quicken1,
> Quicken2, ScratchDisk, and so on.  Whenever you insert a floppy into the
> drive, it automounts it and allows one to use the name "Quicken1:" to
> access that drive.

Why not make yourself a little script that uses /proc to
build yourself some symlinks?  (Just poking around: IANAE)

If the size of the device is enough, you can use this:

zeno:~# cat /proc/partitions 
major minor  #blocks  name

   8     0    4444462 sda
   8     1    3903763 sda1
   8     2          1 sda2
   8     5     538146 sda5
   8    16   19535040 sdb
   8    17   19535008 sdb1
  34    64   33027624 hdh
  34    65   33027246 hdh1
  33     0   29316672 hde
  33     1   28322563 hde1
  33     2          1 hde2
  33     5     987966 hde5

If you need more to identify the device, /proc/scsi/*/1 
would seem to identify the device at sda:

zeno:~# head -n 2 /proc/scsi/*/0
Adaptec AIC7xxx driver version: 6.2.8
aic7890/91: Ultra2 Wide Channel A, SCSI Id=7, 32/253 SCBs

It looks easier with IDE:

sanity:/etc# cat /proc/ide/ide0/hda/model     
TOSHIBA MK6021GAS
sanity:/etc# cat /proc/scsi/usb-storage/1 
   Host scsi1: usb-storage
...