2010-12-18

Mount removable drives from command line

This is too simple, but it took me a while to find this type of solution, so I want to post it here to keep track of it, next time I need it:

I have an Ubuntu (10.x) with a couple of users. Some need to use the GUI (Gnome or XFCE) to work, including accessing removable media. Other users need (or rather, wish) to use the CLI to access removable media. This means /etc/fstab may not have specific entries for removable media (say, /dev/sdg1) with the "user" option, because this would block Nautilus (Gnome) or Thunar (XFCE) from automatically mounting the removable media for the GUI users.

So I just found that there exists a mount wrapper called pmount. (to install in an Ubuntu system, simply sudo apt-get install pmount). The CLI user now has a few aliases in his .csh file to easily mount and umount several types of removable media:

alias flash 'pmount /dev/sdf1 photo_sd' (for SD cards)
alias cflash 'pmount /dev/sdc1 photo_cf' (for Compact Flash cards)
alias pen 'pmount /dev/sdg pen' (for flashdrives)
alias pen1 'pmount /dev/sdg1 pen1' (for the 1st partition in a flashdrive)

All of the above create mount points ( /media/photo_sd, /media/photo_cf, etc...).
To unmount each of them, I've set up aliases too:

alias flash-u 'pumount photo_sd'
alias cflash-u 'pumount photo_cf'
alias pen-u 'pumount pen'
alias pen1-u 'pumount pen1'

2010-03-31

Bluetooth crashes randomly in Ubuntu 9.10

I installed Linux Ubuntu 9.10 (Karmic Koala) in my Dell Mini 9 (Inspiron 910). Everything works fine, except for the bluetooth support. Occasionally, the bluetooth service apparently dies, and I don't know exactly why. When this happens, I cannot restart the bluetooth service simply with "service bluetooth restart"; even after doing that, the report resulting from "service bluetooth status" is "Bluetooth is *not* running". There are no logs that could give a clue as to what's going on. Since the bluetooth service is down, the bluetooth application (blueman) does not work either.

The bluetooth device in this Dell mini is a USB device identified as:
Bus 005 Device 004: ID 413c:02b0 Dell Computer Corp.
You can check your machine with this command: "lsusb -v |grep Bluetooth"

I figured that the hardware bluetooth device must be switched off (again, for some odd reason), and sure enough, that seemed to be the problem. So the solution I found is:

  1. Turn the hardware bluetooth device on
  2. Restart the bluetooth service
  3. Run my bluetooth application (blueman)
Step by step, this means:

1) Turn the hardware bluetooth device back on. The best way I found to do this is by using the "aircraft manager" application. You can install this with this set of commands:
sudo add-apt-repository ppa:opensource-subakutty/ppa
sudo apt-get update
sudo apt-get install aircraft-manager
Now you will have a nice command-line tool, /usr/bin/aircraft-manager-util
To use it:
/usr/bin/aircraft-manager-util BT on (to turn bluetooth on)
/usr/bin/aircraft-manager-util BT status (to check the status of the bluetooth hardware)

2) Once the device is turned on, restart the bluetooth service in Linux:
sudo service bluetooth restart

You can check that the service is indeed running:
sudo service bluetooth status

3) Restart your blueman applet:
killall blueman-applet
blueman-applet &

At this point, the bluetooth application should be fully operational again.

References:
http://www.ubuntumini.com/2009/12/aircraft-manager-turn-wifi-bluetooth.html
http://blueman-project.org/