Fstab usage details

Source: Internet
Author: User
Fstab' usage '/etc/fstab' is an important configuration file for the 'Mount' command. You can use the 'root' identity to modify this file through 'diskdrake' (MandrakeLinux control center-load point) or by using an editor. '/Etc/fstab' can be used to determine the media to be automatically mounted at startup, and to specify the option for each media to be mounted. Use of fstab'
'/Etc/fstab' is an important configuration file for the 'Mount' command. You can use the 'root' identity to modify this file through 'diskdrake' (MandrakeLinux control center-load point) or by using an editor.

'/Etc/fstab' has several functions:

Determines which media is automatically mounted at startup;

Specifies the options and loading points for each media mount;

The system is used to mount several virtual file systems.

Mount media at startup
By default, all media listed in 'fstab' will be mounted at startup. If an error occurs in a media set, 'mount' displays the error message and continues the next object. Note that this is also valid for network media such as NFS or SMB sharing. If you want to cancel automatic mounting at startup, you must provide the 'noauto' option for the corresponding entry in '/etc/fstab.

Specify mounting options and loading points
If you read the previous article, you know that the 'Mount' command has two options: General options and special options for the file system.

Special options for specific file systems. If you provide special options for an entry in 'fstab' (for example, umask = 0 for Windows FAT file system ), only the media of the corresponding file system can be mounted through this entry. If you want to mount the media of another file system, either set the option or create a separate entry.

It is advantageous to specify the loading point. you can omit the file name of the device when mounting/detaching.

Mount mount_point

In '/etc/fstab', find the entry of the corresponding loading point and mount it according to the preset settings.

Virtual File System
According to the system configuration, 'fstab' contains virtual file system entries that do not list the corresponding device files. In any case, do not move these entries!

'Proc' mounts the process tree to provide system information;

'PTS 'enables "pseudo terminal support" (pseudo terminal support), which is compatible with Unix;

Enable POSIX shared memory in 'shm'. only a small part of the program will be used without any negative impact.

Section index top

Description of entry in 'fstab'
Local fixed system partition

You can see that '/etc/fstab' already contains several system partitions (such. Take this example:

/Dev/hda3/ext2 defaults 1 1

Syntax:

/Dev/hda3/ext2 defaults 1 1
Device_name mount_point file_system options 'dumpe2fs' 'fsck'
There are device names, load points (/), and file systems (ext2) of the media (partition of the hard disk ).
Defaults includes several 'mount' options: rw readable and writable, and suid allows setting of user identifier (set-user-identifier) exec allows running programs, automatic mounting during auto startup, nouser only has 'root' permission to detach, and async allows disk delay (caching ).

The last two options are the symbols used by the file system tools 'dumpe2fs' and 'fsck.
The 'dump' field can be set to '1' (enabled) or '0' (disabled ). Because the program that backs up the ext2/ext3 file system uses 'dump', set the file system to '1' for the ext2/ext3 entries, and set all other entries to '0 '.
The 'fsck' field can be set to '0' (do not check the file system), '1' (check first), and '2' (check ). All non-Linux file systems, removable and network media, and virtual file systems must be set to '0'. because the root partition must be mounted first (then checked ), the '/' entry must be set to '1', and all other non-removable and Linux file system local media must be set to '2 '.

Removable Media
Removable data storage bodies, such as CDs, require different options (if you do not use 'supermount '):

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

The user allows the user to attach or detach a file. Otherwise, only 'root' has the permission. Please note that this option will disable exec. you must specify exec after the user option is available so that you can run the program in the mounted Media. these are the same as the above example. Noauto indicates that the media is not mounted at startup. this option is required for some removable media. Read-only media mounted by ro ). 'Dump' and 'fsck' are all disabled.

Although the disc is not set to auto-mounted, the following attaching is simple due to this entry in '/etc/fstab': put the disc and enter:

Mount/mnt/cdrom

'Mount' searches for the entry associated with this load point in '/etc/fstab' and uses the listed options. Therefore, you can save some input. In KDE, after you place the disc, you can click the disc icon with the mouse to automatically run the 'Mount' command.
The mounted disc will lock the optical drive. to bring up the disc, you must first uninstall umount/mnt/cdrom.

To configure other removable media, you need to know their device file names. you can refer to devices.txt or read articles about removable storage devices.

Local fixed non-system partition
What does MS-Windows partition entry look like? Assume that the disk is in the second partition of the first IDE hard disk, and you want to automatically mount the disk:

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

For the NTFS partition of Windows NT, replace 'vfat' with 'ntfs '. Note that in Linux, only NTFS file systems can be read, but not written.

The 'umask 'option will disable permission monitoring. without this option, only 'root' can access the files on the device. When a file is moved to the media, an annoying error message is displayed because the permission cannot be set. you can use 'Quiet 'to not display the irrelevant information.

If the file name in the Windows partition looks strange, you have to add two more options: 'iocharset' and 'codepage '. By default, 'mount' uses the 'iso8859-1' character set and codepage 437. After modification, character conversion can be realized. Man charsets lists available character sets and sets codepage to 850 (codepage = 850) to solve some problems.

(Note: to display simplified Chinese, add charsets = gb2312, codepage = 936)

Network sharing
You can also configure the shared directories of NFS and SMB through 'fstab. Because the options involved are very important and you need to understand the work of some protocols, you must first read Samba and NFS.

There are not many differences between the basic syntax and the local media. Replace 'device file' with remoteserver and share ):

Remote_server: share local_mount_point file_system options dumpfsck

Server 'domain. if the '/share/nfs' directory on com is automatically mounted to the local '/mnt/nfs' directory and can be read/written, the entry is basically similar:

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

For SMB sharing, you only need to replace 'nfs 'with 'smbfs '.

Section index top

Use 'supermount'
If you are using MDL 8.1, read the 'supermount' prompt.

Mandrake Linux introduces 'supermount' to simplify processing of removable media. To enable automatic media mounting, here is a tip: when the device is started (empty), it is mounted and the newly inserted or removed media is used for query. In this way, you no longer need to attach or detach external devices, and the system can automatically complete them.

However, there are four other problems that you may not know at the moment: how do you tell 'supermount' to handle new devices? How to uninstall a media set? How do I use the media of the same device but different file systems? How to pass the optional information to the 'Mount' command through the 'supermount' entry?

'Supermount' processes new devices
# Supermount-I enable

Enable 'supermount' for all removable devices listed in '/etc/fstab'. to make it take effect, you must restart the system. This command requires the 'root' permission.

If the system cannot identify your new peripherals, '/etc/fstab' does not add any entries, you have to do it yourself. You can also create a standard fstab entry for the device and run the 'supermount' command to make it take effect. Alternatively, you can immediately write an entry in the 'supermount' format.

The following is a general 'supermount' entry for the optical drive:

/Mnt/cdrom supermount fs = iso9660, dev =/dev/cdrom 00
Mount_point supermount fs = file_system, dev = device 00
To add a new device, you need to know: load point (Create directory as 'root': mkdir/mnt/name) file system that is added to the media (manmount has supported types to describe it), device name (see devices.txt or articles about removable storage devices ).

One tricky thing here can be finding out how the vendorformatted the medium. usually, they do not use the first partition, but either the forth (like Iomega's ZIP) or the second th (likeCastlewood's ORB ). remember to keep this scheme if you reformat themedium for Windows/Mac compatibility.

Detach a 'supermount' device
If you want to listen to a record, you will need to uninstall it. There are no other solutions. you can only umount the device and then use the media. However, in the following session, you cannot use 'supermount.

Use 'supermount' for different file systems'
The entries in '/etc/fstab' are valid only for the MS-Windows file system (vfat), but cannot directly mount the GNU/Linuxextfs2 media. The solution is to set the file system type in this entry to 'auto', but make sure that the file system you are using is listed in '/etc/filesystem.

In this way, when the media is added, the 'supermount' will find the appropriate parameter in the file.

In '/etc/fstab', pass the 'Mount' option to 'supermount'
When 'supermount' is used to process a device, if you want to pass options to the 'Mount' command, you need to use -- to separate the options that are passed to 'supermount.

Suppose you want to add 'umask = 0' to a 'supermount' entry in '/etc/fstab:

/Mnt/zip supermount fs = vfat, dev =/dev/sda4, --, umask = 0 00
In this way, you can.

_____________

Fstab stores important information related to partitions. each row is a partition record, and each row can be divided into six parts, the following uses/dev/hda7/ext2defaults 1 as an example to describe one by one:

1. The first is the physical location of the storage device you want to mount, such as hdb or/dev/hda6.

2. the second item is the directory to which you want to add it, such as/home or/. this is the mount point prompted during installation.

3. the third item is the so-called localfilesystem, which contains the following formats: ext, ext2, msdos, iso9660, nfs, swap, etc., or ext2. for details, see/prco/filesystems.

4. the fourth item is the status you want to set during mount, such as ro (read-only) or ULTS (including other parameters such as rw, suid, exec, auto, nouser, and async ), see "mountnfs 」.

5. the fifth item is to provide the DUMP function. it indicates whether the BACKUP flag is required during system DUMP. The value is 0.

6. the sixth item is to set whether the filesystem needs to perform the check action at startup. except for the root filesystem, the required check value is 1. the other items can be set as needed. the internal value is 0.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.