Linux #14 ? Mounting

By Pete | @kingpetey | 22 Nov 2002

In Linux in order for you to access a device such as a CD Drive or Hard Drive you first need to mount it to the file system, though this may sound silly compared to Windows it is actually a very useful way of doing things.

For instance say a device was not working properly you may was to unmount it if it is conflicting with something else, also you may only want certain devices mounted for certain people that use the computer. When you install Linux it will try to mount all your devices for you and store them in a file called fstab that is located in /etc/fstab.

Before you can mount something you need to know what type of file system you are mounting. For instance if you are mounting another Linux partition it is most likely to be ext2 or ext3 but if you are mounting a Windows Partition it is more likely to be vfat(fat32) or ntfs.

The second thing that you need to know is where you want to mount your device to, normally if it is another partition or cdrom drive you can mount it into the /mnt directory. You cannot mount the same device to the same directory so make more directories in /mnt such as /mnt/windows or /mnt/cdrom that way you know what the device was has been mounted.

All of the information about the file system that you want to mount is stored in the directory /dev/ so when mounting a device you usually specify that directory. The /dev/ directory includes information about the drive you wish to mount but when typing the mount command you also need to specify the file system type. Below shows the directory for each device that is usually in the /dev directory.

/dev/hda ? First IDE Hard Drive
/dev/hda1 ? First IDE Hard Drive ? First primary or extended partition
/dev/hda2 ? First IDE Hard Drive ? Second primary or extended partition
/dev/hdb ? Second IDE Hard Drive
/dev/hdb1 ? Second IDE Dard Drive ? First primary or extended partition
/dev/hdb2 ? Second IDE hard drive - Second primary or extended partition
/dev/cdrom ? CDRom Drive
/dev/cdrom1 ? Second CDrom drive
/dev/fd0 ? Floppy Drive

For example to mount devices in the console type:

mount ?t iso9660 /dev/cdrom /mnt/cdrom

This will mount your cdrom to /mnt/cdrom, be careful if you have more then 1 cdrom as it might be /dev/cdrom1 etc. iso9660 is the file system used by cdroms.

Mount ?t vfat /dev/hda2 /mnt/windows

This will mount the windows partition to /mnt/windows. The /dev/hda2 refers to the second partition on the first IDE hard drive.

Mount ?t /dev/fd0 /mnt/floppy

This will mount the floppy drive to /mnt/floppy , if the floppy is a default linux floppy you do not need to specify a file system.