码迷,mamicode.com
首页 > 其他好文 > 详细

调整lv逻辑卷

时间:2019-03-18 15:19:15      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:mount   auth   ble   please   div   bsp   res   active   style   

author:headsen chen

date:2019-03-18  14:48:17

 

1,查看分区状态,发现/ 分区不够用。/home分区太大了。浪费

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      50G  1.8G  49G   2% /
tmpfs                 931M     0  931M   0% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
/dev/mapper/VolGroup-lv_home
                      65G   32M  61.6G   1% /home

 2,卸载 /home分区

[root@localhost ~]# umount /home
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  1.8G   45G   4% /
tmpfs                 931M     0  931M   0% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot

       假如要是无法卸载:使用 fuse -km /home 强制杀死站用该/home 分区的进程

查看总的lv的情况

[root@localhost ~]# lvs
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-a----- 65.65g                                                    
  lv_root VolGroup -wi-ao---- 50.00g                                                    
  lv_swap VolGroup -wi-ao----  3.86g         

设置文件系统下的  /lv_home分区的大小为5G                                          

[root@localhost ~]# resize2fs -p /dev/VolGroup/lv_home 5G
resize2fs 1.41.12 (17-May-2010)
Please run ‘e2fsck -f /dev/VolGroup/lv_home‘ first.

[root@localhost ~]# e2fsck -f /dev/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/VolGroup/lv_home: 11/4308992 files (0.0% non-contiguous), 316463/17209344 blocks

[root@localhost ~]# resize2fs -p /dev/VolGroup/lv_home 5G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/VolGroup/lv_home to 1310720 (4k) blocks.
Begin pass 2 (max = 32768)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 526)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/VolGroup/lv_home is now 1310720 blocks long.

挂载 /home 分区

[root@localhost ~]# mount /dev/VolGroup/lv_home
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  1.8G   45G   4% /
tmpfs                 931M     0  931M   0% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
/dev/mapper/VolGroup-lv_home
                      4.8G   32M  4.6G   1% /home

但此时的lv配置并没有改变:

[root@localhost ~]# lvs
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao---- 65.65g                                                    
  lv_root VolGroup -wi-ao---- 50.00g                                                    
  lv_swap VolGroup -wi-ao----  3.86g            

 修改lv的配置大小为5G                                       

[root@localhost ~]# lvreduce -L 5G /dev/VolGroup/lv_home     #  设置lv_home 大小为5g
  WARNING: Reducing active and open logical volume to 5.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce VolGroup/lv_home? [y/n]: y
  Size of logical volume VolGroup/lv_home changed from 60.00 GiB (15360 extents) to 5.00 GiB (1280 extents).
  Logical volume lv_home successfully resized.
[root@localhost ~]# lvs
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao----  5.00g                                                    
  lv_root VolGroup -wi-ao---- 50.00g                                                    
  lv_swap VolGroup -wi-ao----  3.86g                                                    
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  VolGroup   1   3   0 wz--n- 119.51g 60.65g

 增加/lv_root 的大小:60g

[root@localhost ~]# lvextend -L +60G /dev/VolGroup/lv_root
  Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 80.00 GiB (20480 extents).
  Logical volume lv_root successfully resized.
[root@localhost ~]# resize2fs -p /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 5
Performing an on-line resize of /dev/VolGroup/lv_root to 20971520 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 20971520 blocks long.
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       109G  1.8G   103G   3% /
tmpfs                 931M     0  931M   0% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
/dev/mapper/VolGroup-lv_home
                      4.8G   32M  4.6G   1% /home
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree  
  VolGroup   1   3   0 wz--n- 119.51g 664.00m

 

调整lv逻辑卷

标签:mount   auth   ble   please   div   bsp   res   active   style   

原文地址:https://www.cnblogs.com/kaishirenshi/p/10552267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!