Mounting II
Summary:
- Uses Of 'fstab'
- 'fstab' Entries explained
- Using 'supermount'
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
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 entries1.1
- '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.
fstab Entries Explained 1.1 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
rw
suid
exec
auto
nouser
async
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
exec
exec
user
noauto
ro
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
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'.
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.
Next Item: Trouble with mounting
Related Resources:
man mount
man fstab
man supermount
Revision / Modified: Jan 09, 2002
Author: Tom Berger
Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
Version 1.10 last modified by ptyxs on 18/01/2007 at 16:22
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!
Comments (1)