Putting Linux to work - Mounting file systems

One of the strengths of Linux is its support for a variety of file systems. The default file system for Linux is the second extended file system, or ext2. When you install Linux, the root and other partitions will be formatted with the ext2 file system. "Mounted" is the term given to file systems that are currently in use on a given system - whether it is a hard drive or external devices such as floppy disks and CD-ROMs.

To determine which file systems are presently in use by your system, type:

$ mount

at a command prompt. This will display all the mounted file systems in terms of the device, file system type and the mount point. The mount point is the local directory that is assigned to a file system during the process of mounting.

External devices

In order to use floppy disks and CD-ROMs you must mount them first. Login as root and start by making three directories that will be used as mount points:

$ mkdir /floppy /cdrom /win

However, your system may already have two such directories under the /mnt directory for this purpose, i.e., /mnt/floppy /mnt/cdrom. Many people using Linux for the first time will want to access MS-DOS formatted floppy disks in order to use Windows files within Linux. To mount a floppy with this format, put the disk in the drive and as root type:

$ mount -t msdos /dev/fd0 /floppy

This allows the mount command to mount an MS-DOS formatted file system as indicated by the -t (type) option. The device as recognised by the kernel is located at /dev/fd0 (as in device Floppy Disk 0) and the mount point is the /floppy directory. Now you can access the MS-DOS formatted floppy disk as you would any other directory. A similar command would be used to mount an ext2 formatted floppy except you would type "ext2" instead of "msdos".

Mounting a CD is similar, however, the file system and device are different:

$ mount -t iso9660 /dev/cdrom /cdrom

The iso9660 file format is standard for all CD-ROM media and is also the default format that the mount command uses for mounting /dev/cdrom. You can access your CD-ROM and all the files on it through the /cdrom directory. Note that some desktop environments automatically will mount a CD as it is placed in the drive.

When you are finished using any external file system you will need to unmount it; this is the process of telling the kernel that you are no longer accessing that particular file system. In order to unmount a file system you must not be accessing it in any way, meaning that your working directory cannot be the particular mount point. The umount command is used for unmounting file systems:

$ umount /floppy

and

$ umount /cdrom

This will unmount your CD-ROM and floppy drives, allowing you to change the media. With unmounting, only the mount point or device needs to be specified.

Other partitions

The mount command can also be used to mount partitions on local hard drives. This is very useful for accessing your Windows partition and sharing files between Windows and Linux on one computer. Windows 9x partitions are usually formatted as FAT16 or FAT32, FAT standing for File Allocation Table.

Linux will recognise FAT file systems and they can be classified vfat when mounting. To mount your Windows partition type:

$ mount -t vfat /dev/hda1 /win

Since your Windows partition is likely to be the first partition on the first IDE hard drive, it will be classified as hda1. If /dev/hda1 does not hold the Windows partition, use the "df" command see which partitions are not mounted under Linux (it may be /dev/hda2, for example) and use them instead.

The /win directory will now allow you to access all your Windows files, which can be transferred to and from your Linux system.

For a more detailed summary of the mount command see its online manual page located at:

$ man mount

The /etc/fstab file

The Linux file system table, or /etc/fstab, is a file that can be used to predefine mount points and other variables. Every time the mount command is issued, the /etc/fstab is read for this purpose. Using a text editor, and while logged in as root, edit your /etc/fstab file to look like the one illustrated below.

An example of a /etc/fstab file

DEVICE MOUNT POINT TYPE PARAMETERS

/dev/hdb3 / ext2 defaults 1 1

/dev/hdb4 swap swap defaults 0 0

/dev/fd0 /floppy msdos noauto,rw 0 0

/dev/cdrom /cdrom iso9660 noauto,ro 0 0

/dev/hda1 /win vfat nosuid,rw 0 0

none /proc proc defaults 0 0

none /dev/pts devpts gid=5,mode=620 0 0

This allows you to mount a CD-ROM or MS-DOS formatted floppy by executing the appropriate command below:

$ mount /cdrom

or

$ mount /floppy

This works because the mount conditions for each type of file system have been set in the /etc/fstab file. The explanations for the variables in the parameters section are all available in the mount manual page.

Mounting file systems is a necessary utility that can be applied in various ways to increase the amount of access your system has to peripheral devices and different operating systems.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Rodney Gedda

PC World
Show Comments

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Kurt Hegetschweiler

Brother PocketJet PJ-773 A4 Portable Thermal Printer

It’s perfect for mobile workers. Just take it out — it’s small enough to sit anywhere — turn it on, load a sheet of paper, and start printing.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?