Mounting In Linux - Online Article

Mounting is the Linux phrase for getting the operating system to access your disks. This disk can be a floppy, a cdrom or a hard disk partition.

To mount a disk, there are two necessary conditions:

  1. The disk (device) must be one of the files in the /dev directory.
  2. The disk must be listed in the /etc/fstab (or /etc/mtab sometimes) file along with some extra information.

By default when you install Linux, it is automatically configured to be able to access your floppy disks, cdrom and at least one hard disk. Also every time you boot into Linux, your /swap and your /root directory, are mounted.

However there are times when you have stored some songs on your windows partition and you want to listen to them while running Linux, or maybe read some web-pages you saved on Windows while running Linux. For this you might have to configure your system to read the Windows drives or as we say, mount them.

Mounting is done using the mount command but before using that command we must actually edit the configuration file for it in the /etc folder.

NOTE: Almost all configuration files in Linux are stored in the /etc directory and its subdirectories.

The file to look for now is the /etc/fstab file. Open this file in your favorite text editor. If you are using KDE, you can do this by typing \" kwrite /etc/fstab \" in the console.

What you see now is something similar to this:

/dev/hdc5	/			ext2	defaults				1	1
/dev/fd0	/mnt/floppy	auto	noauto,owner			0	0
none		/proc		proc	defaults				0	0
none		/dev/pts	devpts	gid=5,mode=620			0	0
/dev/hdc6	swap		swap	defaults				0	0
/dev/cdrom	mnt/cdrom	iso9660	noauto,owner,kudzu,ro	0	0 

The first column lists the device which can be mounted from the /dev directory. The second column lists the mount point or the directory in which this device can be opened once mounted. The third column lists the format in which data is stored on this disk. The fourth column lists some parameters used for mounting the disk. The last two columns are 0 0 unless the disk to be mounted is your /root partition.

Now first we must find which file in /dev denotes our windows hard disk. Generally this is /dev/hda1 if the Windows Hard Disk is your primary master disk. It is /dev/hdc1 if the Windows Hard Disk is your primary slave disk We must now create a mount point, or a directory in which the drive will be opened when mounted. Open the console.

Type:

mkdir /mnt/hda1 (For most users)

OR

mkdir /mnt/hdc1 (For those rare few who have windows as primary slave disk)

Data on a windows hard disk is stored in fat32 or fat format which is denoted by \vfat\' in Linux. So now lets edit the /etc/fstab file which we have opened in the text editor. Make a new entry which should look like this.

/dev/hda1 /mnt/hda1 vfat sw 0 0

OR

/dev/hdc1 /mnt/hdc1 vfat sw 0 0

Save the /etc/fstab file.

Open the console (terminal) and type:

mount /dev/hda1

OR

mount /dev/hdc1

Now do

cd /mnt/hda1

OR

cd /mnt/hdc1

then do

ls

This should give you a list of the files in your Windows drive. Now you can create a shortcut to the windows disk on your desktop using:

cp -l /mnt/hda1 /home/yfr/Desktop

And thus you have mounted your Windows drive. For removable media try these commands.

mount /dev/cdrom

For mounting a cdrom.

mount /dev/fd0 

For mounting a floppy drive.

About the Author:

No further information.




Comments

No comment yet. Be the first to post a comment.