Finding out names of mountable devices

Brian Fundakowski Feldman green at freebsd.org
Thu May 12 15:32:06 GMT 2005


On Thu, May 12, 2005 at 04:54:40PM +0300, Juho Vuori wrote:
> Tried on freebsd-questions without an answer. I suppose this is not 
> doable, but I'll ask here anyway.
> 
> If I plug in e.g. a USB thumb drive, which becomes, say, umass0. 
> Normally something like /dev/da0 will also be created and slices of that 
> device may be mounted. But is there a API for finding out what is the 
> corresponding block device for umass devices? The device driver writes 
> that to syslog, but reading logs for something like that is quite clumsy. 

One easy way is to look for changes in the GEOM topology:

green# sysctl -b kern.geom.conftxt
0 DISK cd0 4627595264 2048 hd 0 sc 0
0 DISK ad0 164696555520 512 hd 16 sc 63
1 MBR ad0s1 164694749184 512 i 0 o 32256 ty 165
2 BSD ad0s1g 141340864512 512 i 6 o 23353884672 ty 7
2 BSD ad0s1f 21474836480 512 i 5 o 1879048192 ty 7
2 BSD ad0s1e 268435456 512 i 4 o 1610612736 ty 7
2 BSD ad0s1d 268435456 512 i 3 o 1342177280 ty 7
2 BSD ad0s1c 164694749184 512 i 2 o 0 ty 0
2 BSD ad0s1b 1073741824 512 i 1 o 0 ty 1
2 BSD ad0s1a 268435456 512 i 0 o 1073741824 ty 7

-- 
Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
  <> green at FreeBSD.org                               \  The Power to Serve! \
 Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\


More information about the freebsd-hackers mailing list