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!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Rodney Gedda

PC World
Show Comments

Father’s Day Gift Guide

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?