2009/11/19

Ubuntu 9.10 and mobistar stick

So recently I changed from Windows XP to Ubuntu 9.10 on my work laptop. I was already using it on my home laptop which has a lot less of possible hardware/software requirements.

First of all, lets start with the good news. I have a Lenovo T61. Under xp it was performing badly so that is on of the reasons I decided to change to Ubuntu. Installation was a piece of cake. It went smooth, 6 answer setup and it installs. Hardware support was amazing except for my Mobistar usb stick...

When plugging it in I get this HUAWEI Mass Storage kind of message in my dmesg. Seems ok except that it is a composit device (more then one device on the same usb port). Ubuntu ofcourse recognize the wrong device (the mass storage device part). Luckily I found this guy on the internet who had the same problem:
http://blog.simple2web.ie/?p=363

So ok I tried it out and it works ! Great ! Well what was not so great is that I always have to run usb_modeswitch manually. This seems no biggy but it can get annoying if you need to plug in and plug out your device frequently. So here is my solution and my added value.

Ubuntu has something called udev. Udev is a service that dynamically detects devices and can run scripts when it sees certain devices. So I made my own script:
/usr/local/share/mobistar.sh
which has
#!/bin/bash
/usr/sbin/usb_modeswitch

Now that wasn't so hard was it. Now how can we make udev execute this script. First of all you need a rule script. I created :
/etc/udev/rules.d/10-mobistartusbswitch.rules
which contains
BUS=="usb", SYSFS{idProduct}=="12d1", SYSFS{idVendor}=="1001",
ACTION=="add", RUN+="/usr/local/share/mobistar.sh"

Doesn't seem to complicated except for the idproduct and idvendor numbers. I found these by executing lsusb. This gives something like :
Bus 001 Device 030: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem

After I created the rule, I restarted udev by doing
sudo service udev stop
sudo service udev start

That was it! Plugging and deplugging works as a charm now!

1 comment:

  1. Remember to make the mobistar.sh script executable by doing the following as well:
    sudo chmod +x /usr/local/share/mobistar.sh

    - Hasse

    ReplyDelete