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

The usage of the Linux basic command tune2fs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the relevant knowledge of "the usage of the Linux basic command tune2fs". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Tune2fs

Tune2fs allows system administrators to adjust various tunable file system parameters on Linux ext2, ext3, or ext4 file systems. The current values of these options can be displayed using the-l option or by using the dumpe2fs (8) program.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Tune2fs [options] device

Tune2fs [- l] [- c max-mount-counts] [- e errors-behavior] [- f] [- I interval-between-checks] [- j] [- J journal-options] [- m reserved-blocks-percentage] [- o [^] mount-options [ ...] [- r reserved-blocks-count] [- s sparse-super-flag] [- u user] [- g group] [- C mount-count] [- E extended-options] [- L volume-name] [- M last-mounted-directory] [- O [^] feature [,...]] [- T time-last-checked] [- U UUID] device

2. List of options

Option

Description

-l

Display the details of the device

-c max-mount-counts

Adjust the maximum number of mounts before checking the file system. If the maximum mount count is 0 or-1 Magi e2fsck (8) and the kernel ignores the number of times the file system is mounted. If you are forced to check the mount count of a file system, you will avoid checking all file systems at once when using a journaled file system.

-C mount-count

Sets the number of times the file system is mounted, and if set to a greater value than the max-mount-counts parameter set by the-c option, e2fsck (8) will check the file system the next time it restarts.

-e error-behavior

Change the behavior of the kernel code when an error is detected. In any case, a file system error will cause e2fsck (8) to check the file system on the next boot. The error behavior can be one of the following:

Continue, continue with the normal execution.

Remount-ro, which is mounted again as read-only.

Panic to generate kernel panic.

-E extended-options

Set extension options for the file system. Extension options are comma-separated and can be parameterized using the equal sign ('=') symbol. The following extension options are supported:

Stride=stride-size to configure a file system with step-size file system blocks for the RAID array. This is the number of blocks read or written to disk before moving to the next disk. This mainly affects the placement of file system metadata, such as bitmaps, at mke2fs (2) time to avoid placing them on a single disk, which can damage performance. It can also be used by block allocators.

Stripe_width=stripe-width, which configures the file system for the RAID array, the file system block for each bandwidth. This is usually stride-size * N, where N is the number of data disks in the RAID (for example, RAID 5 Numeric 1 Magi raid 6 Num2). This allows the block allocator to prevent read-modify-write (if possible) parity in RAID bars when writing data.

Hash_alg=hash-alg, which sets the default hash algorithm for file systems with hash b-tree directories. Valid algorithms accepted are: legacy, half_md4, and tea.

Mount_opts=mount_option_string, which sets a default set of mount options that will be used when mounting the file system. Unlike the default bitmask-based mount option specified with the-o option, mount_option_string is any string with a maximum length of 63 bytes, stored in a super block. The ext 4 file system driver first applies the default options based on the bitmask, and then parses the mount_option_string before parsing the mount options passed from the mount (8) program. This superblock setting is only executed in kernels above 2.6.35, while the ext2 and ext3 file system drivers are not executed at all.

Test_fs, set a flag in the filesystem superblock to indicate that it can be mounted using experimental kernel code, such as the ext4dev filesystem.

^ test_fs, clear the test_fs flag and instruct to mount the file system using only the production-level file system code.

-f

Enforcement. This option is useful when removing the Has_Journal file system feature from a file system that has external logs (or is so corrupted that it appears to have external logs) and external logs are not available.

-g group

Sets a group that can use reserved file system blocks. The group parameter can be a numeric gid or a group name. If a group name is given, it is converted to a numeric gid before it is stored in the super block.

-I interval-between-checks [d | m | w]

Adjusts the maximum time between two file system checks. No suffix or d interprets the numeric interval check as days, m for months and w for weeks. A value of zero disables time-related checks. It is strongly recommended that-c (mount-count-dependent) check or-I (time-dependent) check be enabled to force a regular and complete e2fsck (8) check of the file system. Failure to do so may result in file system corruption (due to disk, cable, memory, or kernel errors) and ignored, resulting in data loss or corruption.

-j

"add ext3 logs to the file system, and if the-J option is not specified, the default log parameter is used to create logs of the appropriate size (the size of a given file system) stored in the file system." Note that you must use a kernel with ext3 support to actually use logs.

"if this option is used to create logs on an installed file system, an immutable file, the log, is created in the top-level directory of the file system, because it is the only secure way to create a log inode when the file system is mounted." Although the ext 3-day log is visible, it is not safe to delete it or modify it when you install the file system; therefore, the file is marked as immutable. When checking an unmounted file system, e2fsck (8) automatically moves the .Journal file to the invisible reserved log inode. For all file systems except the root file system, this should happen automatically and naturally in the next restart cycle. Because the root file system is read-only, you must run e2fsck (8) from the rescue floppy disk to complete this conversion.

-J journal-options

Override the default ext 3-day log parameter. The journal options are comma-separated and can be parameterized using the equal sign ('=') symbol. The following logging options are supported:

Size=journal-size, create a log stored in the file system, the size journal-size. The size of the log must be at least 1024 file system blocks (1MB if 1k blocks are used or 4MB if 4k blocks are used). And there may be no more than 102400 file system blocks. There must be enough free space in the file system to create logs of this size.

Device=external-journal, attach the file system to the log block device located on the external log. The external journal_dev external-journal must have been created with the following command "mke2fs-O log". Note that the external log must be formatted with the same block size as the file system that will be used. In addition, although multiple file systems are supported for attaching to a single external log, the Linux kernel and e2fsck (8) do not currently support sharing external logs. In addition to specifying the device name directly, you can also specify external logs through LABEL=label or UUID=UUID to locate external logs through volume labels or UUID stored in the ext2 superblock at the beginning of the log. Use dupe2fs (8) to display the volume label and UUID of the log device.

There can be only one size and device.

-L volume-label

Sets the file system volume label. The ext2 file system label can be up to 16 characters long; if the volume label exceeds 16 characters, tune2fs truncates it and prints a warning. Volume labels can be used by mount (8), fsck (8), and / etc/fstab (5) (and possibly others) by specifying LABEL=volume_label instead of block-specific device names such as / dev/hda 5.

-m reserved-blocks-percentage

Sets the percentage of file systems that can only be allocated by privileged processes. Some file system blocks are reserved for use by privileged processes to avoid file system fragmentation and to allow system daemons, such as syAdd.1-d (8), to continue to run correctly after unprivileged processes are prevented from writing to the file system. In general, the default percentage of reserved blocks is 5%.

-M last-mounted-directory

Set the last mount directory

-o [^] mount-option [,...]

Sets or clears the specified default mount options in the file system. The default mount option can be overridden by the mount option specified in "/ etc/fstab" (5), or mount (8) can be overridden on the command line argument. The older kernel may not support this feature; in particular, the kernel before 2.4.20 will almost certainly ignore the default mount option field in the superblock. You can clear or set multiple mount options by separating them with commas. Mount options prefixed with the insert character ('^') are cleared in the super block of the file system; mount options with no prefix characters or with the prefix'+ 'are added to the file system. You can use tune2fs to set or clear the following mount options:

Debug,bsdgroups,user_xattr,acl,uid16,journal_data,journal_data_ordered,journal_data_writeback,nobarrier,block_validity,discard,nodelalloc

-O [^] feature [,...]

Sets or clears the file system properties specified in the file system (options). Multiple file system properties can be cleared or set by separating properties with commas. File system properties prefixed with the insert character ('^') are cleared in the super block of the file system; file system properties without prefix characters or prefixed with'+ 'are added to the file system. You can use tune2fs to set or clear the following file system properties: dir_index,filetype,flex_bg,has_journal,large_file,resize_inode,sparse_super,uninit_bg.

-r reserved-blocks-count

Set the number of reserved file system blocks

-T time-last-checked

Use e2fsck to set the time when the file system was last checked. The time is interpreted using the current (local) time zone. This is useful in scripts that use the logical volume manager to take consistent snapshots of the file system, and then check the file system in idle time to make sure it is not corrupted due to hardware problems, and so on. If the file system is clean, this option can be used to set the time of the last check on the original file system. The format of the last check is the international date format, with an optional time specifier, YYYYMMDD [HH [mm [SS]. The keyword Now is also accepted, in which case the last check time is set to the current time.

-u user

Sets the user who can use reserved file system blocks. The user can be a uid or a user name. If a user name is given, convert it to a numeric uid and store it in a super block.

-U UUID

Sets the universal unique identifier (UUID) of the file system to UUID. The format of UUID is a series of hexadecimal digits separated by hyphens, such as "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may also be one of the following:

Clear, clear UUID.

Random to generate a random UUID.

Time, which produces a time-based UUID.

3. Examples

1) View the details of sdb4

[root@localhost ~] # tune2fs-l / dev/sdb4

Tune2fs 1.41.12 (17-May-2010)

Filesystem volume name: hello

Last mounted on:

Filesystem UUID: e2a0cb30-f3ca-47de-92b8-780296960d93

...

First inode: 11

Inode size: 128

Default directory hash: half_md4

Directory Hash Seed: 4930bf0f-771e-4940-9255-bee40d138079

2) set the maximum number of mounts

[root@localhost ~] # tune2fs-c 30 / dev/sdb4 / / set the maximum number of mounts

Tune2fs 1.41.12 (17-May-2010)

Setting maximal mount count to 30

You have new mail in / var/spool/mail/root

[root@localhost ~] # tune2fs-l / dev/sdb4 / / View details

Tune2fs 1.41.12 (17-May-2010)

Filesystem volume name: hello

Maximum mount count: 30 / / the maximum number of mounts has been modified to 30

Directory Hash Seed: 4930bf0f-771e-4940-9255-bee40d138079

[root@localhost ~] #

This is the end of the introduction to "the usage of the Linux basic command tune2fs". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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