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 PC World 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

Matthew Stivala

HP OfficeJet 250 Mobile Printer

The HP OfficeJet 250 Mobile Printer is a great device that fits perfectly into my fast paced and mobile lifestyle. My first impression of the printer itself was how incredibly compact and sleek the device was.

Armand Abogado

HP OfficeJet 250 Mobile Printer

Wireless printing from my iPhone was also a handy feature, the whole experience was quick and seamless with no setup requirements - accessed through the default iOS printing menu options.

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?