linux - boot automatically mount the hard drive [turn]

Turn: http://c.biancheng.net/view/900.html

 

After understanding the mount command, the reader might ask, how the system automatically mount the hard disk at boot time, it is how to know which partition is the need to mount it?

Very simple, Linux  via / etc fstab configuration / file to determine this information, the configuration file readable to all users, but only the root user has the right to modify this file. That is, if we want to achieve power on automatically mount a hardware device, only need to use this device to add as root in / etc / fstab file.

First of all, we see it open this file, execute the following command:

[the root @ localhost ~] # VI / etc / fstab
the UUID = c2ca6f57-b15c-43ea-bca0-f239083d8bd2 / ext4 Defaults. 1. 1
the UUID = 0b23d315-33a7-48a4-bd37-9248e5c44345 / Boot. 1 2 ext4 Defaults
the UUID = 4021be19-2751 Defaults swap swap-383368c39edb -4dd2-98cc 0 0
# only three is a real hard disk partition, the following are virtual file system or swap
tmpfs / dev / tmpfs SHM Defaults 0 0
devpts / dev / PTS devpts gid = 5 , MODE = 0 620. 0
the sysfs / SYS sysfe Defaults 0 0
proc / proc proc 0 0 Defaults

At present, we can ignore tmpfs, devpts, sysfs and proc these lines, they are special equipment and shared memory, a terminal window, device information and associated kernel parameters.

It can be seen in the fstab file, each row of data is divided into six fields, their meanings are:

  1. To mount partition device file name of each file system or UUID (used to refer to the device name);
  2. Mount point;
  3. Type of file system;
  4. Various mount options;
  5. Specifies whether the partition is a backup dump;
  6. Detecting whether the specified partition is fsck;

Below, we explain one by one.

Meaning / etc / fstab file of each field

First introduced the first field, what is the UUID it? I.e. UUID Universally Unique Identifier, is a 128 bit number, it is understood that the hard disk ID, and UUID generated automatically by the system management.

This field CentOS 5.5 system is written label name or file name of the partition device partition, now turned into a hard disk UUID. The benefit of this is when the hard disk to increase in the new partition, or change the order of the partitions, or after a kernel upgrade will still be able to ensure that the partition is properly loaded, without incurring start obstacles.

So, each partition UUID in the end what is it? With dumpe2fs command (follow-speak) you can view the specific implementation of the command is as follows:

[root@localhost ~]# dumpe2fs /dev/sdb5
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name: test_label
Last mounted on: <not available>
Filesystem UUID: 63f238f0-a715-4821-8ed1-b3d18756a3ef
#UUID
...省略部分输出...

In addition, you can also view each hard disk to determine the UUID UUID of the linked file name, the command is as follows:

[root@localhost ~]# ls -l /dev/disk/by-uuid/
总用量 0
Irwxrwxrwx. 1 root root 10 4 月 11 00:17 0b23d315-33a7-48a4-bd37-9248e5c44345
-> ../../sdal
Irwxrwxrwx. 1 root root 10 4 月 11 00:17 4021 be19-2751 -4dd2-98cc-383368c39edb
-> ../../sda2
Irwxrwxrwx. 1 root root 10 4 月 11 00:17 63f238f0-a715-4821-8ed1-b3d18756a3ef
-> ../../sdb5
Irwxrwxrwx. 1 root root 10 4月 11 00:17 6858b440-ad9e-45cb-b411 -963c5419e0e8
-> ../../sdb6
Irwxrwxrwx. 1 root root 10 4月 11 00:17 c2ca6f57-b15c-43ea-bca0-f239083d8bd2
-> ../../sda3


The second field on the meaning of the mount point, we have " Linux mount " and " Linux Mount command " to explain the chapter, so will not repeat them here. But it needs to be emphasized that it must be a mount point already established an empty directory.

The third field is the file system name, CentOS 6.3 is the default file system should be ext4.

The fourth field is the mount parameters, consistent with the specifications of the mount and the mount command.

The fifth field indicates "whether the specified partition backup dump", 0 on behalf of no backup, 1 for backup, 2 for occasional backup.

The sixth field indicates "whether the specified partition is detected fsck", 0 represents not detected, other priority numbers represent detected higher priority than 2 to 1. So the first detection zones 1, 2 and then detection zones. Priority 1 is a general partition, other partitions are priority 2.

Configuration / etc / fatab file

Able to read this document, right? We put / dev / sdb5 and / dev / sdb6 join two partitions / etc / fstab file, execute the following command:

[root@localhost ~]# vi /etc/fstab
UUID=c2ca6f57-b15c-43ea-bca0-t239083d8bd2 ext4 defaults 1 1
UUID=0b23d315-33a7-48a4-bd37-9248e5c44345 I boot ext4 defaults 1 2
UUID=4021be19-2751-4dd2-98cc-383368c39edb swap swap defaults 0 0
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 proc defaults 0 0
/dev/sdb5 /disk5 ext4 defaults 1 2
/dev/sdb6 /disk6 ext4 defaults 1 2

It can be seen here and did not use UUID partition, but the partition is written directly to the device file name, it is also possible. However, if you do not write UUID, we should note that, after modifying the disk order, / etc / fstab file should be changed accordingly.

Here masterpieces directly using the device file for the file first field partition, of course, you can write UUID partition. But more advanced UUID, device file name slightly simpler.

So far, the partition on the establishment of complete, as long as the next reboot, to test whether the system can start properly on it. As long as / etc / fstab file modification correct, there would not be any problems

Guess you like

Origin www.cnblogs.com/clairedandan/p/11527727.html