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 lvm shrinks logical volume space

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

Share

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

Today, I will talk to you about how lvm shrinks the logical volume space. Many people may not know much about it. In order to let you know more, Xiaobian summarizes the following contents for you. I hope you can gain something according to this article.

[root@cspserver1 /]# umount /softdata

[root@cspserver1 /]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/RHELVG-ROOT

15G 12G 2.6G 82% /

tmpfs 16G 7.8G 8.0G 50% /dev/shm

/dev/sda1 190M 40M 141M 23% /boot

/dev/mapper/RHELVG-HOME

20G 55M 19G 1% /home

/dev/mapper/RHELVG-OPT

15G 13G 1.2G 92% /opt

/dev/mapper/RHELVG-TMP

15G 44M 14G 1% /tmp

/dev/mapper/RHELVG-USR

15G 3.8G 11G 28% /usr

/dev/mapper/RHELVG-VAR

15G 261M 14G 2% /var

[root@cspserver1 /]# e2fsck -f /dev/mapper/RHELVG-SOFTDATA

e2fsck 1.41.12 (17-May-2010)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/RHELVG-SOFTDATA: 11/2559088 files (0.0% non-contiguous), 205643/10232832 blocks

[root@cspserver1 /]# resize2fs /dev/mapper/RHELVG-SOFTWARE DATA 10240m (file system shrunk to 10g)

resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on /dev/mapper/RHELVG-SOFTDATA to 2621440 (4k) blocks.

The filesystem on /dev/mapper/RHELVG-SOFTDATA is now 2621440 blocks long.

is already 2621440 blocks long. Nothing to do!

[root@cspserver1 /]# lvreduce -L 10240m /dev/mapper/RHELVG-SOFTWARE DATA (abbreviated lv)

WARNING: Reducing active logical volume to 10.00 GiB.

THIS MAY DESTROY YOUR DATA (filesystem etc.)

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

Size of logical volume RHELVG/SOFTDATA changed from 39.04 GiB (9993 extents) to 10.00 GiB (2560 extents).

Logical volume SOFTDATA successfully resized.

[root@cspserver1 /]# mount /dev/mapper/RHELVG-SOFTDATA /softdata

[root@cspserver1 /]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/RHELVG-ROOT

15G 12G 2.6G 82% /

tmpfs 16G 7.8G 8.0G 50% /dev/shm

/dev/sda1 190M 40M 141M 23% /boot

/dev/mapper/RHELVG-HOME

20G 55M 19G 1% /home

/dev/mapper/RHELVG-OPT

15G 13G 1.2G 92% /opt

/dev/mapper/RHELVG-TMP

15G 44M 14G 1% /tmp

/dev/mapper/RHELVG-USR

15G 3.8G 11G 28% /usr

/dev/mapper/RHELVG-VAR

15G 261M 14G 2% /var

/dev/mapper/RHELVG-SOFTDATA

9.8G 36M 9.2G 1% /softdata

[root@cspserver1 /]# pvs

PV VG Fmt Attr PSize PFree

/dev/sda2 RHELVG lvm2 a--u 149.80g 29.04g

[root@cspserver1 /]# lvextend -L +20480M /dev/mapper/RHELVG-OPT (Extended Logical Volume)

Size of logical volume RHELVG/OPT changed from 15.00 GiB (3840 extents) to 35.00 GiB (8960 extents).

Logical volume OPT successfully resized.

[root@cspserver1 /]# resize2fs /dev/mapper/RHELVG-OPT (synchronize extended logical volumes to file systems)

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/RHELVG-OPT is mounted on /opt; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 3

Performing an on-line resize of /dev/mapper/RHELVG-OPT to 9175040 (4k) blocks.

The filesystem on /dev/mapper/RHELVG-OPT is now 9175040 blocks long.

[root@cspserver1 /]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/RHELVG-ROOT

15G 12G 2.6G 82% /

tmpfs 16G 7.8G 8.0G 50% /dev/shm

/dev/sda1 190M 40M 141M 23% /boot

/dev/mapper/RHELVG-HOME

20G 55M 19G 1% /home

/dev/mapper/RHELVG-OPT

35G 13G 20G 40% /opt

/dev/mapper/RHELVG-TMP

15G 44M 14G 1% /tmp

/dev/mapper/RHELVG-USR

15G 3.8G 11G 28% /usr

/dev/mapper/RHELVG-VAR

15G 261M 14G 2% /var

/dev/mapper/RHELVG-SOFTDATA

9.8G 36M 9.2G 1% /softdata

[root@cspserver1 /]#

After reading the above, do you have any further understanding of how lvm shrinks logical volume space? If you still want to know more knowledge or related content, please pay attention to 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: 242

*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