Monday, May 26, 2008

My Most Used Command!

I have a bunch of 2.5" HDD's that I used to 'ferry' data back an forth between my laptop and various computers. I have not taken the time to setup a file share on my Windows box and like most people I have a wife, who would devorce me if I started spending all our disposable income on FIle Servers, Web Servers, Firewalls, a DVR and a T1 line... trust me I've asked!

Anyway, a while ago I noticed that my laptop would not mount one of my HDD's after I unplugged it from my windows box. This drove me crazy for hours... I could not find any easy way to mount the drive and all the suggestions I did find online were fstab hacks.

Basically when you unplug a drive from windows, it locks the drive or marks the drive as inuse. (To get around this, you need to open the small green arrow hardware icon and then stop the drive and then unplug the device). So when ubuntu tries to mount this drive it sees it as being locked or in use and you get an error like so:


In order to get this drive to mount you must do the following. First create a directory in the /media directory (I called mine 'usb')

sudo mkdir /media/usb

Now you can 'force mount' the drive using the option flag and force command

sudo mount /dev/sdb1 /media/usb -o force

You will need to change the device name, mine is usually sdb1. Once you are done, you will need to unmount the drive. Now since we did this via the command line, you will need to issue the following command to unmount the drive via the command line as well.

sudo umount /dev/sdb1

That's it! I use these commands on a daily basis, I guess I'm a creature of habit and dont' really want to take the time to find an automated way to do this. Ussually if I can remember or I'm not in a hurry I'll eject the drive from windows first. Good Luck!

No comments: