Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I read some resources about the mount command for mounting devices on Linux, but none of them is clear enough (at least for me).

On the whole this what most guides state:

$ mount
(lists all currently mounted devices)

$ mount -t type device directory
(mounts that device)

for example (to mount a USB drive):
$ mount -t vfat /dev/sdb1 /media/disk

What's not clear to me:

  • How do I know what to use for "device" as in $ mount -t type device directory? That is, how do I know that I should use "/dev/sdb1" in this command $ mount -t vfat /dev/sdb1 /media/disk to mount my USB drive?

  • what does the "-t" parameter define here? type?

I read the man page ($ man mount) a couple of times, but I am still probably missing something. Please clarify.

share|improve this question
    
If you'd really read the manual, you wouldn't ask such questions. –  rozcietrzewiacz Aug 17 '11 at 22:06
    
@rozcietrzewiacz I must admit that my mind didn't work properly. When @Let_Me_Be was referring to /dev/disk/by-id I thought "by-id" was to be replaced by something and should be issued as a command. It didn't strike my mind that it could actually be a directory. This probably happens to Windows -> Linux users in their initial phase! (or it's only me :)) –  its_me Aug 17 '11 at 22:20
    
@rozcietrzewiacz That's not very fair. –  Alex Chamberlain Oct 10 '12 at 9:05
    
Drop the -t type. mount will normally figure it out and generally if it can't, it's a reasonable indication you are doing something wrong. –  Alex Chamberlain Oct 10 '12 at 9:06
3  
@AlexChamberlain I can see I got carried. My apologies to @its_me. I should have written "If you'd really read the manual, you wouldn't ask about the -t option". The other part of the question (how to determine, which device is represented by a /dev/ entry) is very reasonable. –  rozcietrzewiacz Oct 18 '12 at 12:59
add comment

3 Answers

up vote 7 down vote accepted

You can use fdisk to have an idea of what kind of partitions you have, for example:

fdisk -l
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   204796619   102398278+   7  HPFS/NTFS
/dev/sda2       204797952   205821951      512000   83  Linux
/dev/sda3       205821952   976773119   385475584   8e  Linux LVM

That way you know that you have sda1,2 and 3 partitions. Now the -t option is the filesystem type, means NTFS, FAT, EXT. So in my example sda1 is ntfs so in my example it should be something like:

mount -t ntfs /dev/sda1  /mnt/

USB devices are usually vfat and Linux are usually ext

share|improve this answer
    
I am on a fedora VM (Windows 7 host). I just plugged in a usd drive (Windows doesn't recognize it because the VM is running) and issued the command $ fdisk -l. But it only lists Linux and Linux LVM file systems (only two). Not vfat, ntfs, hpfs or ext etc. –  its_me Aug 17 '11 at 20:49
    
Maybe this is not a mount issue, but a device recognition problem. Take a look at /var/log/message file, it should show if there is any problem with the USB device. –  ghm1014 Aug 17 '11 at 20:56
    
So, normally is this how I should find it on a running linux system: plugin a pen drive (example), issue the command # fdisk -l and find the device (/dev/*) & its filesystem (vfat, ntfs, hpfs, ext etc). Right? –  its_me Aug 17 '11 at 21:02
    
Usually, yes. If you're running gnome, it mount usb and external hard drives but itself without manually mount. It shows a popup window just like Windows does. –  ghm1014 Aug 17 '11 at 21:55
    
One last doubt. Are these the only common filesystem device files: /dev/sd* or /dev/hd* are for hard disks, /dev/cdrom for CD-ROMs and /dev/fd* for floppies. Anything else? –  its_me Aug 17 '11 at 22:00
show 1 more comment

These days, you can use the verbose paths to mount a specific device.

For example:

mount /dev/disk/by-id/ata-ST31500341AS_9VS2AM04-part1 /some/dir
mount /dev/disk/by-id/usb-HTC_Android_Phone_SH0BTRX01208-0\:0 /some/dir
share|improve this answer
    
Where can I find more information about this? I am not yet into this "verbose thing" on Linux, so it's confusing. –  its_me Aug 17 '11 at 21:21
1  
@Aahan Well, these are just symlinks to /dev/sd*. There are /dev/disk/by-id (device/partition ID), /dev/disk/by-uuid (device/partition UUID - not very useful for manual use), /dev/disk/by-path (depends on how the device is connected), /dev/disk/by-label (partition label if present) –  Let_Me_Be Aug 17 '11 at 21:27
    
where do I get these details (partition ID, device path, label etc) from? –  its_me Aug 17 '11 at 21:36
1  
@Aahan Well, that is what the device reports. Id will be the device name or model or serial number, or a combination. Path will be the same, but reported for the way the disk is connected, so it will be for example pci-0000:00:1f.2-scsi-3:0:0:0-part3 (pci device 0000:00:1f.2, third port, third partition), label will be label, uuid is computer generated unique id (you will use that if you will want a form of identification that won't change). –  Let_Me_Be Aug 17 '11 at 21:42
    
I guess this is tougher for me as I am a beginner. Where do I find more information about common device files i.e., that /dev/sd* or /dev/hd* are for hard disks, /dev/cdrom for CD-ROMs, /dev/fd* for floppies etc? Kindly direct me (I don't know what to search for - - search term). –  its_me Aug 17 '11 at 21:53
show 5 more comments

mount (the command) usually figures out the "type" of the file system on the device. I think the hard part if figuring out the device file name. You almost have to know the disk drive naming conventions to figure it out.

On an up-to-date Arch linux box:

133 % ls /dev/sd??
/dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sdb1  /dev/sdb2

But that doesn't work on a mature (2.6.20.9) Slackware box:

1 % ls /dev/sd??
zsh: no matches found: /dev/sd??
2 % ls /dev/hd??
/dev/hda1  /dev/hda2

Without knowing in advance that /dev/sd* or /dev/hd* are hard disk device files, you have to use lspci or lsusb or something to figure out the device file name. USB devices often leave information in /var/log/messages to help you figure out what device file udev assigned to them.

share|improve this answer
1  
How about using fdisk -l like the other answer mentioned? (also please see my latest comment on that answer.) –  its_me Aug 17 '11 at 21:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.