1581 views|0 replies

3836

Posts

19

Resources
The OP
 

Adjustment of lv space usage in linux system lvm [Copy link]

Recently, a project was deployed. Party A used a virtualization platform and the servers provided were all virtualized cloned machines. The default partition when the operating system was installed was that the root partition was only 50G. During deployment, a deployment directory was created using a soft link, but colleagues who upgraded later did not pay attention and placed the deployment directly in the root partition, resulting in a large log file during recent data synchronization. The log deletion script task was not scheduled to be executed before the execution time, so the disk was filled with service log files. The solution is as follows.
1. System environment: Operating system: Centos_x64 6.5 Kernel version: 2.6.32-431.el6.X86_64 Disk format: EXT4
2. Existing partition situation and description
df -h #View current partitionsFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 17G 31G 36% /tmpfs 7.8G 0 7.8G 0% /dev/shm/dev/sda1 485M 33M 427M 8% /boot/dev/mapper/VolGroup-lv_home 435G 9.7G 404G 3% /home
Note: It can be clearly seen that the partitions of the two lv volumes VolGroup-lv_root are mounted as the root partition of 50G, and VolGroup-lv_home is mounted as the /home partition. The home partition is relatively large, but it is not used.
3. Release the occupation of the /home partition and unmount the /home partition 1. I thought that using fuser -m /home would complete it, but after executing it, the unmounting still prompts that /home is occupied. The situation is as follows:
# fuser -m /home/home: 24033ce# umount /homeumount: /home: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
2. Check the occupied files and find that the system provided by Party A contains Kingsoft's protection software. Kill the software process and uninstall the /home partition normally:
# lsof | grep /home --Check and find that it is Kingsoft's protection software that is occupied. Run it directly kiil -9 24033KANLinuxC 24033 root cwd DIR 253,2 4096 5636103 /home/kingsoft/kavnetKANLinuxC 24033 root txt REG 253,2 1645332 5636130 /home/kingsoft/kavnet/KANMainModuleKANLinuxC 24033 root mem REG 253,2 1369600 5636263 /home/kingsoft/kavnet/libcrypto.so.6KANLinuxC 24033          root  mem       REG              253,2    323320    5636276 /home/kingsoft/kavnet/libssl.so.6KANLinuxC 24033          root  mem       REG              253,2     34487    5636129 /home/kingsoft/kavnet/KANLocalComm.soKANLinuxC 24033          root  mem       REG              253,2    626402    5636131 /home/kingsoft/kavnet/KANNetComm.soKANLinuxC 24033          root  mem       REG              253,2    163342    5636265 /home/kingsoft/kavnet/libjson.soKANLinuxC 24033          root    3w      REG              253,2    789537    5636280 /home/kingsoft/kavnet/neterror.logKANLinuxC 24033          root   10w      REG              253,2    789537    5636280 /home/kingsoft/kavnet/neterror.logKANLinuxC 24033          root   11w      REG              253,2    789537    5636280 /home/kingsoft/kavnet/neterror.logKANLinuxC 24033          root   13w      REG              253,2    789537    5636280 /home/kingsoft/kavnet/neterror.logKANLinuxC 24033          root   20w      REG              253,2    789537    5636280 /home/kingsoft/kavnet/neterror.log# umount /home          --重新卸载未在报错未在报错。
3. Reduce the space of VolGroup-lv_home LV 1. Check whether the information of this LV partition is normal;
# e2fsck -f /dev/mapper/VolGroup-lv_homee2fsck 1.41.12 (17-May-2010)Step 1: Check inode, block, and sizeStep 2: Check directory structureStep 3: Check directory connectivityPass 4: Checking reference countsStep 5: Check cluster summary information/dev/mapper/VolGroup-lv_home: 5779/28950528 files (2.2% non-contiguous), 4334183/115775488 blocks
2. Adjust the size of the VolGroup-lv_home partition;
#resize2fs -p /dev/mapper/VolGroup-lv_home 80Gresize2fs 1.41.12 (17-May-2010)Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 20971520 (4k) blocks.Begin pass 2 (max = 50904) Relocating block XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXBegin pass 3 (max = 3534) Scanning inode tableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXBegin pass 4 (max = 838) Updating inode reference XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem 3. Remount the home partition and check the size of the space. You can find that the space of /home has become smaller. # mount /home# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 17G 31G 36% /tmpfs 7.8G 0 7.8G 0% /dev/shm/dev/sda1 485M 33M 427M 8% /boot/dev/mapper/VolGroup-lv_home 79G 9.6G 66G WARNING: Reducing active and open logical volume to 80.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.)Do you really want to reduce lv_home? [y/n]:y  Reducing logical volume lv_home to 80.00 GiB  Logical volume lv_home successfully resized
5、检查空闲出的空间Free PE已经空出了361G;
# vgdisplay   --- Volume group ---  VG Name               VolGroup  System ID               Format                lvm2  Metadata Areas        1  Metadata Sequence No  5  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                3  Open LV               3  Max PV                0  Cur PV                1  Act PV                1  VG Size               499.51 GiB  PE Size               4.00 MiB  Total PE              127874  Alloc PE / Size       35292 / 137.86 GiB  Free  PE / Size       92582 / 361.65 GiB  VG UUID               Ur7bJ4-hQKi-xx4R-f9Qt-INvG-fjBf-zcvJ4n
四、将缩减出的空间增加给VolGroup-lv_root这个LV
1、给VolGroup-lv_root增加空间;
# lvresize --size +361G /dev/VolGroup/lv_root   Extending logical volume lv_root to 410.71 GiB  Logical volume lv_root successfully resized
2、让系统重新识别VolGroup-lv_root增加的空间;
# resize2fs -p /dev/mapper/VolGroup-lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 4, new_desc_blocks = 26Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 107665408 (4k) blocks.The filesystem on /dev/mapper/VolGroup-lv_root is now 107665408 blocks long.
3、检查最终结果,确认操作成功;
# df -hFilesystem                    Size  Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root  405G   23G  362G   6% /tmpfs                         7.8G     0  7.8G   0% /dev/shm/dev/sda1                     485M   33M  427M   8% /boot/dev/mapper/VolGroup-lv_home   79G  3.5G   72G   5% /home
This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list