/Etc/fstab file explanation

Source: Internet
Author: User
Tags arch linux

Http://ckc620.blog.51cto.com/631254/394238

/Etc/fstab file explanation

The file fstab contains information about the storage devices on your computer and their file systems. It determines how a hard disk (partition) is used or integrated into a unique file in the system.

The full path of this file is/etc/fstab. It is just a text file. You can open it in your favorite editor, but it must be a root user to edit it. At the same time, fsck, mount, umount and other commands all use this program.

Specifically, fstab can be used to automatically mount hard disks, partitions, removable devices, and remote devices in various file system formats. For Windows and arch operating systems, you can use fstab to mount partitions in the fat format and NTFS format to share resources in Linux.

Fstab file example

Now let's take a look at a typical fstab file:

# <file system><dir><type><options><dump><pass>none                   /dev/pts      devpts    defaults                0      0none                   /dev/shm      tmpfs     defaults                0      0/dev/cdrom             /media/cd     iso9660   ro,user,noauto,unhide   0      0/dev/dvd               /media/dvd    udf       ro,user,noauto,unhide   0      0/dev/fd0               /media/fl     auto      user,noauto             0      0/dev/hda1              swap          swap      defaults                0      0/dev/hda4              /             ext3      defaults                0      1/dev/hda3              /home         xfs       rw,suid,exec,auto,nouser,async 0      2</pass></dump></options></type></dir></file>

Fstab details

Let's have a detailed understanding of the usage of fstab. A typical entry has the following fields (fields are separated by spaces or tabs ):

<file system><dir><type><options><dump><pass></pass></dump></options></type></dir></file>
  • <File systems> not a file system we generally understand, but a device (hard disk and its partition, DVD drive, and so on ). It tells us the name of the device (partition), which is used when you mount or detach a device in the command line. So one shoshould substitute for this entry the device name, remote partition, or similar. </File>

  • To tell us where the device is mounted.
  • <Type> indicates the types of file systems (such as ext2, ext3, reiserfs, XFS, JFS, smbfs, iso9660, vfat, NTFS, and swap) used to mount devices or partitions ). Archlinux supports many file systems. To obtain a complete support list, find Mount Man-page. Typical names include: ext2, ext3, reiserfs, XFS, JFS, smbfs, iso9660, vfat, NTFS, swap, and auto. 'auto' is not a file system, instead, let the mount command automatically determine the file type, especially for removable devices, floppy disks, and DVD drives. This is necessary because the file types on each mount may be different.
    </Type>
  • <Options>, options, which are the most useful settings !!! </Options>

It automatically loads the mounted device when it is started, prevents garbled characters in Chinese, and limits the read and write permissions on the Mount partition. It is related to the usage of the mount command. For a complete list, refer to mount manpage.

    • Recommended Parameters
Noatime disables the atime feature to improve performance. This is a very old feature. You can safely disable it and reduce loadcycle.
    • Default settings
Defaults uses the default settings. It is equal to RW, SUID, Dev, exec, auto, nouser, and async. For more information, see the following description.
    • Automatic and manual mounting
When Auto starts or enters Mount-A in the terminal, it automatically mounts the noauto device (partition) and can only manually mount the file system can be mounted only explicitly.
    • Io encoding settings
Iocharset = add your local encoding after the = sign. It seems that when file IO is performed on this device (partition), the encoding format is automatically converted. For example, if your partition is UTF-8 encoded and the file in the device is gb2312, When you copy the file from your device to your partition, it automatically performs encoding conversion. (I don't know if my understanding is correct, but it seems that the conversion can be implemented using the NLS below .)
    • Chinese garbled characters
NLS = add your local code after the = sign so that no garbled characters will appear in your Chinese.
    • Read and Write Permissions
Umask = This is about read and write permissions. It seems to be more useful than RO and RW options below !!! For example, umask = 000 or 0222 means that default exists in option during mounting, and normal users can still read and write things in the mounting device. Please add it !!! RO mounting is read-only permission RW mounting is read-write permission
    • Executable
Exec is a default setting that enables executable binary files in that partition to be executed. Noexec binary files cannot be executed. Do not use this option in your root partition !!!
    • I/O Synchronization
Sync all I/O will be synchronized async all I/O will be non-synchronous
    • User Mount permission
User allows any user to mount the device. Implies noexec, nosuid, nodev unless overridden. nouser can only be mounted by the root user. This is the default setting.
    •  
   suid     Permit the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.   nosuid   Blocks the operation of suid, and sgid bits.

 

 

  • <Dump> dump utility is used to determine whether a backup is performed. after the installation (ARCH Linux does not install dump by default), dump checks the entry and uses numbers to determine whether to back up the file system. The allowed numbers are 0 and 1. If it is 0, dump will ignore this file system. If it is 1, dump will make a backup. Most users do not install dump, so for them, <dump> This entry should be written as 0. </Dump>
  • <Pass> fsck checks the numbers under this lead to determine the order of the file system (looks at the number substituted for <pass> and determines in which order the file systems shocould be checked). The allowed numbers are 0, 1, and 2. The <pass> Option 0 of the file system will not be checked by the fsck utility. The root file system should have the highest priority, 1, and all other file systems should be written as 2 if you want it to be checked. </Pass>

Note: In addition to the device (partition) name, you can also use the uuid or volume name. Format label =Or UUID = <UUID>. For example, 'label = boot' or 'uuid = 3e6be9de-8139-11d1-9106-a43f08d823a6 '. </UUID>

Use fstab to automatically mount FAT32 and NTFS partitions

1. first obtain the hard disk information table using fdisk-l (which may require root permission), for example:

#  Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1        2397    19253871    b  W95 FAT32/dev/sda2            2398        3144     6000277+  83  Linux/dev/sda3            3145        9729    52894012+   5  Extended/dev/sda5            3145        3152       64228+  83  Linux/dev/sda6            3153        3276      995998+  82  Linux swap / Solaris/dev/sda7            3277        7340    32644048+  83  Linux/dev/sda8            7341        9729    19189611    7  HPFS/NTFS

As we can see from the above, there is only one hard disk on this computer, where the sda1 and sda8 partitions are in NTFS format, sda1 is able to start, and thus may be the disk of the window system. The system disk is mounted in read-only mode, and the non-system disk sda8 is mounted in read/write mode (it cannot be mounted in any directory "/" or below ).

2. Use your favorite editor to open/etc/fstab in the terminal, for example:

                    nano /etc/fstab

Add the following content to the end of the file:

/dev/sda1 /mnt/WindowsC vfat defaults,codepage=936,iocharset=cp936,umask=0222 0 0/dev/sda8 /mnt/WindowsD ntfs defaults,iocharset=utf8,umask=000,nls=utf8 0 0

Save and exit.

Warning:Hanging a 936 codePage on a FAT32 partition may cause normal Chinese recognition in Linux, but garbled characters appear in windows. We recommend replacing it with utf8, but the dmesg prompts a warning. It doesn't matter, N people have been using it for so long.

/dev/sda1 /mnt/WindowsC vfat user,utf8,umask=000 0 0

3. Enter

mount -a

You should be able to find the content of your system partition sda1 under/mnt/windowsc, and find the content of sda8 in/home/username/windowsd (username indicates the user name ).

From http://www.javaeye.com/articles/368

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.