Disk parameter revision for Linux missing and missing detection

Source: Internet
Author: User

Disk parameter revision for Linux missing and missing detection

Archive representative Device

In Linux, we all know that we can use corresponding files to represent a device. For example,/dev/sdb1 represents the first separator slot of the sdb hard disk. The device uses major and minor to indicate the device to be replaced.

Brw-rw -- 1 root disk 8, 0 May 12 20:16/dev/sda
Brw-rw -- 1 root disk 8, May 12 19:48/dev/sda1
Brw-rw -- 1 root disk 8, 10 October 19:48/dev/sda10
Brw-rw -- 1 root disk 8, 11 Aug 17 19:48/dev/sda11
Brw-rw -- 1 root disk 8, 12 May 12 19:48/dev/sda12
Brw-rw -- 1 root disk 8, 13 Aug 17 19:48/dev/sda13
Brw-rw -- 1 root disk 8, 2 May 12 19:48/dev/sda2
Brw-rw -- 1 root disk 8, 3 Aug 17 19:48/dev/sda3
Brw-rw -- 1 root disk 8, 4 May 12 19:48/dev/sda4
Brw-rw -- 1 root disk 8, May 12 19:48/dev/sda5
Brw-rw -- 1 root disk 8, 6 May 12 19:48/dev/sda6
Brw-rw -- 1 root disk 8, May 12 19:48/dev/sda7
Brw-rw -- 1 root disk 8, 8 Aug 17 19:48/dev/sda8
Brw-rw -- 1 root disk 8, 9 May 12 19:48/dev/sda9
Root @ qeesung-laptop:/media # ll/dev/sdb *
Brw-rw -- 1 root disk 8, 16 May 12 20:16/dev/sdb
Brw-rw -- 1 root disk 8, 17 Aug 17 20:25/dev/sdb1
Brw-rw -- 1 root disk 8, May 12 20:18/dev/sdb2

The Linux kernel identifies the corresponding device through the corresponding major and minor.

Device name Major Minor
/Dev/sdb 8 0-15
/Dev/sdba 8 16-31

Mknod command
This command is mainly used to create a device file (make block or character special files)
Mknod [OPTION]... name type [major minor]
The main types are:
-B block Device
-C char character device
-P pipe Equipment
Example:

Create an MPS queue File

# Mknod pipeFile p
# Echo this is a test line> pipeFile
# Cat pipeFile

--------------------------------------------------------------------------------

Create a block File

# Mknod blockFile B 8 100

--------------------------------------------------------------------------------

Create a character file

# Mknod charFile c 4 100

There will eventually be three files
Brw-r-1 root 8,100 May 12 21:15 blockFile
Crw-r-1 root 4,100 May 12 21:16 charFile
Prw-r-1 root 0 May 12 21:12 pipeFile |

--------------------------------------------------------------------------------

E2label command

In linux, a corresponding label can be specified for each separator slot to indicate the separator slot, which is like a C drive D Drive in windows. If a label is specified for the disk's separator slot, it will be mounted under the/media Directory according to the label name. If no label is specified, the UUID of the split slot will be mounted under the/media directory.

In linux, you can run the e2label command to specify the label of the corresponding separator. The advantage of specifying a label is that the label will not change with the change of the disk file name, we know that the disk mounting order in linux determines the disk file name. For example, if you first Mount SATA disk 1, the device name of Disk 1 is/dev/sda, if you try to mount Disk 1 after attaching SATA disk 2, the disk file of Disk 1 is/dev/sdb... However, even if the disk file name is changed, the corresponding separator label will not change.

Run the e2label command:

E2label/dev/sdb1 "newLabelName"

--------------------------------------------------------------------------------

Tune2fs command

The tune2fs command is very useful. The following are some basic usage instructions:
--L is equivalent to displaying the superBlock content of the troughs of dumpe2fs-h.
--L is equivalent to e2label changing the label of a separator
--J: Convert the ext2 file format to the ext3 file format with logs
For more details, just use man.

--------------------------------------------------------------------------------

Automatic mounting of the file system

We can change the data in/etc/fstab to change the file system that is automatically mounted to the system every time the system is started. The following are the items in the/etc/fstab/file:

In this example, the file system is mounted under the/home directory, and no line of information indicates the file system automatically mounted upon startup. each item is distinguished by space. The specific meaning of each item is:
-File system: The corresponding separator slot, which is the UUID or label name.
-Mount point: the mount point. It must be a directory and the root directory/must take precedence over all file systems.
-Type: File System type
-Options: Mount parameters of the file system, including:

Arg1 Arg2 Description
User Nouser Can a common user mount a file system?
Async Sync Whether the disk is read and written Asynchronously
Auto Noauto Whether it can be automatically mounted is mount-.
Rw Ro Whether the file system is read-only or read/write
Suid Nosuid Whether suid/sgid files and directories are supported

-Dump: Indicates whether to perform dump backup on the file system. 0 indicates no backup, 1 indicates daily backup, and 2 indicates irregular backup.
-Pass: fsck is used to check whether the file system is faulty. 0 indicates no detection. 1 indicates the first check (usually the root directory). 2 indicates that the check is required, it is detected only after 1 Detection!

Now suppose we need to mount the file system/dev/sdb1 to the/media/sdb1 directory in read-only mode when it is started, then we need to write data under/etc/fstab;
/Dev/sdb1/media/sdb1 ext4 ro 1 2
Next, let's try mount-a and find that the file system is automatically mounted to the/media/sdb1 directory in read-only mode, indicating that we have not written an error.
Note: If you do not check whether the entries in the newly added fstab are correctly written and restarted in a rush, you may fail to start the device and enter the single-user mode, in this case, you need to mount-n = o remount. rw/Remount the root directory, and then modify the/etc/fstab file.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.