/Etc/fstab file details

Source: Internet
Author: User
Fstab (/etc/fstab) is an important configuration file in Linux. It contains detailed information about the file system and storage devices mounted at startup. The following is the fstab file on my machine: LABEL // ext3defaults11LABEL/boot1/bootext3defaults12tmpfs/dev/shmtmpfsdefaults00devp

Fstab (/etc/fstab) is an important configuration file in Linux. It contains detailed information about the file system and storage devices mounted at startup. Below is the fstab file on my machine:

LABEL = // ext3 defaults 1 1
LABEL =/boot1/boot ext3 defaults 1 2
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
LABEL = SWAP-sda11 swap defaults 0 0
/Dev/sda6/mnt/winE vfat defaults 0 0
/Dev/sda8/mnt/winG ntfs defaults 0 0

We can see that this file has six columns, and the last column is used as an example to explain them one by one. Here we assume you are familiar with the mount command:
1. the 1st column is the file system or storage device to be mounted. here is my G disk on Windows and the partition is/dev/sda8.
2. the 2nd column is the mount point. I chose/mnt/winG.
3. columns 3rd specify the file system or partition type. my G disk is NTFS type and is represented as ntfs in Linux.

. It is used to specify the device name or block information of the file system to be mounted, or remote file system. Anyone who has developed an embedded linux system may know the significance of the mount 192.168.1.56:/home/nfs/mnt/nfs/-o nolock (which can be other IP addresses) command. Its task is to mount the/home/nfs/directory on the remote host whose IP address is 192.168.1.56 to the/mnt/nfs/directory on the local machine. If you want to write it into the/etc/fstab file, set filesystem to/192.168.1.56:/home/nfs /.

If you want to mount a device on the local machine, write the following statements:/dev/sda1,/dev/hda2, or/dev/cdrom, /dev/sda1 indicates the first partition of the first serial hard disk or the first partition of the first SCSI hard disk./dev/hda1 indicates the first partition of the first IDE hard disk, /dev/cdrom indicates the optical drive.

In addition, it can be represented by a label (volume label) or UUID (globally unique identifier of a universal UniqueIdentifier. Before using a label, you must first create an e2label, for example, e2label/dir_1/dir_2, which means/dir_2 is used to represent the name of/dir_1. Then, add LABEL =/dir_2/dir_2 under/etc/fstab as follows: . After the restart, the system will mount/dir_1 to the/dir_2 directory. You can use vol_id-u/dev/sdax to obtain the UUID. For example, if you want to mount the first partition of the first hard disk, run vol_id-u/dev/sda11 to obtain the UUID, for example, 5dc08a62-4402-471b-9ef5-0a91e5e2c126, and then Enter UUID = 5dc08a62-4872-471b-9ef5-0a91e5e2c126 in this field to indicate/dev/sda11. Red Hatlinux generally uses label, while Ubuntu linux generally uses UUID.

File types:
Linux file systems: ext2, ext3, jfs, reiserfs, reiser4, xfs, swap.
Windows:
Vfat = FAT 32, FAT 16
Ntfs = NTFS
Note: For NTFS rw NTFS-3G
CD/DVD/iso: iso9660
Network file systems:
Nfs: server:/shared_directory/mnt/nfs 0 0
Smb: // win_box/shared_folder/mnt/samba smbfsrw, credentials =/home/user_name/winbox-credentials.txt 0 0
Auto: The file system type (ext3, iso9660, etc) itdetected automatically. usually works. used for removable devices (CD/DVD, Floppy drives, or USB/Flash drives) as the file system mayvary on these devices.

4. the 4th column lists mounting options. for details, refer to man mount. The following lists some common options:
Auto: Automatic mounting. fstab is the default option.
Ro: read-only
Rw: read-write
ULTS: rw, suid, dev, exec, auto, nouser, andasync.

5. columns 5th as the "dump" option, and sets whether to allow the backup program to dump the backup file system. values 0 are ignored, and 1 is backup.
6. columns 6th as the fsck option, telling the fsck program in what order to check the file system, 0 is ignored.

========================================================== ======================================

1. functions of the fstab file

File/etc/fstab stores the file system information in the system. When the file is correctly set, you can use the mount/directoryname command to load a file system. each file system corresponds to an independent line, fields in each row are separated by spaces or tabs. At the same time, fsck, mount, umount and other commands all use this program.

2. fstab file format

The following is an example line of the/etc/fatab file:

Fs_spec fs_file fs_type fs_options fs_dump fs_pass

/Dev/hda1/ext2 defaults 1 1

Fs_spec-this field defines the device or remote file system where the file system to be loaded is located. for general local block devices, the IDE device is generally described as/dev/hdaXN, X is the channel (a, B, or c) of the IDE device. N represents the partition number. SCSI device 1 is described as/dev/sdaXN. For NFS, the format is generally:

For example, 'knuth. aeb. nl :/. For procfs, use 'proc to define.

Fs_file-this field describes the directory point to be loaded by the file system. for a swap device, this field is none. for a directory name containing spaces, 40 is used to indicate spaces.

Fs_type-defines the file system on the device. the common file types are ext2 (common file types for Linux devices) and vfat (fat32 format for Windows systems), NTFS, iso9600, etc.

Codepage country code page

Iocharset character set

Fs_options-specifying the file system to load the device is a specific parameter option that needs to be used, multiple parameters are separated by commas. Most systems can use ULTS to meet their needs. Other common options include:

Option description

Ro loads the file system in read-only mode

Sync does not buffer write operations on the device, which can prevent file system damage during abnormal shutdown, but reduces the computer speed.

User allows normal users to load the file system

Quota forces disk quota limit on this file system

Noauto no longer uses the mount-a command (for example, when the system is started) to load the file system

Fs_dump-This option is used by the dump command to check how often a file system should be dumped. If no dump is required, set this field to 0.

Fs_pass-this field is used by the fsck command to determine the sequence of the file system to be scanned at startup. The value of the root file system/pair should be 1, other file systems should be 2. If the file system does not need to scan at startup, set this field to 0.

3. Sample file

#/Etc/fstab

/Dev/hda8 swap defaults 0 0

/Dev/hda9/ext2 defaults 1 1

/Dev/hda6/wine vfat defaults, codepage = 936, iocharset = cp936 00

/Dev/hda7/winf vfat defaults, codepage = 936, iocharset = cp936 00

/Dev/hdb/cdrom iso9660 noauto, user 0 0

None/proc defaults 0 0

None/dev/pts devpts gid = 5, mode = 620 00fstab stores important partition-related information, where each row is a partition record, 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 mount nfs 」.

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. /Etc/fstab mainly includes six items:

For example, print the content of the two middle lines, as shown below:
LABEL = // ext3 defaults 1 1
/Dev/sda2/mnt/D/vfat defaults 0 0

Column 1: Device name or device volume name (/dev/sda10 or LABEL = /)

Column 2: Device Mount Directory (for example, the above "/" or "/mnt/D /")

Column 3: device file system (for example, the above "ext3" or "vfat ")

Column 4: mount parameters (see help man mount)
For a mounted device, such as the/dev/sda2 above, you need to change the Mount parameter. you do not need to uninstall the device, but you can use the following command (no mounted device, the remount parameter is invalid)
# Mount/mnt/D/-o remount, ro (change defaults to ro)
To ensure security, you can specify other mount parameters, such:
Noexec, at this time, we only need to re-build the system!
Nodev (device files cannot be mounted)
Nosuid and nosgid (suid and sgid attributes are not allowed)
Nouser)

Column 5: indicates whether to back up data. (0 indicates no backup, 1 indicates backup, and generally the root partition must be backed up)

Column 6: indicates the self-check sequence. (0 indicates no self-check. 1 or 2 indicates self-check. if the root partition is set to 1, other partitions can only be 2.) if you want to enable the system, the system automatically mounts the disk, you can add the following lines on/etc/fstab:
/Dev/hda5/mnt/d vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0
It also solves the problem of garbled characters in Chinese file names. my fstab file is as follows for your reference only:
LABEL =/12/ext3 defaults 1 1
None/dev/pts devpts gid = 5, mode = 620 0 0
None/proc defaults 0 0
None/dev/shm tmpfs defaults 0 0
/Dev/hda4 swap defaults 0 0
/Dev/cdrom/mnt/cdrom iso9660 noauto, owner, kudzu, ro 0 0
/Dev/fd0/mnt/floppy auto noauto, owner, kudzu 0 0
/Dev/hda1/mnt/c vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0
/Dev/hda5/mnt/d vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0
/Dev/hda6/mnt/e vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0
/Dev/hda7/mnt/f vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0
/Dev/hda8/mnt/g vfatexec, dev, suid, rw, umask = 0, iocharset = gb2312, codepage = 936 0 0

Fstab interpretation

To the right:
/Dev/device mount-point type rules dump fsck
1./dev/device: Needless to say, right? For example,/dev/hda1 is a c: disk under M $-Win9x.
2. mount-point: mount point. For example, Mount/dev/hda1 to/mnt/mywinc.
3. type: ext3, vfat,... is the type of the file system to be mounted.
4. rules:
Auto: Automatic mounting upon startup;
Default, noauto: The device is not automatically mounted upon startup;
Nouser: Only root users can be mounted;
Ro: Read-only mounting;
Rw: readable and writable;
User: any user can be attached;
5. dump: backup; 0 indicates never backup, or the number of days since the last backup is displayed;
6. fsck: fsck check sequence at startup. if the value is 0, no check is performed, and "/" is always 1;
Mine is:
/Dev/hda1/mnt/mywinc vfat default 0 0

Load partitions in fstab

Mkdir/mnt/win_c
Vi/etc/fstab
:::: Add :::::
/Dev/hda1/mnt/win_c vfat default, pagecode = 936, iocharset = cp936 00

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.