同时调整lv分区的大小(减少一个,增加另一个)

Posted 开始认识

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了同时调整lv分区的大小(减少一个,增加另一个)相关的知识,希望对你有一定的参考价值。

author:headsen chen

date: 2018-04-20  16:48:06

 

1、查看分区:/home 为67G,太大了,/ 是50g,太小了。
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  1.5G   46G   4% /
tmpfs                 495M     0  495M   0% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot
/dev/mapper/VolGroup-lv_home
                       67G   52M   63G   1% /home

2,先卸载/home 分区
[[email protected]
~]# umount /home
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  1.5G   46G   4% /
tmpfs                 495M     0  495M   0% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot


3,减少lv_home的逻辑卷大小调整为10G
[[email protected] ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
技术分享图片
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/VolGroup-lv_home: 11/4431872 files (0.0% non-contiguous), 324173/17713152 blocks
View Code

[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 10G
技术分享图片
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 2621440 (4k) blocks.
Begin pass 2 (max = 32768)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 541)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 2621440 blocks long.
View Code

 

  4,重新挂载/home分区

[[email protected] ~]# mount /home
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  1.5G   46G   4% /
tmpfs                 495M     0  495M   0% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot
/dev/mapper/VolGroup-lv_home
                      9.8G   36M  9.2G   1% /home

[[email protected] ~]# ls /home
lost+found
[[email protected] ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  VolGroup   1   3   0 wz--n- 119.51g    0 
[[email protected] ~]# lvs
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao---- 67.57g                                                    
  lv_root VolGroup -wi-ao---- 50.00g                                                    
  lv_swap VolGroup -wi-ao----  1.94g       

5,在逻辑卷里面减少lv的大小
[[email protected] ~]# lvreduce -L -51G /dev/VolGroup/lv_home
  WARNING: Reducing active and open logical volume to 16.57 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Size of logical volume VolGroup/lv_home changed from 67.57 GiB (17298 extents) to 16.57 GiB (4242 extents).
  Logical volume lv_home successfully resized

[[email protected] ~]# lvs
技术分享图片
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao---- 16.57g                                                    
  lv_root VolGroup -wi-ao---- 50.00g                                                    
  lv_swap VolGroup -wi-ao----  1.94g           
View Code

                                       
[[email protected] ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  VolGroup   1   3   0 wz--n- 119.51g 51.00g

6,增加lv_root的lv
[[email protected]
~]# lvextend -L +50G /dev/VolGroup/lv_root Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 100.00 GiB (25600 extents). Logical volume lv_root successfully resized

7,使文件系统重新扫描lv,使修改立即生效。
[[email protected]
~]# resize2fs -p /dev/mapper/VolGroup-lv_root
技术分享图片
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 26214400 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 26214400 blocks long.
View Code

[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       99G  1.5G   92G   2% /
tmpfs                 495M     0  495M   0% /dev/shm
/dev/sda1             477M   36M  416M   8% /boot
/dev/mapper/VolGroup-lv_home
                      9.8G   36M  9.2G   1% /home
[[email protected] ~]# 

 












以上是关于同时调整lv分区的大小(减少一个,增加另一个)的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 6.5 64位,调整分区大小

linux已经分区,想增大一个分区的容量怎么办

Linux下调整磁盘大小后的基于LVM的磁盘扩容

DiskGenius无损调整分区大小

linux 逻辑卷管理 调整分区大小

Linux 使用LVM动态调整磁盘大小/扩容