MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Administration

Mounting II

* Uses Of 'fstab'
* 'fstab' Entries explained
* Using 'supermount'

Related Resources:

man mount
man fstab
man supermount

Revision / Modified: Jan 09, 2002
Author: Tom Berger

 

* Uses Of 'fstab'

The central configuration file for the 'mount' command is '/etc/fstab'. You can either use 'diskdrake' (Mandrake Control Center - Hardware - Mount Points) to make changes to that file, or edit the file directly as 'root'.

'/etc/fstab' has several uses:

  • You can determine which media to mount automatically on boot.

  • You can specify fixed mount options and mount points for every medium.

  • The system uses it to mount several 'virtual' file systems.

Mounting Media On Boot

By default, all media listed in 'fstab' are mounted on boot. If a medium isn't available, 'mount' will print an error message and continue with the next entry. Notice that this also applies to networked media like NFS or SMB shares. To prevent 'mount' from trying to mount a medium on boot time, you have to supply the 'noauto' option to the entry of that medium in '/etc/fstab'.

Specifying Mount Options And Mount Points

If you've read the previous page, you already know that the 'mount' command has two sets of options: a set of general options and a set specific to each file system.

File system specific options are file system specific. Really ;-) If you supply an entry in 'fstab' with an option which is specific to a file system (for example umask=0, specific to the Windows FAT file system), only media with this file system can be mounted via this entry. If you need to mount media with different file systems on the same device, either refrain from using file system specific options or create an entry for every file system.

Specifying a mount point has the advantage that you don't have to supply the device file name to the (u)mount command any longer.

mount mount_point

will look up the entry with the respective mount point in '/etc/fstab' and access the listed device file.

Virtual File Systems

Depending on system configuration, 'fstab' contains a number of entries for 'virtual file systems'. These entries do not have corresponding device files listed. Whatever you do, don't mess with these entries!

  • 'proc' mounts the 'process tree' under '/proc' which provides a slew of information on what's going on on your system.

  • 'pts' enables 'pseudo terminal support', a Unix compatibility feature.

  • 'shm' enables support for 'POSIX shared memory'. Only used by a few programs, but doesn't hurt.

* section index * top

* fstab Entries Explained

Local Fixed System Partitions

You see that there are already entries in '/etc/fstab' for your system partitions like '/'. Have a look at one of them:

/dev/hda3 / ext2 defaults 1 1

The syntax is:

/dev/hda3 / ext2 defaults 1 1
device_name mount_point file_system options 'dumpe2fs' 'fsck'

So there's the device name of the medium (here the partition on a disk), the mount point ('/') and the file system ('ext2').
defaults collects a set of 'mount' options: rw allow read/write, suid allow set-user-identifier, execallow execution of programs, auto mount on boot,nouser can only unmounted by root, and async allows delayed disk accesses (caching).

The last two options are flags for the file system utilities 'dumpe2fs' and 'fsck'.
The 'dump' field is either set to '1' (enable) or '0' (disable). Since 'dump' is used by backup programs for the ext2 / ext3 file system only, '1' is set just with entries for ext2 / ext3 media. All other media use '0'.
The 'fsck' field can either be set to '0' (disable file system check), '1' (check first) or '2' (check). '0' is set for all media with non-Linux file systems, removable and networked media, and virtual file systems. '1' is set for the '/' entry, since this partition has to be mounted (and thus checked) first and '2' for all other non-removable, local media with Linux file systems.

Removable Media

Removable data storage like CDs needs different options (if you are not using 'supermount'):

/dev/cdrom /mnt/cdrom auto user,noauto,exec,ro 0 0

user allows mounts and unmounts by users. Otherwise only 'root' is allowed to do that. Notice however, that this option will turn offexec. You have to specify exec after theuser option to allow execution of programs on user-mountable drives, like it is done in this example. noauto means that the system shouldn't to mount the device at boot time, which is quite a sensible option for removable media ;-). ro specifies the media as 'read-only'. 'dump' and 'fsck' are disabled.

Although the CD isn't mounted automatically, the entry in '/etc/fstab' makes mounting much easier: Insert a CD into the drive and type

mount /mnt/cdrom

'mount' looks into '/etc/fstab' for an entry connected with this mount point and takes the options which are listed there, so you don't have to supply them anymore. In KDE, you just have to insert the CD and click on the CD icon. This will issue the correct 'mount' command automatically.
A mounted CD will lock the CD tray. To change or eject the CD, you have to unmount it first with umount /mnt/cdrom.

To configure additional removable media, you have to know the name of their device files. Either check devices.txt or read the article on removable storage devices.

Local Fixed Non-System Partitions

Now what would an entry for an MS-Windows partition look like? Assume it is the second partition on your first IDE drive and you want to have it mounted automatically. It's

/dev/hda2 /mnt/win_d vfat umask=0,quiet 0 0

For an partition formatted with NTFS, the standard file system on the Windows NT line of operating system, just replace 'vfat' with 'ntfs'. Notice that Linux NTFS file system driver currently supports only reading, not writing.

The 'umask' option turns off the permissions check. Without that option, only 'root' can access files on this device. 'quiet' turns off those annoying and pointless error messages about not being able to set permissions when moving files to this medium.

If the file names on the Windows medium look funny, you might have to specify two more options, 'iocharset' and 'codepage'. By default, 'mount' uses the 'iso8859-1' charset and codepage 437. These enable character conversion. Available charsets are listed in man charsets, setting the codepage to 850 (codepage=850) should fix most problems.

Networked Shares

NFS and SMB shares can also be configured via 'fstab'. Please read the articles on Samba and NFS first, since options here are important and require some understanding on how these protocols work.

The basic syntax is not very different from that for local media. The entry for the 'device file' is just replaced by an entry for the remote server and share:

remote_server:share local_mount_point file_system options dump fsck

So, an entry for automatically read-write mounting an NFS share called '/share/nfs' from the server 'domain.com' to the local '/mnt/nfs' directory would basically look like this:

domain.com:/share/nfs /mnt/nfs nfs rw 0 0

For SMB shares, you'd basically just replace the 'nfs' file system type with 'smbfs'.

* section index * top

* Using 'supermount'

If you are using 8.1, read this hint on 'supermount'.

'supermount' has been introduced in Mandrake Linux to make the handling of removable media much easier. It uses a nifty trick to automatically mount all inserted media: it mounts the (empty) devices by itself on boot and queries them regularly for newly inserted or removed media. The effect of which is that you don't have to mount or unmount external devices anymore: the system does it all by itself.

There just four instances left you have to worry about mounting: when adding a new device you want 'supermount' to handle, when you have to use a medium unmounted, when you use media with different file systems in the same device, or when you want to pass options to the 'mount' command via a 'supermount' entry.

Extending 'supermount' to new devices

# supermount -i enable

enables 'supermount' on all removable devices listed in '/etc/fstab'. In order to have this take effect, you have to reboot. This command requires 'root' privileges.

If the system doesn't recognize your new external device and thus doesn't write an entry to '/etc/fstab', you'll have to do that by yourself, either by creating a standard fstab entry for that device and then running the 'supermount' command to enable it, or by writing an entry in the 'supermount' format right away.

A common 'supermount' entry for a CD drive looks like this:

/mnt/cdrom /mnt/cdrom supermount fs=iso9660,dev=/dev/cdrom 0 0
mount_point mount_point supermount fs=file_system,dev=device 0 0

All you need to know for adding a new device is: the mount point (create one yourself as 'root' with mkdir /mnt/name), the file system the inserted medium will have (read man mount for supported types and their codes) and the device name (Either check devices.txt or read the article on removable storage devices).

One tricky thing here can be finding out how the vendor formatted the medium. Usually, they do not use the first partition, but either the forth (like Iomega's ZIP) or the fifth (like Castlewood's ORB). Remember to keep this scheme if you reformat the medium for Windows / Mac compatibility.

Unmounted Media In 'supermount' Devices

Certain tasks like playing music CDs for example require the medium to be inserted but unmounted. There's currently no other solution then to unmount the device, thus making it possible to use the unmounted medium but also turning off 'supermount' for the remaining session.

Using 'supermount' with different file systems

That entry in '/etc/fstab' however will only work with media that are formatted with the MS-Windows file system (vfat). It will not mount media formatted with GNU/Linux' extfs2, for example. You can change this easily, though, by simply setting the entry for the file system type to 'auto'. Make sure that '/etc/filesystems' contains entries for all the file systems you use.

'supermount' will now look up this file when inserting a medium and mount it with the appropriate parameters.

Passing 'mount' options to 'supermount' in '/etc/fstab'

If you need or want to pass options to the 'mount' command when the device is handled by 'supermount', you will need to separate these options from those passed to 'supermount' itself with --,

Let's say you want to add the 'umask=0' option to a 'supermount' entry in '/etc/fstab':

/mnt/zip /mnt/zip supermount fs=vfat,dev=/dev/sda4,--,umask=0 0 0
                  

would be the right way to do it.

The next page covers frequent mount troubles.

* section index * top

* Trouble with mounting


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.