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

LVM enlarges and shrinks partitions, repeats reduced partitions, reports errors and fixes them

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

Share

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

The installation of LVM and the online growth of LVM are relatively simple, and the partition of LVM has more offline shrinking pits.

To reduce the size of the LVM device to / dev/mapper/test-lv_test to 200m

Step 1: unmount the device (unmounting is required when reducing the file system. Neither the file system nor the resize tool supports online reduction. )

Umount / dev/mapper/test-lv_test

Step 2: perform a file system check (check the integrity of the partition first. )

Fsck-f / dev/mapper/test-lv_test

Step 3: resize the file system (reduce the file system to 200m)

Resize2fs / dev/mapper/test-lv_test 200M

Step 4: narrow the partition

Lvreduce-L 200m / dev/mapper/test-lv_test reduces the partition to 200m

PS: parameter:-200m reduced by 200m, parameter: 200m reduced to 200m

[root@master ~] # mkfs.ext3 / dev/mapper/test-lv_test

Mke2fs 1.41.12 (17-May-2010)

File system label =

Operating system: Linux

Block size = 1024 (log=0)

Chunk size = 1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

128016 inodes, 512000 blocks

25600 blocks (5.00%) reserved for the super user

First data block = 1

Maximum filesystem blocks=67633152

63 block groups

8192 blocks per group, 8192 fragments per group

2032 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode table: complete

Creating journal (8192 blocks): complete

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first. Use tune2fs-c or-i to override.

[root@master ~] # mount / dev/mapper/test-lv_test / aas/

1.lvm expands 200m disk usage space online

[root@master aas] # lvextend-L + 200m / dev/mapper/test-lv_test

Extending logical volume lv_test to 700.00 MiB

Logical volume lv_test successfully resized

The appearance of this successfully keyword represents a successful expansion of space.

Then use the df command to see what happens when the space increases.

[root@master aas] # df-h / dev/mapper/test-lv_test

two。 Refresh the size of the new lv with the resize2fs command

[root@master aas] # resize2fs / dev/mapper/test-lv_test

Resize2fs 1.41.12 (17-May-2010)

Filesystem at / dev/mapper/test-lv_test is mounted on / aas; on-line resizing required

Old desc_blocks = 2, new_desc_blocks = 3

Performing an on-line resize of / dev/mapper/test-lv_test to 716800 (1k) blocks.

The filesystem on / dev/mapper/test-lv_test is now 716800 blocks long.

[root@master aas] # df-h / dev/mapper/test-lv_test

II. Steps for LVM to reduce partition size offline

If you miss it in the middle of the strict steps, you will report an error: bad blocks, which are difficult to repair, and need to be formatted after the size is restored.

Check the disk usage with the df command

[root@master /] # umount / dev/mapper/test-lv_test

[root@master /] #

[root@master /] # fsck-f / dev/mapper/test-lv_test

Fsck from util-linux-ng 2.17.2

E2fsck 1.41.12 (17-May-2010)

Step 1: check inode, block, and size

Step 2: check the directory structure

Step 3: check directory connectivity

Pass 4: Checking reference counts

Step 5: check the cluster profile information

/ dev/mapper/test-lv_test: 12Compare 178816 files (0.0% non-contiguous), 33358Compare 716800 blocks

[root@master /] #

[root@master /] # fsck-f / dev/mapper/test-lv_test

Fsck from util-linux-ng 2.17.2

E2fsck 1.41.12 (17-May-2010)

Step 1: check inode, block, and size

Step 2: check the directory structure

Step 3: check directory connectivity

Pass 4: Checking reference counts

Step 5: check the cluster profile information

/ dev/mapper/test-lv_test: 12Compare 178816 files (0.0% non-contiguous), 33358Compare 716800 blocks

[root@master /] # resize2fs / dev/mapper/test-lv_test 200M

Resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on / dev/mapper/test-lv_test to 204800 (1k) blocks.

The filesystem on / dev/mapper/test-lv_test is now 204800 blocks long.

[root@master /] # lvreduce-L 200m / dev/mapper/test-lv_test

WARNING: Reducing active logical volume to 200.00 MiB

THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce lv_test? [y/n]: y

Reducing logical volume lv_test to 200.00 MiB

Logical volume lv_test successfully resized

[root@master /] # mount / dev/mapper/test-lv_test / aas/

Check the disk usage with the df command

Error case:

If you don't follow the steps, you don't seem to have succeeded in reducing it, because it's not written to file system 4.

Resize2fs if the command executes an error, it is not written to the file system

Check the disk usage with the df command

[root@master /] # umount / aas/

[root@master /] # lvreduce-L-500m / dev/mapper/test-lv_test

WARNING: Reducing active logical volume to 724.00 MiB

THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce lv_test? [y/n]: y

Reducing logical volume lv_test to 724.00 MiB

Logical volume lv_test successfully resized

At this point, an error occurred in narrowing the partition, resulting in bad blocks in the file system, and a file system check needs to be performed.

[root@master /] # resize2fs / dev/mapper/test-lv_test

Resize2fs 1.41.12 (17-May-2010)

Please run 'e2fsck-f / dev/mapper/test-lv_test'. first.

It is found that the node is wrong here, but it can not be repaired. You need to increase the space later.

[root@master /] # e2fsck-f / dev/mapper/test-lv_test

E2fsck 1.41.12 (17-May-2010)

The file system size (according to the super block) is 1253376 block s

The physical size of the device is 741376 block s

Either the super block or the partition table is likely to be corrupt!

Interruption? No

Step 1: check inode, block, and size

Error reading block 745475 (invalid parameter) while getting next inode from scan. Ignore mistakes? Yes

Mandatory coverage? Yes

Error writing block 745475 (invalid parameter) while getting next inode from scan. Ignore mistakes? Yes

Error reading block 745476 (invalid parameter) while getting next inode from scan. Ignore mistakes? Yes

Mandatory coverage? No

Error reading block 745478 (invalid parameter) while getting next inode from scan. Ignore mistakes? No

Error while scanning inodes (184912): Can't read next inode

E2fsck: aborted

[root@master ~] #

How to fix it:

1. Mount, check that the size has not decreased

[root@master ~] # mount / dev/mapper/test-lv_test / aas/

Check the disk usage with the df command

two。 How much is reduced according to the wrong steps, it will be added back.

[root@master] # lvextend-L + 500m / dev/mapper/test-lv_test

Extending logical volume lv_test to 1.20 GiB

Logical volume lv_test successfully resized

Check the disk usage with the df command

Prompt that the file system has not been modified and the original size has not changed

[root@master ~] # resize2fs / dev/mapper/test-lv_test

Resize2fs 1.41.12 (17-May-2010)

The filesystem is already 1253376 blocks long. Nothing to do!

Just follow the normal steps to reduce the partition and do it again.

[root@master ~] # umount / dev/mapper/test-lv_test

[root@master] # fsck-f / dev/mapper/test-lv_test

Fsck from util-linux-ng 2.17.2

E2fsck 1.41.12 (17-May-2010)

Step 1: check inode, block, and size

Step 2: check the directory structure

Step 3: check directory connectivity

Pass 4: Checking reference counts

Step 5: check the cluster profile information

/ dev/mapper/test-lv_test: 12Compare 310896 files (0.0% non-contiguous), 50246 Universe 1253376 blocks

[root@master] # resize2fs / dev/mapper/test-lv_test-500m

Resize2fs 1.41.12 (17-May-2010)

Resize2fs: invalid option-- 5

Usage: resize2fs [- d debug_flags] [- f] [- F] [- M] [- P] [- p] device [new_size]

[root@master ~] # resize2fs / dev/mapper/test-lv_test 500m

Resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on / dev/mapper/test-lv_test to 512000 (1k) blocks.

The filesystem on / dev/mapper/test-lv_test is now 512000 blocks long.

[root@master] # lvreduce-L-500m / dev/mapper/test-lv_test

WARNING: Reducing active logical volume to 724.00 MiB

THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce lv_test? [y/n]: y

Reducing logical volume lv_test to 724.00 MiB

Logical volume lv_test successfully resized

[root@master ~] # mount / dev/mapper/test-lv_test / aas/

Check the disk usage with the df command

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