5.12.08

Ubuntu tip: Name your USB Camera

OK, here is the situation:
I've got my camera which I connect to my ubuntu computer via USB. It automatically shows up on the desktop when I plug it in. However, it's kind of hard to find on my desktop (I have a cluttered desktop) because it shows up with the default ubuntu name "256mb volume" or some other non-descriptive title like that. This isn't ubuntu's fault, if doesn't have a better name for your camera device. A serial number would hardly be better - but still maybe confusing.

No matter, you can name your camera and have it show up as the name you want on your desktop.

The way to do this is by naming the filesystem used by your camera. Typically naming a linux type of filesystem such as ext3, ext2 one uses tune2fs which is a very handy command line program. The relevant commands would be something like tune2fs -l /dev/sda1 (change sda1 to the relevant name for your disk use the gnome-system-monitor to find it) to list the filesystem's information. Then you use tune2fs -L yourdiskLabel /dev/sda1 to change the label. Of course you need to be super user (sudo) if you want to mess with the filesystems and use tune2fs.

The hard part the camera usually isn't formatted in a linux/unix style filesystem. It is usually but something like vfat (a fat32 and fat16 compatable open source clone) which is to make the camera compatable with the common windows computer OS. You probably shouldn't try to reformat your camera because the software that resides on the computer might not like it. Even if the camera could work you will make the dumb windows computers you come across unable to read the camera (without updating windows first) which isn't ideal for a portable device.

Enter the solution: mtools
This program is avaliable in the main ubuntu repository
This will work for mp3 players, DOS floppy disks or anything else with a MS-DOS type of filesystem.

The difficulty using this program is that mtools doesn't read devices (such as your camera or hard disk) in the linux way but in the MS-DOS way. So you need to do some special things to get the program to know what you are telling it to rename.

So, in our example we'll use the gnome system monitor to find out want the linux device name for the camera is. This will be something like /dev/hda1. In this example let's say the camera is mounted as /dev/sde1

Now we have to make up a MS-DOS style drive letter for that. Let's say drive E: for simplicities sake (though it could be any letter you choose)

Here are the steps after you have installed mtools using synaptic
or apt-get install mtools

first you open a terminal and run mtools once so that it creates the default config file and to make sure it is there. Type:
mtools
then copy the default config file into your home user directory so that your new disklabel will be visable to you:
cp /etc/mtools.conf ~/.mtoolsrc
Now, edit mtools config file: (Or use any other text editor)
gedit ~/.mtoolsrc
Enter 2 lines at the end that just say
# # camera
drive e: file="/dev/sde1"

That was the hard part (configuring mtools) Almost done!
Now, you use the utility mlabel (a subset of mtools) to actually rename/relabel your MS-DOS device (camera)

First initialise the device in mlabel:
mlabel -s e:
Then finally, rename it!
mlabel e:yourdisklabel
All done!

Note that MSDOS disklabels are not case sensitive and usually just show up at all capital letters.

Now unplug and replugin your device and you should see it automatically showing up on the desktop with the new name you have set.