tying down adaX to physical interfaces

Bruce Evans brde at optusnet.com.au
Mon Mar 28 14:48:13 UTC 2011


On Sat, 26 Mar 2011, Kostik Belousov wrote:

> On Sun, Mar 27, 2011 at 12:24:03AM +1100, Bruce Evans wrote:
>> To hijack this thread a little, I'll ask how people handle removable media
>> changing the addresses of non-removable media.  I use the following to
>> prevent USB drives stealing da0 from my 1 real SCSI disk on 1 machine:
>>
>>    hint.scbus.0.at="sym0"
>>    hint.da.0.at="scbus0"
>>
>> This works OK and is easy to manage with only 1 SCSI disk.  But 1 of my
>> USB drives also steals cd0 from a not-so-real ATAPI drive under atapicam,
>> depending on whether the USB drive is present at boot time:
>>
>>    USB drive not present at boot time:
>>      ad* (no SCSI disks on this machine)
>>      cd0 = acd0 (but no further ATAPI drives on this machine)
>>    insert USB drive:
>>      da1 (da0 was reserved by above)
>>      cd1 (phantom ATAPI drive on the USB drive.  Accessing this hangs
>> 	  parts of the ata system but it doesn't get used since various
>> 	  places only point cd0)
>>
>>    USB drive present at boot time:
>>      ad*
>>      da1 on USB
>>      cd0 phantom on USB
>>      cd1 = acd[0 or 1] (normal cd0).  Accessing cd0 now hangs parts of the
>> 	   ata system and this happens too easily since various places point
>> 	   to cd0.
>>
>> How do people defend agains random USB drives present or not at boot time?
>
> Wouldn't it be cd0 on scbusX on ahciY, and cd1 on scbusZ on umass-simT ?
> I believe similar hints would wire the cd0/cd1 in your case.

That works of course.  I was hoping for something more automatic and
general.  Maybe reserve lots of bus numbers for fixed devices.

What seems to happen is that buses are allocated sequentially in probe
order, and at least in my configuration, USB drives are probed before
atapi drives, so the removable drives always renumber the fixed drives.
However, the order of the probe messages is the opposite -- atapi drives
before USB drives (with higher unit numbers for atapi drives!).  E.g.,
acd0, cd1 (same physical drive as acd0), cd0 (USB drive).  This is with
an older kernel and usb.

Bruce


More information about the freebsd-fs mailing list