Hooking up my Verbatim external hard drive

logo

Just today I bought a new Verbatim external hard drive for my Linux machine. It’s a nice, small 160GB USB 2.0 hard drive. Getting it set up on ArchLinux with autofs was super simple. When you access the drive, it automatically mounts, and unmounts after a couple seconds of no activity. It works great. Here’s how to do it.

Setting up udev

The first order of business is getting udev to recognize the device and assign it the same device file everytime. I wanted it to show up as /dev/verbatim. First of all, I needed to see how it’s identified by Linux. So I plugged in the device, ran dmesg, and determined the USB address:

scsi 6:0:0:0: Direct-Access     TOSHIBA  MK1637GSX             PQ: 0 ANSI: 2

Now I went into the sys filesystem to get the vendor and model information to help udev identify this device in the future. Using the USB address above — 6:0:0:0, I descended into the directory:

cd /sys/bus/scsi/devices/6:0:0:0
cat vendor
cat model

That gave me the values of “TOSHIBA” and “MK1637GSX”. Ok, so I could have gotten that from the dmesg output, but I wanted to make sure I was looking at the right fields.

Now I was ready to create my udev rule. I put the following in /etc/udev/rules.d/60-verbatim.rules:

BUS=="scsi", SYSFS{vendor}=="TOSHIBA", SYSFS{model}=="MK1637GSX", NAME="verbatim", GROUP="storage", MODE="0660"

Since my user wasn’t in the storage group I had to add him:

sudo gpasswd -a username storage

Alright! Now we have a stable device everytime we plug in the drive.

Setting up autofs

This part is simple. We just want the autofs daemon to pay attention every time the /dev/verbatim device shows up on the system, and handle auto-mounting and unmounting it as it is accessed.

I made sure the following line is in /etc/autofs/auto.master:

/media /etc/autofs/auto.media --timeout 2

Then I added the following line to /etc/autofs/auto.media (where 95 is the storage group id) to automount the device onto /media/verbatim:

verbatim -fstype=vfat,async,rw,gid=95,umask=002 :/dev/verbatim

Now, just restart the autofs daemon:

/etc/rc.d/autofs restart

All done!

That’s all it takes. Make sure the drive is unmounted, unplug it, plug it back in and take a look at your /media/verbatim directory. As you access it, you’ll see it’s automatically mounted (run mount). After a couple seconds of no activity, the drive will auto-unmount.

Was this helpful? Please let me know!


Related Posts

Tags:
Posted in solutions on April 11th, 2008 | No Comments »


sshfs: A simple Linux file-sharing solution

logo

What’s a quick, simple way to set up a file share between two Linux boxes? I looked into NFS shares, but that involves running extra daemons, and I don’t want to deal with the hassle of extra configuration files and daemons. I looked into SAMBA — OK, I didn’t; the thought grossed me out before I even gave it a chance.

Enter sshfs

According to the project website:

This is a filesystem client based on the SSH File Transfer Protocol. Since most SSH servers already support this protocol it is very easy to set up: i.e. on the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

» Read the rest of this entry


Related Posts

Tags:
Posted in solutions on January 24th, 2008 | No Comments »

Mounting a drive with Russian filenames

Today I wanted to mount a USB drive from Windows. But when I did and tried to ls the directory, all I got was “????” for the filenames, lots and lots of question marks. After some searching around, I found out that you have to provide a vfat drive with a character set to convert long filenames.

mount -t vfat -o iocharset=utf8 /dev/sdb1 /mnt/drive

According to the mount man page:

   iocharset=value
       Character set to use for converting between 8 bit characters and
       16 bit Unicode characters. The default is iso8859-1.  Long file-
       names are stored on disk in Unicode format.

Related Posts

Tags:
Posted in solutions on October 16th, 2007 | No Comments »