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


    author:headsen chen

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

     

    1、查看分区:/home 为67G,太大了,/ 是50g,太小了。
    [root@localhost ~]# 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 分区
    [root@localhost
    ~]# umount /home
    [root@localhost ~]# 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
    [root@localhost ~]# 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
    
    
    [root@localhost ~]# 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分区

    [root@localhost ~]# mount /home
    [root@localhost ~]# 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
    
    
    [root@localhost ~]# ls /home
    lost+found
    [root@localhost ~]# vgs
      VG       #PV #LV #SN Attr   VSize   VFree
      VolGroup   1   3   0 wz--n- 119.51g    0 
    [root@localhost ~]# 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的大小
    [root@localhost ~]# 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
    
    
    [root@localhost ~]# 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
    
    
                                           
    [root@localhost ~]# vgs
      VG       #PV #LV #SN Attr   VSize   VFree 
      VolGroup   1   3   0 wz--n- 119.51g 51.00g
    
    6,增加lv_root的lv
    [root@localhost
    ~]# 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,使修改立即生效。
    [root@localhost
    ~]# 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
    
    
    [root@localhost ~]# 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
    [root@localhost ~]# 
  • 相关阅读:
    Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_chinese_ci,COERCIBLE) for operation '=' 一个解决办法(转载)
    mysql limit用法
    preparedStatement一个小技巧
    两个简单的压力测试代码。
    cookie实现session机制
    java.util.properties用法
    数据库是否使用外键,及视图,索引,存储过程的一些说明(zz)
    某项目要调用现有的100多个DLL 二 最最简单原型的思考
    面试题:红绿灯
    一个简单的封装 .net的日志功能
  • 原文地址:https://www.cnblogs.com/kaishirenshi/p/8892084.html
Copyright © 2020-2023  润新知