LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   how do I mount an external USB hard drive (https://www.linuxquestions.org/questions/linux-hardware-18/how-do-i-mount-an-external-usb-hard-drive-450518/)

hykhoshn 06-01-2006 07:11 AM

how do I mount an external USB hard drive
 
I am VERY new to linux. any hint is appreciated.
When I plug in an external USB hard drive in one of
the FRONT USB ports (both REAR ports used already used):

1- how do I make the system recognize it?
2- how do I mount this drive and what type of
filesystem is it.

SYS: Dell Poweredge 2800 running Red Hat Enterprise
Linus ES 3.

b0uncer 06-01-2006 10:14 AM

You can usually use "auto" as the filesystem type, so when you mount the drive the filesystem gets automatically detected (normally). If it does not get automatically mounted when you plug the cable in, then add the information about it into your /etc/fstab file; for this you'll need to know two things: 1) where you want it to be mounted (in which directory will you want to see it's contents) and 2) what is the device file (a special file in /dev directory) called. The 2nd question is most of the time the "harder" one, but you could try guessing: for usb hard drives it's usually (but not always) sda1, sda2, sda3, or something like it (second usb hard drive would be sdb1, sdb2, ..., in a normal situation).

First when you plug the cable in, open up a console and do

Code:

dmesg
and when it gets to the bottom, read the last 10 or so lines, for information if your drive was seen (you should see text that tells the name of the drive, some usb info etc., and some device name, like sda or sdb - this is the part we need). Now let's say you read the lines from dmesg and it said something about "sda" there. Let's also say you want the drive to be mounted in /mnt/usbdrive (change this to what you really want).

First, create the mount directory where the drive will show it's contents:

Code:

mkdir /mnt/usbdrive
second, get superuser rights if you're not logged in as root:

Code:

su
when asked for password, type in the root password (it won't show you any letters or *s or small circles or anything, so don't wait to see any while typing) and hit enter. Then, open up a text editor of your choise and /etc/fstab in it (gedit, nano, vim, joe, emacs, kwrite, what ever you like - launch it from the command line so it's opened with super user rights):

Code:

gedit /etc/fstab
go to the bottom and write a line like this:

Quote:

/dev/sda1 /mnt/usbdrive auto rw,users,auto,umask=0222 0 0
where sda1 is the device file (you might have to change it), /mnt/usbdrive is the mount place you created, first "auto" tells fstab you want it to detect the filesystem, the comma-separated list is a list of options (read-write, users can unmount it too, it gets automatically mounted at bootup, everyone can access it not just root), and the last two zeroes..well, you can read more about them issuing man fstab, just write them now.

After you've saved, simply try:

Code:

mount /mnt/usbdrive
and if you get no output, you're fine. Next bootup your drive is there automatically every time. BUT if you did get output, a line that tells you sda1 is not found or something, then something's wrong. Most of the time the problem is that the device file is wrong (this is why you read dmesg output to figure it out). Then open up /etc/fstab file again, change sda1 to sda2 or sda4 or whatever you think it should be. dmesg output is of great help finding this out.

Once you get this done, you don't have to worry about it again, it's there. Nowadays people have nice things like automounters so they don't have to do this even, but adding new drives to fstab is always a sure way.

EDIT: about the dev filenames. sda is normally assigned to an usb or scsi device, and the number (sda1, sda2, sda3 etc.) depends on the device, most of the time it's 1 for the first device, 2 for the second etc. Also, when dealing with harddisks, first disk should get sda, second sdb and so on. Like hda for a primary "normal" harddisk, hdb for a secondary "normal" harddisk etc. The two names I've seen most often are sda1 and sda4 (I can't tell why it's just sda4 and not sda2, for example, but that's what my devices have always been, or at least almost always - so sda1 and sda4 are good tries if you start guessing).


All times are GMT -5. The time now is 06:53 PM.