Mounting an external USB Harddrive

In Fedora Core 4 (and earlier Cores) when the user is in Gnome or KDE, the HAL daemon will automatically recognize when a USB drive is attached to the computer. It will then create an fstab entry and all will be good in the world. I’m not sure if this happens in Debian, but I’m using Debian as a print/file server so I don’t have any GUIs installed. So I will go over my learning process for others who may be having the same difficulties.

On of the first commands you learn when you first enter the Linux world is dmesg. This command is essential to master in order to get help in the forums or IRC chatrooms. When you type it, you are given all of the system messages. These are important when plugging in new devices in order to debug them. First I type dmesg before plugging anything in to see what it currently says. This can be very important because if it looks exactly the same after plugging in the device, it means that Linux didn’t detect it. The second time I type dmesg, I get:

a bunch of stuff followed by –

drivers/usb/class/usblp.c: usblp0: out of paper
drivers/usb/class/usblp.c: usblp0: ok
usb 4-1: new high speed USB device using address 4
scsi2 : SCSI emulation for USB Mass Storage devices
Vendor: MAXTOR 6 Model: L040J2 Rev: AR1.
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sdb: 78177792 512-byte hdwr sectors (40027 MB)
sdb: assuming drive cache: write through
/dev/scsi/host2/bus0/target0/lun0: p1
Attached scsi disk sdb at scsi2, channel 0, id 0, lun 0
USB Mass Storage device found at 4
First of all, you will notice the message from before, that my printer had run out of paper. I left it in as an example of things you can find in dmesg. As you can see, it has not only detected the hard drive, but correctly identified it as a Maxtor. Looks like I have 40 GB on this drive. The most important detail for us to glean out of this is that it has been assigned to device sdb. This means usb device b. What was a? Probably the printer. Now we know that important info, so what’s next?

First we need to go root. (This is always represented by # instead of $ for good tutorial writers)

e@printman-eevet:~$ su –

Now need to mount the sucker and tell the computer where to mount it. If we just wanted to mount it this once, it would be a command like:

mount -t vfat /dev/sdb1 /mnt/your_mount_point

But we want to load up and be mountable by anyone so we will edit the /etc/fstab file.

# vi /etc/fstab

# /etc/fstab: static file system information.
# proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 none swap sw 0 0
/dev/hdc /media/cdrom0 iso9660 ro,user,noauto 0 0
/dev/hdd /media/cdrom1 iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
/dev/sdb1 /media/external vfat rw,user 0 0
The bottom is the part I added. So I decided to mount!

e@printman-eevet:~$ mount /dev/sdb1
mount: mount point /media/external does not exist
What’s this? I guess you can’t just make up a directory, it has to already exist. So I’ll make that directory and see what happens. Success! (BTW – I had to be root to make that directory!)

e@printman-eevet:/media$ mount /dev/sdb1
e@printman-eevet:/media$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 6.6G 494M 5.8G 8% /
tmpfs 62M 0 62M 0% /dev/shm
/dev/sdb1 38G 530M 37G 2% /media/external

So there it is! The quick and EZ way to mount a USB hard drive. Now that wasn’t as hard as it sounds, was it? My next task is to make it so that this hard drive, partitioned in Windows FAT32, accessible to all of my computers (Windows and Linux alike) for saving.