Some times when new partitions are partitioned under Linux, these partitions need to be set to auto-mount on boot, otherwise Linux will not be able to use the newly created partition. The/etc/fstab file is responsible for configuring the partitions that are automatically mounted when Linux is powered on.
The file structure of Windows is a multi-side tree structure, the top of which are different disks (partitions), such as: c,d,e,f, etc. The file structure of Linux is a single, tree-like structure. The top is the root directory, i.e./. Under the root directory, it is divided into subdirectories, including/bin,/boot,/dev,/etc,/home,/lib,/media,/mnt,/opt,/proc,/root,/sbin,/tmp,/usr and/var.
The disk Linux partition must be mounted to a specific directory in the directory tree for Read and write operations, and Fstab is responsible for this configuration. Obviously, the root directory is where all Linux files and directories reside, and the previous disk partition needs to be mounted. As mentioned above, Linux partition switching also requires a separate partition, so installing a Linux requires a minimum of two partitions. (In fact, it is possible to install Linux using only one partition, and if the physical memory of the computer is large enough, the swap partition is not required)
This article will take a typical Debian system as an example. Open/etc/fstab File
1 |
[[email protected] ~] # vi /etc/fstab |
By default, the current partition configuration is already in Fstab, and the content might look similar:
# <file system> <mount point> <type> <options> <dump> <pass>
PROC/PROC proc Defaults 0 0
/DEV/HDA1/EXT3 Errors=remount-ro 0 1
/swapfile swap swap defaults 0 0
/dev/hdc/media/cdrom0 udf,iso9660 User,noauto 0 0
As can be seen from the above, the/DEV/HDA1 partition of the system is mounted in the root directory, and the file system is ext3. In addition, there are special "partitions" such as proc, swap, and/DEV/HDC are mounted as optical drives in the/MEDIA/CDROM0
Therefore, if you want to mount the new partition/dev/hda5 in the/home/new directory, simply add a row to the Fstab file:
/dev/hda5/home/new ext3 Default 01
Can.
The first column can be the actual partition name, or it can be the volume label (lable) of the actual partition.
If the disk is a SATA interface and has multiple disks, each disk is marked as/dev/hda,/dev/hdb,/DEV/HDC, and so on, and each disk's partition is marked as/DEV/HDA1,/dev/hda2, and so on.
If the disk is a SCSI type, multiple disks are marked as/DEV/SDA,/dev/sdb, and so on. Partitioning is the same.
If you use a label to represent it, the format is as follows:
The second column is the mount point.
The mount point must be a directory that currently exists, and for compatibility, it is a good idea to set its permissions to 777 after creating the target directory that needs to be mounted to open all permissions.
The third column is the file system type for this partition.
Linux can use types such as ext2, ext3, and so on, and this field must be the same type used when formatting the partition. You can also use Auto as a special syntax to enable the system to automatically detect the partition type of the target partition. Auto is typically used to mount a removable device.
The fourth column is the Mount option to set the mounted parameters.
Common parameters are as follows:
Auto : The system mounts automatically, Fstab is this option by default
defaults: rw, Suid,dev, exec, auto, Nouser, and async.
noauto Boot does not mount automatically
Nouser Only super users can mount
ro Mount by read-only permission
RW mount by Read writable permission
User can mount
Please note that the optical drive and floppy drive can only be mounted when the media is installed, so it is noauto
The fifth column is the dump backup setting.
When the value is set to 1 o'clock, the dump backup program is allowed to be backed up and set to 0 o'clock, ignoring the backup operation;
The sixth column is the fsck disk check setting.
Its value is in one order. When its value is 0 o'clock, never check; the/root directory partition is always 1. Other partitions start at 2, the smaller the number, the first check if the number of two partitions is the same.
When the file is modified and saved, the restart server takes effect.
(Copyright notice: Part of this article refers to the 51CTO operating system channel "Linux partition scheme, file structure and mount")
Transferred from: http://blog.sina.com.cn/s/blog_6ce9e88701014jgl.html
Linux Fstab Automatic Mount partitioning tutorial