Linux Boot Mount Setup Fstab__linux

Source: Internet
Author: User

The use of ' fstab '

'/etc/fstab ' is an important configuration file for the ' Mount ' command. You can "root" through the ' Diskdrake ' (Mandrake Linux Control Center-mount point), or modify the file with the editor.

'/etc/fstab ' has several uses:

*

Decide which media to mount automatically when you turn on the boot;
*

Specifies the optional, mount point for each media mount;
*

The system is used to mount several virtual file systems.

Mounting media at Power-on

By default, all media listed in ' Fstab ' will be mounted at boot time. If one of the media is out of the question, ' mount ' displays an error message and then continues to the next entry. Note that this is also valid for network media, such as NFS or SMB sharing. If you want to cancel the automatic mount on the boot, you have to '/etc/fstab ' to provide the appropriate item ' noauto ' option.
Specify the optional and mount points for Mount

If you read the previous article, you already know that the Mount command has two options: General options, special options for the file system.

Special options are available for specific file systems. If you provide special options for an entry in ' Fstab ' (such as the umask=0 for the Windows FAT file system), only the media for the appropriate file system can be mounted through the entry. If you want to mount another file system's media, either set that option again, or create a separate entry.

Specifying the load point has the benefit of omitting the device file name at the time of Mount/unload.

Mount Mount_point

You will find the entry for the corresponding loading point in '/etc/fstab ' and mount it according to the preset setup.
Virtual file system

Depending on the system configuration, ' Fstab ' contains entries for the virtual file system, which do not list the corresponding device files. No matter what, please do not move these entries.

*

' Proc ' is a "process tree" that provides information about the system;
*

' pts ' enables ' pseudo terminal support ' (pseudo terminal support), which is a compatible feature of Unix;
*

' Shm ' opens the POSIX shared memory, with only a small number of programs that will be used without any negative impact.

* Section index * TOP
* Introduction to the entries in ' Fstab '
Local fixed-system partitions

As you can see, there are already several entries for the system partition (such as '/') in '/etc/fstab '. Take this as an example:

/DEV/HDA3/EXT2 Defaults 1 1

The syntax is:
/DEV/HDA3/EXT2 Defaults 1 1
Device_name mount_point file_system options ' dumpe2fs ' fsck '

Here is the device name, mount point (/), File System (EXT2) of the media (partition of the hard disk).
Defaults includes several options for ' Mount ': RW can read and write, suid allow set user identifier (set-user-identifier), exec allowed to run the program, auto Boot on automatically mount, nouser only ' root ' right to uninstall, Async allows disk latency access (caching).

The last two options are the flags used by the File System tool ' DUMPE2FS ' and ' fsck '.
The ' Dump ' field can be set to ' 1 ' (enabled) and ' 0 ' (disabled). Because the program that backs up the Ext2/ext3 file system uses ' dump ', the file system EXT2/EXT3 entries are set to ' 1 ' and all other entries are ' 0 '.
The ' fsck ' field can be set to ' 0 ' (without checking the file system), ' 1 ' (check first), ' 2 ' (check). All non-Linux file systems, removable and network media, the virtual file system is set to ' 0 ', because the root partition is mounted (then checked), the '/' entry is set to ' 1 ', and all other non removable and Linux file system local media are set to ' 2 '.
Removable media

Removable data stores, such as CDs, require different options (if you do not use ' Supermount '):

/dev/cdrom/mnt/cdrom Auto User,noauto,exec,ro 0 0

User allows users to mount, uninstall, or only ' root ' has this right. Note that this option closes exec, and you have to specify EXEC after user option, so that the user can run the program on the mounted media, which is consistent with the above example. Noauto means this option is required for some removable media when the media is not mounted on the drive. Ro-mounted Media "Read Only" (Read-only). ' Dump ' and ' fsck ' are closed.

Although the disc is not set to mount automatically, because of this entry in '/etc/fstab ', the next mount becomes simple: put the disc in and enter:

Mount/mnt/cdrom

The ' Mount ' will find the entry in '/etc/fstab ' that is associated with the mount point and take the options listed, so you can save some input. In KDE, when you put the disc in, you can automatically run the Mount command by clicking on that disc icon with your mouse.
The disc that is mounted will lock the optical drive, if you want to eject the disc, you have to uninstall: Umount/mnt/cdrom.

To configure other removable media, you need to know their device file name, and you can look at devices.txt or read articles about Removable storage devices.
Local fixed non-system partitions

What does the entry for the ms-windows partition look like? Suppose it's the second partition on the first IDE hard disk, and you want to mount it automatically:

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

If it is a Windows NT NTFS partition, replace ' VFAT ' with ' NTFS '. Note that currently under Linux, you can only read NTFS's file system and not write it.

The ' umask ' option will turn off permission monitoring, without which, only ' root ' can access files on the device. When you move a file to this media, because you cannot set permissions, an annoying error message is displayed, and you can use ' quiet ' to not display these irrelevant information.

If the file name in the Windows partition looks strange, you'll have to add two more options: ' Iocharset ' and ' codepage '. By default, ' Mount ' uses ' iso8859-1 ' character set and codepage 437. After modification, you can implement character conversions. Man charsets lists the available character sets, and setting codepage to 850 (codepage=850) solves some of the problems.

(Note: To display Simplified Chinese, you have to add charsets=gb2312,codepage=936)


A partition is mounted on an existing directory that may not be empty, but the previous contents of this directory will not be available when it is mounted.
This is also true for the mounting of file systems built by other operating systems. However, it should be understood that the format of the file system used by the CD, floppy disk, and other operating systems is different from the file system format used by Linux. The disc is ISO9660, the floppy disk is FAT16 or Ext2;windows NT is FAT16, NTFS;WINDOWS98 is FAT16, fat32;windows2000, and Windows XP are FAT16, FAT32, NTFS. Before you mount, see if Linux supports the file system format you want to mount.

Use Mount command when mounting:
Format: Mount [-parameters] [device name] [Mount Point]

Some of the commonly used parameters are
-t< File System Type > Specifies the file system type of the device, which is common:
Minix Linux The earliest file system used
Ext2 Linux currently used in the file system
Msdos MS-DOS FAT is the FAT16
The common FAT32 of VFAT Windows98
NFS Network File System
ISO9660 CD-ROM standard file system
File systems for NTFS Windows NT 2000
HPFS OS/2 File System
Auto Auto Detect file system
-o< Options > Specify options for mounting file systems. Some can also be used in/etc/fstab. Commonly used to have
CODEPAGE=XXX code page
Iocharset=xxx Character Set
RO is mounted as read-only
RW mounts in read-write mode
Nouser makes it impossible for general users to Mount
User can mount devices for general users

As a reminder, the Mount command does not have the capability to mount the point, so you should make sure that the mount point already exists when you execute the load command. (Don't understand.) The point is that you have to mount the file system, first of all to build a directory. That's OK. )

Example: Windows98 is mounted on the HDA1 partition, and there are floppy disks and discs on the computer that need to be mounted.
# Mk/mnt/winc
# Mk/mnt/floppy
# Mk/mnt/cdrom
# mount-t Vfat/dev/hda1/mnt/winc
# mount-t Msdos/dev/fd0/mnt/floppy
# mount-t Iso9660/dev/cdrom/mnt/cdrom
You can now access the/MNT/WINC and other directories to read and write these file systems.

To ensure that the last two lines of command are not faulted, make sure that there is a disk in the floppy drive and CD drive. (If disk slices of hard disk can be changed often at any time, I think I will not make such a mistake:->)
If you have a Chinese file name in your Windows98 directory, use the command above to mount a stack of garbled characters. This will use the CodePage iocharset option in the-o argument. CODEPAGE specifies the code page for the file system, the Simplified Chinese code is 936;iocharset the specified character set, and the Simplified Chinese is generally cp936 or gb2312.

When the mounted file system Linux is not supported, mount a certain error, such as the Windows2000 NTFS file system. You can recompile the Linux kernel to gain support for the filesystem. About recompiling the Linux kernel, it's not here to say.

Automatic mount

It is obviously too cumbersome to run the Mount command on every boot access windows partition, why not use the Mount command to access other Linux partitions.
In fact, every time the boot, Linux automatically will need to mount the Linux partition mount. So is it possible to configure Linux to mount the partitions that we want to mount, such as Windows partitions, to enable the file system to mount automatically when it is started?
This is perfectly possible. There is a fstab file in the/etc directory that lists the file systems that are automatically mounted when Linux is powered on. My/etc/fstab file is as follows:

/DEV/HDA2/EXT3 Defaults 1 1
/dev/hda1/boot ext3 Defaults 1 2
None/dev/pts devpts gid=5,mode=620 0 0
NONE/PROC proc Defaults 0 0
NONE/DEV/SHM TMPFS Defaults 0 0
/dev/hda3 Swap Defaults 0 0
/dev/cdrom/mnt/cdrom iso9660 noauto,codepage=936,iocharset=gb2312 0 0
/dev/fd0/mnt/floppy Auto Noauto,owner,kudzu 0 0
/dev/hdb1/mnt/winc vfat defaults,codepage=936,iocharset=cp936 0 0
/dev/hda5/mnt/wind vfat defaults,codepage=936,iocharset=cp936 0 0

In the/etc/fstab file, the first column is the device name of the mounted file system, the second column is the mount point, the third column is the mounted file system type, the fourth column is the mounted option, and the options are separated by commas. The 56th column does not know is what meaning, also hope master advice.

In the last two lines I manually added the c;d disk under Windows, adding codepage=936 and iocharset=cp936 parameters to support the Chinese filename. The parameter defaults actually contains a set of default parameters:

RW mounts in readable and writable mode
SUID Open User ID and group ID settings bit
Dev can interpret character or block devices on a file system
EXEC executable binaries
Auto Mount automatically
Nouser makes it impossible for general users to Mount
Async performs an input-output operation of the file system in a unsynchronized manner

As you can see in this list, the optical drive and floppy drive are not mounted automatically, and the parameters are set to Noauto. (If you want to set up automatic mount, you want to make sure that every time you turn on the CD-ROM and floppy drive must have a disk, hehe.) )

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.