CentOS attached hard disk
As we have said before, the mount point is a directory, and this directory is the entry to the disk partition. But before you mount the file, you 'd better determine the following:
A single file system should not be repeatedly mounted to different mount points (directories;
Multiple File Systems should be mounted in a single directory;
The directory to be used as the mount point should theoretically be empty directories.
Especially in the last two points above, if the directory you want to mount is not empty, after the file system is mounted, the contents in the original directory will disappear temporarily. For example, assume that your/home is in the same file system as the root directory (/), and there are two directories:/home/test and/home/heetian. Then you add a new hard disk and mount it directly under/home. After you mount the disk, the/home directory displays information about the newly mounted partitions. As for the original test and heetian directories, they will be temporarily hidden. Note! It is not overwritten. Instead, it is temporarily hidden. When the new partition is detached, the items under/home will return to normal.
How to enable automatic file system mounting upon startup
Think about whether the mounted file system is available after the system is restarted?
Let's test:
Reboot: Press reboot and press Enter. In about 1 minute, use putty to connect to Linux.
After the restart, let's take a look. Is sdb4 still absent?
Why? I can't see sdb4. Do I have to manually mount it again when I restart the system? So how can we make the file system mount automatically? You need to write the configuration file. The path of the configuration file is/etc/fstab.
Let's run the cat command to check what is in it?
Have you found that there are six columns in total? What is each column? It's just a few.
Fs_spec: defines the device or remote file system where the file system to be loaded is located.
Fs_file: this field describes the directory points to be mounted to the file system.
Fs_type: file system type, for example, ext2
Fs_options: specify that the file system to which the device is mounted is a specific parameter option. Multiple parameters are separated by commas (,).
Fs_dump: it is a backup command. It does not need to be set to 0. It will be mentioned after the backup is set to 1.
Fs_pass: whether the disk is verified at startup. If the value is 0, the disk is not verified. If the value is 1, the disk is verified. Usually/is set to 1.
How can I set automatic mounting/dev/sdb4 at startup?
Open it with vim/etc/fstab (We will explain it in subsequent courses DURING vim)
Press the "I" Key, press the top, bottom, left, right, move the cursor to the end, and press Enter.
Add a row:/dev/sdb4/mnt/sdb4 ext2 defaults 0 0
Press the ESC key in the upper left corner of the keyboard. Enter ": x" and press enter to save the settings.
The modified/etc/fstab is as follows:
Let's try reboot again?
It is automatically mounted. Mom no longer needs to worry about me restarting the system and cannot mount the file system !!
How to mount an iso Image File
Many times we need to use iso images. How can we use iso images?
Because there is no iso image file in our system, we will create one first. You do not need to understand the meaning of the command:
We use mkisofs to create an iso9660 image file:
Mkisofs-o heetian. iso/tmp
Now that the iso file is ready, let's mount it and use it: How do we mount it to/media/iso:
Mount-o loop-t iso9660./heetian. iso/media/iso/
This command is used to mount the "maneuver device" and the iso image-t, which is specified as the iso660 optical disc.