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 resize2fs command in Linux system

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

Share

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

Next, please follow the editor to study!

Resize2fs

Resize the ext2\ ext3\ ext4 file system to enlarge or reduce the size of the unmounted file system. If the file system is mounted, it can increase the size of the file system, as long as the kernel supports online resizing.

The size parameter specifies the new size of the requested file system. If no unit is specified, the unit of the size parameter should be the file system block size of the file system. The size parameter can be suffixed by one of the following unit numbers: "s", "K", "M", or "G" for 512-byte sectors, gigabytes, megabytes, or gigabytes, respectively. The size of the file system may never be larger than the size of the partition. If the Size parameter is not specified, it defaults to the size of the partition.

The resize2fs program does not manipulate the size of the partition. If you want to expand the file system, you must first ensure that the size of the underlying partition can be extended. If you use the logical volume manager LVM (8), you can use fdisk (8) to delete the partition and recreate it with a larger size, or you can use lvexport (8). When recreating the partition, be sure to use the same boot disk cylinder as before to create the partition! Otherwise, the resizing operation will definitely not work, and you may lose the entire file system. After running fdisk (8), run resize2fs to resize the ext 2 file system to use all the space in the newly expanded partition.

If you want to reduce the ext2 partition, first use resize2fs to reduce the size of the file system. You can then use fdisk (8) to reduce the size of the partition. When reducing the partition size, make sure it is not smaller than the new size of the ext2 file system.

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

1. Grammar

Resize2fs [options] device [size]

Resize2fs [- fFpPM] [- d debug-flags] [- S RAID-stride] device [size]

2. List of options

Option

Description

-ddebug-flags

Turn on the various resize2fs debugging features if they have been compiled into binaries. The debug flag should be calculated by adding the number of required features from the following list:

2, debug block relocation.

4. Debug iNode relocation.

8. Debug mobile inode table.

-f

Enforce, overriding some security checks that are usually enforced.

-F

Flush the buffer of the file system before execution

-M

Shrink the file system to a minimum

-p

Displays the percentage of tasks completed

-P

Displays the minimum value of the file system

-SRAID-stride

The resize2fs program heuristically determines the RAID step size specified when the file system is created. This option allows the user to explicitly specify the RAID step size setting so that it can be replaced by resize2fs.

3. Examples

1) display the minimum sda1

[root@localhost] # resize2fs-P / dev/sda1

Resize2fs 1.41.12 (17-May-2010)

Estimated minimum size of the filesystem: 37540

2) set sdb4 to 1k

[root@localhost ~] # resize2fs / dev/sdb4 1k

Resize2fs 1.41.12 (17-May-2010)

Resize2fs: New size smaller than minimum (373) / / less than the minimum, failed

At this point, the study of "the usage of resize2fs commands in Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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