Terminus
(usa Debian)
Enviado em 20/03/2011 - 00:20h
Estou usando o Debian Squeeze 6 KDE (stable, versão em CD) e adquiri um modem 3G Huawei E156B, o qual tem uma entrada para leitura de cartões MicroSD.
O problema é o seguinte: todos os dispositivos como CD, DVD, pendrives, etc., são "visíveis" para o notificador do dispositivo, menos o MicroSD (de 2GB) inserido dentro do modem. Fui informado que tal façanha é possível criando regras no udev (/etc/udev/rules.d/10-local.rules).
Comandos que já executei (todos como root):
# fdisk -l
Disk /dev/sda: 20.1 GB, 20060135424 bytes
255 heads, 63 sectors/track, 2438 cylinders
Units = cilindros of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcd05cd05
Dispositivo Boot Start End Blocks Id System
/dev/sda1 * 129 2439 18553856 83 Linux
/dev/sda2 1 129 1034241 5 Estendida
Partition 2 does not end on cylinder boundary.
/dev/sda5 1 129 1034240 82 Linux swap / Solaris
Partições lógicas fora da ordem do disco
Disk /dev/sdb: 1973 MB, 1973420032 bytes
60 heads, 59 sectors/track, 1088 cylinders
Units = cilindros of 3540 * 512 = 1812480 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Dispositivo Boot Start End Blocks Id System
/dev/sdb1 * 1 1089 1927100+ 6 FAT16
O MicroSD é /dev/sdb1.
# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
# lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0c45:612e Microdia PC Camera (SN9C110)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
# blkid
/dev/sda1: UUID="9ac12f30-a762-462a-8af4-d14c54abc8ec" TYPE="ext3"
/dev/sda5: UUID="b333d059-e25c-42d9-a6e9-712c80576d0d" TYPE="swap"
/dev/sdb1: SEC_TYPE="msdos" LABEL="PENCLARO" UUID="34F9-8922" TYPE="vfat"
Vamos agora coletar algumas informações para criar uma regra no udev:
# udevadm info -a -p $(udevadm info -q path -n /dev/sdb1)
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3/host26/target26:0:0/26:0:0:0/block/sdb/sdb1':
KERNEL=="sdb1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{partition}=="1"
ATTR{start}=="135"
ATTR{size}=="3854201"
ATTR{alignment_offset}=="0"
ATTR{stat}==" 42 207 361 284 0 0 0 0 0 284 284"
ATTR{inflight}==" 0 0"
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3/host26/target26:0:0/26:0:0:0/block/sdb':
KERNELS=="sdb"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{range}=="16"
ATTRS{ext_range}=="256"
ATTRS{removable}=="1"
ATTRS{ro}=="0"
ATTRS{size}=="3854336"
ATTRS{alignment_offset}=="0"
ATTRS{capability}=="53"
ATTRS{stat}==" 54 207 457 348 0 0 0 0 0 348 348"
ATTRS{inflight}==" 0 0"
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3/host26/target26:0:0/26:0:0:0':
KERNELS=="26:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="3"
ATTRS{vendor}=="HUAWEI "
ATTRS{model}=="MMC Storage "
ATTRS{rev}=="2.31"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0x5d"
ATTRS{iodone_cnt}=="0x5d"
ATTRS{ioerr_cnt}=="0x0"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"
ATTRS{max_sectors}=="240"
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3/host26/target26:0:0':
KERNELS=="target26:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3/host26':
KERNELS=="host26"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6/1-6:1.3':
KERNELS=="1-6:1.3"
SUBSYSTEMS=="usb"
DRIVERS=="usb-storage"
ATTRS{bInterfaceNumber}=="03"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bNumEndpoints}=="02"
ATTRS{bInterfaceClass}=="08"
ATTRS{bInterfaceSubClass}=="06"
ATTRS{bInterfaceProtocol}=="50"
ATTRS{modalias}=="usb:v12D1p1003d0000dc00dsc00dp00ic08isc06ip50"
ATTRS{supports_autosuspend}=="0"
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-6':
KERNELS=="1-6"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}=="Qualcomm Configuration"
ATTRS{bNumInterfaces}==" 4"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bMaxPower}=="500mA"
ATTRS{urbnum}=="4172"
ATTRS{idVendor}=="12d1"
ATTRS{idProduct}=="1003"
ATTRS{bcdDevice}=="0000"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="480"
ATTRS{busnum}=="1"
ATTRS{devnum}=="12"
ATTRS{version}==" 2.00"
ATTRS{maxchild}=="0"
ATTRS{quirks}=="0x0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="HUAWEI Technology"
ATTRS{product}=="HUAWEI Mobile"
looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bMaxPower}==" 0mA"
ATTRS{urbnum}=="256"
ATTRS{idVendor}=="1d6b"
ATTRS{idProduct}=="0002"
ATTRS{bcdDevice}=="0206"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="480"
ATTRS{busnum}=="1"
ATTRS{devnum}=="1"
ATTRS{version}==" 2.00"
ATTRS{maxchild}=="6"
ATTRS{quirks}=="0x0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Linux 2.6.32-5-686 ehci_hcd"
ATTRS{product}=="EHCI Host Controller"
ATTRS{serial}=="0000:00:03.3"
ATTRS{authorized_default}=="1"
looking at parent device '/devices/pci0000:00/0000:00:03.3':
KERNELS=="0000:00:03.3"
SUBSYSTEMS=="pci"
DRIVERS=="ehci_hcd"
ATTRS{vendor}=="0x1039"
ATTRS{device}=="0x7002"
ATTRS{subsystem_vendor}=="0x1043"
ATTRS{subsystem_device}=="0x8087"
ATTRS{class}=="0x0c0320"
ATTRS{irq}=="23"
ATTRS{local_cpus}=="ffffffff"
ATTRS{local_cpulist}=="0-31"
ATTRS{modalias}=="pci:v00001039d00007002sv00001043sd00008087bc0Csc03i20"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""
ATTRS{companion}==""
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
# tail -f /var/log/messages
Mar 20 00:37:56 debian kernel: [ 4320.632021] usb 1-5: new high speed USB device using ehci_hcd and address 8
Mar 20 00:37:56 debian kernel: [ 4320.775205] usb 1-5: New USB device found, idVendor=12d1, idProduct=1003
Mar 20 00:37:56 debian kernel: [ 4320.775211] usb 1-5: New USB device strings: Mfr=3, Product=2, SerialNumber=0
Mar 20 00:37:56 debian kernel: [ 4320.775216] usb 1-5: Product: HUAWEI Mobile
Mar 20 00:37:56 debian kernel: [ 4320.775219] usb 1-5: Manufacturer: HUAWEI Technology
Mar 20 00:37:56 debian kernel: [ 4320.775375] usb 1-5: configuration #1 chosen from 1 choice
Mar 20 00:37:56 debian kernel: [ 4320.779342] scsi12 : SCSI emulation for USB Mass Storage devices
Mar 20 00:37:56 debian kernel: [ 4320.780623] usb 1-5: USB disconnect, address 8
Mar 20 00:38:04 debian kernel: [ 4329.336039] usb 1-5: new high speed USB device using ehci_hcd and address 9
Mar 20 00:38:05 debian kernel: [ 4329.479210] usb 1-5: New USB device found, idVendor=12d1, idProduct=1003
Mar 20 00:38:05 debian kernel: [ 4329.479216] usb 1-5: New USB device strings: Mfr=3, Product=2, SerialNumber=0
Mar 20 00:38:05 debian kernel: [ 4329.479220] usb 1-5: Product: HUAWEI Mobile
Mar 20 00:38:05 debian kernel: [ 4329.479224] usb 1-5: Manufacturer: HUAWEI Technology
Mar 20 00:38:05 debian kernel: [ 4329.479382] usb 1-5: configuration #1 chosen from 1 choice
Mar 20 00:38:05 debian kernel: [ 4329.485951] option 1-5:1.0: GSM modem (1-port) converter detected
Mar 20 00:38:05 debian kernel: [ 4329.486154] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
Mar 20 00:38:05 debian kernel: [ 4329.486471] option 1-5:1.1: GSM modem (1-port) converter detected
Mar 20 00:38:05 debian kernel: [ 4329.486574] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
Mar 20 00:38:05 debian kernel: [ 4329.487233] scsi15 : SCSI emulation for USB Mass Storage devices
Mar 20 00:38:05 debian kernel: [ 4329.488640] scsi16 : SCSI emulation for USB Mass Storage devices
Mar 20 00:38:10 debian kernel: [ 4334.489935] scsi 15:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
Mar 20 00:38:10 debian kernel: [ 4334.519438] sr1: scsi-1 drive
Mar 20 00:38:10 debian kernel: [ 4334.519752] sr 15:0:0:0: Attached scsi generic sg2 type 5
Mar 20 00:38:10 debian kernel: [ 4334.524103] scsi 16:0:0:0: Direct-Access HUAWEI MMC Storage 2.31 PQ: 0 ANSI: 2
Mar 20 00:38:10 debian kernel: [ 4334.526108] sd 16:0:0:0: Attached scsi generic sg3 type 0
Mar 20 00:38:10 debian kernel: [ 4334.543418] sd 16:0:0:0: [sdb] 3854336 512-byte logical blocks: (1.97 GB/1.83 GiB)
Mar 20 00:38:10 debian kernel: [ 4334.546150] sd 16:0:0:0: [sdb] Write Protect is off
Mar 20 00:38:10 debian kernel: [ 4334.558220] sdb: sdb1
Mar 20 00:38:10 debian kernel: [ 4334.576111] sd 16:0:0:0: [sdb] Attached SCSI removable disk
Tentei me basear num tutorial em inglês sobre leitores de cartões SD, criei a seguinte regra (a qual não deu certo por razões, para mim, desconhecidas).
KERNEL=="sd?1", SUBSYSTEMS=="block", ATTRS{model}=="MMC Storage ", SYMLINK+="sdb%n", OPTIONS+="all_partitions"
# udevadm test /dev/sdb1
run_command: calling: test
udevadm_test: version 164
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
parse_file: reading '/etc/udev/rules.d/10-local.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-usb_modeswitch.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-udev-default.rules' as rules file
parse_file: reading '/lib/udev/rules.d/55-dm.rules' as rules file
add_rule: NAME="" is ignored, because udev will not delete any device nodes, please remove it from /lib/udev/rules.d/55-dm.rules:57
parse_file: reading '/lib/udev/rules.d/60-fuse-utils.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-gnupg.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-alsa.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-input.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-serial.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-dm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-tape.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-v4l.rules' as rules file
parse_file: reading '/dev/.udev/rules.d/61-dev-root-link.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-mobile-action.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-xorg-xkb.rules' as rules file
parse_file: reading '/lib/udev/rules.d/69-xserver-xorg-input-wacom.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-acl.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-hid2hci.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-cd-aliases-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-net-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-persistent-net-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-probe_mtd.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-tty-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-ericsson-mbm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-longcheer-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-simtech-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-usb-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-zte-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-nm-olpc-mesh.rules' as rules file
parse_file: reading '/lib/udev/rules.d/78-sound-card.rules' as rules file
parse_file: reading '/lib/udev/rules.d/79-fstab_import.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-alsa.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-drivers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-udisks.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-hwclock.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-hal.rules' as rules file
parse_file: reading '/lib/udev/rules.d/91-permissions.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keyboard-force-release.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keymap.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-udev-late.rules' as rules file
parse_file: reading '/etc/udev/rules.d/z60_hdparm.rules' as rules file
udev_rules_new: rules use 50520 bytes tokens (4210 * 12 bytes), 21826 bytes buffer
udev_rules_new: temporary index used 27040 bytes (1352 * 20 bytes)
unable to open device '/sys/dev/sdb1'
É de meu conhecimento que editar o /etc/fstab apropriadamente funciona, mas ter que digitar a senha toda vez que for montar o dispositivo ou reiniciar o PC (e outros meios gambiarrentos) é meio desconfortável. Prefiro montar pelo Device Notifier/Notificador de dispositivos mesmo. :)