Discussion:
[9fans] usb flash drive with ext2
(too old to reply)
Rudolf Sykora
2012-01-11 09:45:23 UTC
Permalink
Hello,

I have a usb flash drive.

[ When plugged into my linux, /var/log/messages gives:

Jan 11 10:28:14 redstar kernel: [ 388.588091] usb 1-3: new high speed
USB device using ehci_hcd and address 3
Jan 11 10:28:14 redstar kernel: [ 388.743813] usb 1-3: New USB device
found, idVendor=058f, idProduct=6387
Jan 11 10:28:14 redstar kernel: [ 388.743826] usb 1-3: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Jan 11 10:28:14 redstar kernel: [ 388.743837] usb 1-3: Product: Mass Storage
Jan 11 10:28:14 redstar kernel: [ 388.743844] usb 1-3: Manufacturer: Generic
Jan 11 10:28:14 redstar kernel: [ 388.743851] usb 1-3: SerialNumber: ABC01089
Jan 11 10:28:14 redstar kernel: [ 388.746708] scsi4 : usb-storage 1-3:1.0
Jan 11 10:28:15 redstar kernel: [ 389.749192] scsi 4:0:0:0:
Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 2
Jan 11 10:28:15 redstar kernel: [ 389.753494] sd 4:0:0:0: Attached
scsi generic sg2 type 0
Jan 11 10:28:15 redstar kernel: [ 389.754612] sd 4:0:0:0: [sdb]
8007680 512-byte logical blocks: (4.09 GB/3.81 GiB)
Jan 11 10:28:15 redstar kernel: [ 389.755405] sd 4:0:0:0: [sdb] Write
Protect is off
Jan 11 10:28:15 redstar kernel: [ 390.388661] sdb: unknown partition table
Jan 11 10:28:15 redstar kernel: [ 390.391887] sd 4:0:0:0: [sdb]
Attached SCSI removable disk
]

It has an ext2 filesystem on itself and can be, in linux, mounted:
mount /dev/sdb mnt
without errors, and works.

What should I do to be able to work with the drive (read/write) in plan9?
(When I plug it into my plan9 machine, I don't see any entry like
/dev/sdUXX, I see 3 entries under /dev/usb/, ep4.0, ep4.1 and ep4.2,
which appear/disappear as I plug/unplug the device. Running usb/disk
claims sth. like 'there is no disk unhandled').

Thank you for suggestions!
Ruda
Rudolf Sykora
2012-01-11 10:15:56 UTC
Permalink
It appears you have no partition table and an ext2 fs occupying
the whole device.  This should be OK.
Yes, I think the ext2 is really occupying the whole device. This is in
accord with what linux has said.
Try 'mount -a /srv/usb /dev' and see if /dev/sdUx.y appears.
I will when I back home.
If yes, try 'ext2srv -f /dev/sdUx.y/data && mount /srv/ext2 /n/linux'
       enabled control rw speed high maxpkt 64 pollival 0 samplesz 0 hz 0 hub 5 port 6 busy
       storage csp 0x500608 vid 0x058f did 0x6387 Generic 'Mass Storage' ehci
where "storage" means it's been recognised as a mass storage device,
and "busy" means it's already being handled by the usb/disk driver.
This I tried yesterday (cat /dev/usb/ep4.0/ctl), and I saw both 'busy'
and 'storage'.

So perhaps 'mount -a /srv/usb /dev' will help.
Thanks!
Ruda
Richard Miller
2012-01-11 10:06:06 UTC
Permalink
This post might be inappropriate. Click to display it.
Rudolf Sykora
2012-01-12 09:44:27 UTC
Permalink
This post might be inappropriate. Click to display it.
Richard Miller
2012-01-12 10:07:05 UTC
Permalink
Post by Rudolf Sykora
3) 'ext2srv -f /dev/sdU0.0/data && mount /srv/ext2 /n/linux' goes smoothly.
However.
; cd /n/linux
; lc
ls: .: I/O error
Any more help?
Try invoking ext2srv with '-v' to get more diagnostics.
Try 'dd -if /dev/sdU0.0/data -of /dev/null' to see if usb driver
is having trouble reading the device.
Rudolf Sykora
2012-01-12 10:21:30 UTC
Permalink
Post by Richard Miller
Post by Rudolf Sykora
3) 'ext2srv -f /dev/sdU0.0/data && mount /srv/ext2 /n/linux' goes smoothly.
However.
; cd /n/linux
; lc
ls: .: I/O error
Any more help?
Try invoking ext2srv with '-v' to get more diagnostics.
ext2srv 220: serving ext2
destroy(fid=302)
attach(fid=302,uname="ruda",aname="",afid="-1")...alloc
"/dev/sdU0.0/data", dev=3...good super block...OK
Post by Richard Miller
Try 'dd -if /dev/sdU0.0/data -of /dev/null' to see if usb driver
is having trouble reading the device.
0+1 records in
0+1 records out

The last bit is strange, isn't it?
Ruda
Richard Miller
2012-01-12 10:26:24 UTC
Permalink
Post by Rudolf Sykora
Post by Richard Miller
Try 'dd -if /dev/sdU0.0/data -of /dev/null' to see if usb driver
is having trouble reading the device.
0+1 records in
0+1 records out
The last bit is strange, isn't it?
Try 'cat /dev/sdU0.0/ctl' to see if usb/disk has got the
geometry wrong.
Rudolf Sykora
2012-01-12 10:40:43 UTC
Permalink
Post by Richard Miller
Post by Rudolf Sykora
Post by Richard Miller
Try 'dd -if /dev/sdU0.0/data -of /dev/null' to see if usb driver
is having trouble reading the device.
0+1 records in
0+1 records out
The last bit is strange, isn't it?
Try 'cat /dev/sdU0.0/ctl' to see if usb/disk has got the
geometry wrong.
/dev/usb/ep4.0 lun 0: inquiry Generic Flash Disk 8.07 geometry 8007680 512

linux' fdisk says:

Command (m for help): p

Disk /dev/sdb: 4099 MB, 4099932160 bytes
127 heads, 62 sectors/track, 1016 cylinders, total 8007680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xde308271

Device Boot Start End Blocks Id System

Command (m for help):

... so I'd think this is ok ...

Ruda
Francisco J Ballesteros
2012-01-12 11:30:55 UTC
Permalink
you can enable debug diagnostics for devices by using the usbd ctl file.
I don´t remember which ones are the strings (see the man, probably) but
I remember you can enable debug flags without restarting it.

You could try to locate them and enable debug for that, plug the disk
again, disable
debug for that.

IIRC, that is.
/dev/usb/ep4.0 lun 0: inquiry Generic Flash Disk      8.07 geometry 8007680 512
... so I'd think this is ok ...
My next step would be to get more diagnostic output from usb/disk.
This is no longer easy with the new monolithic usb driver
architecture.  You can't just start 'usb/disk -d' because the usb/disk
embedded into usb/usbd will have started automatically and seized
control of the device when you plugged it in.
I think you will need to generate a new usbd with the disk driver
configured out (see /sys/src/cmd/usb/usbd/usbdb), then kill the usbd
which is embedded into the kernel and start your new one, before
running usb/disk.
Richard Miller
2012-01-12 12:05:03 UTC
Permalink
Post by Francisco J Ballesteros
you can enable debug diagnostics for devices by using the usbd ctl file.
Sorry, I wasn't aware of that. usbd(4) does describe setting
environment variables in plan9.ini to change the arguments for usb
drivers (I wasn't aware of that either), but doesn't mention that you
can also do it dynamically via usbdctl. For example

echo diskargs -d >/dev/usbdctl

before plugging in the device (or -dd, -ddd etc for more verbosity).
You may need to study the source of usb/disk to make sense of the
output.

Richard Miller
2012-01-12 11:25:56 UTC
Permalink
Post by Rudolf Sykora
/dev/usb/ep4.0 lun 0: inquiry Generic Flash Disk 8.07 geometry 8007680 512
... so I'd think this is ok ...
My next step would be to get more diagnostic output from usb/disk.
This is no longer easy with the new monolithic usb driver
architecture. You can't just start 'usb/disk -d' because the usb/disk
embedded into usb/usbd will have started automatically and seized
control of the device when you plugged it in.

I think you will need to generate a new usbd with the disk driver
configured out (see /sys/src/cmd/usb/usbd/usbdb), then kill the usbd
which is embedded into the kernel and start your new one, before
running usb/disk.
Continue reading on narkive:
Loading...