Force USB Device Discovery in Ubuntu

January 19, 2009 by
Filed under: bash, gnome, HowTo, linux, Ubuntu 

I previously did a post on how to Create a Button to Restart USB in Ubuntu. The purpose of that procedure was to get the USB hub in my HP w2207 monitor to recognize a flash drive that had been inserted into one of the ports.

Well I've found a better way to force this recognition that doesn't require root permission. It turns out that issuing the lsusb command polls all of the USB devices and causes my flash drive to be recognized and automounted. You can try this in a terminal with:

lsusb

Again, it's nice to have a launcher icon for this procedure to make things easier for my wife. At first I thought I could simply create a launcher that used lsusb >/dev/null, but for an unknown reason, it doesn't work. I was able to write a script that worked though, and calling my script from a launcher works to mount the USB drive.

I saved the following script as /home/userid/bin/read_usb

Affiliate Link
#!/bin/bash## Script *read_usb*. Place file in ~/bin. Make sure to make
# executable with "chmod +x read_usb".
# For desktop launcher, use command "/home/user/bin/read_usb".

lsusb >/dev/null

exit 0

Make sure to make the script executable with

chmod +x /home/userid/bin/read_usb

Now that we have an executable script, we can make a desktop launcher for it. Right click on the desktop and select Create Launcher. In the Name field enter Read USB. In the Command field enter /home/userid/bin/read_usb. If you like, click the springboard icon to select a different icon for your launcher. I used /usr/share/icons/crystalsvg/48x48/apps/usb.png. Now click OK in the Create Launcher window and you're done.

If you prefer to make a panel launcher instead, just start the same procedure by right clicking on the panel and selecting Add to Panel. Then select Custom Application Launcher and click Add. The rest of the procedure should be the same from there.

Comments

One Response to “Force USB Device Discovery in Ubuntu”

  1. 1blog says:

    huh, my usb flash doesn't get recognised even by issuing "lsusb"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>