Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify disk parameters in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Linux how to modify disk parameters, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Under the Linux, we all know that the corresponding file can be used to represent a device. For example, / dev/sdb1 represents the first partition slot of the sdb hard disk, and the device marks the corresponding replacement device through major and minor.

Brw-rw-- 1 root disk 8, May 12 20:16 / dev/sda

Brw-rw-- 1 root disk 8, January 12 19:48 / dev/sda1

Brw-rw-- 1 root disk 8, October 12 19:48 / dev/sda10

Brw-rw-- 1 root disk 8, 11 May 12 19:48 / dev/sda11

Brw-rw-- 1 root disk 8, 12 May 12 19:48 / dev/sda12

Brw-rw-- 1 root disk 8, 13 May 12 19:48 / dev/sda13

Brw-rw-- 1 root disk 8, May 12 19:48 / dev/sda2

Brw-rw-- 1 root disk 8, 3 May 12 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, June 12 19:48 / dev/sda6

Brw-rw-- 1 root disk 8, July 12 19:48 / dev/sda7

Brw-rw-- 1 root disk 8, 8 May 12 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 May 12 20:25 / dev/sdb1

Brw-rw-- 1 root disk 8, 18 May 12 20:18 / dev/sdb2

The linux kernel recognizes the corresponding device through the corresponding major and minor.

Device namemajorminor

/ dev/sdb80-15

/ dev/sdba816-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 block device

-c char character device

-p pipe piping equipment

Examples of use:

Create a new pipe file

# mknod pipeFile p

# echo this is a test line "" pipeFile

# cat pipeFile

Create a new block file

# mknod blockFile b 8 100

Create a new character file

# mknod charFile c 4 100

Eventually, there will be three files.

Brw-r-r- 1 root root 8,100 May 12 21:15 blockFile

Crw-r-r- 1 root root 4,100 May 12 21:16 charFile

Prw-r-r- 1 root root May 12 21:12 pipeFile |

E2label command

Under the linux, each partition slot can be designated a corresponding label to mark the partition slot, which is similar to the C disk D disk under the windows. If label is specified in the partition slot of the disk, it will be mounted under the / media directory according to the name of label. If label is not specified, it will be mounted under the / media directory according to the UUID of the partition slot.

Under the linux, you can specify what the label of the corresponding divider is through the e2label command. One advantage of specifying label is that the label will not change with the change of the disk file name. We know that the mount order of the disk under the linux determines the file name of the disk. For example, if you mount disk 1 first, then the device name of disk 1 is / dev/sda. If you are hanging on disk 2 of SATA, mount disk 1 lags behind. Then the disk file of disk 1 is / dev/sdb. But even if the disk file name is changed, the corresponding partition slot label will not change.

Use the e2label command:

E2label / dev/sdb1 "newLabelName"

Tune2fs command

The tune2fs command is of great use. Here are some basic uses

-- l is equivalent to dumpe2fs-h showing the superBlock content of the separator.

-- L is equivalent to e2label changing the label of a divider.

-- J converts ext2 file format to ext3 file format with logs

It is better to man for more specific usage.

Automatic mounting of file system

We can change the file system that is mounted automatically every time the system boots by changing the data under / etc/fstab. Here is what's in the / etc/fstab/ file:

The file system in this example is mounted under the / home directory. There is no line of information indicating the file system that is automatically mounted on boot. Each item is distinguished by a space. The specific meaning of each item is:

-file system: the corresponding separator slot, which is the name of UUID or label

-mount point: Mount point, must be a directory, and root directory / must take precedence over all file system mounts

-type: type of file system

-options: the mount parameters of the file system, including:

Arg1arg2 description

Can ordinary usernouser users mount the file system?

Whether the asyncsync disk reads and writes asynchronously

Whether autonoauto can be mounted automatically, that is, mount-a

Is the rwro file system read-only or read-write?

Does suidnosuid support suid/sgid files and directories?

-dump: indicates whether to back up the file system with dump: 0 indicates no backup, 1 indicates daily backup, and 2 indicates irregular backup

-pass: use fsck to check whether there is a problem with the file system. 0 indicates no detection, 1 indicates the first detection (usually the root directory), 2 means it needs to be tested, but only after 1 detection!

Now suppose we need to automatically mount the file system / dev/sdb1 to the / media/sdb1 directory as read-only at boot time, then we need to write under / etc/fstab

/ dev/sdb1 / media/sdb1 ext4 ro 1 2

Next, we try mount-an and find that the file system is automatically mounted as read-only to the / media/sdb1 directory, indicating that we have not made a mistake.

Note: if you rush to restart without checking whether the entries in the newly added fstab are written correctly, you may not be able to boot successfully and enter single-player mode, at this time you need to mount-n = o remount.rw / a pair of root directories to mount again, and then we will modify the / etc/fstab file.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report