• 云途科技成立于2010年 - 专注全球跨境电商服务器租赁托管!
  • 帮助中心

    您可以通过下方搜索框快速查找您想知道的问题

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

      in  unix      Tags: 

    测试机各种报错,创建个目录都报错,df看了一下,发现VolGroup-lv_root 100%,虚拟磁盘满了,怎么办呢

    1,解决过程

    # df -h //查看分区
    # umount /home //取消挂载
    # e2fsck -f /dev/mapper/VolGroup-lv_home //分区检测
    # resize2fs -p /dev/mapper/VolGroup-lv_home 100G //将lv_home虚拟分区设为100G
    # mount /home //挂载home
    # df -h //查看分区
    # lvreduce -L 100G /dev/mapper/VolGroup-lv_home //释放空间
    # vgdisplay //查看可用空间大小
    # lvextend -L +311.47G /dev/mapper/VolGroup-lv_root //扩展lv_root虚拟分区
    # resize2fs -p /dev/mapper/VolGroup-lv_root //lv_root重设分区大小

    LVM(逻辑磁盘管理),灵活性很高.

    2,详细解决过程

    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root 50G 47G 16M 100% /   //lv_root满了
    tmpfs 1.9G 72K 1.9G 1% /dev/shm
    /dev/sda1 485M 40M 420M 9% /boot
    /dev/mapper/VolGroup-lv_home 406G 19G 366G 5% /home   //lv_home空间很多
    
    [root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 100G
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/mapper/VolGroup-lv_home is mounted on /home; on-line resizing required
    On-line shrinking from 107865088 to 65536000 not supported.    //先umount才能resize2fs
    
    [root@localhost ~]# umount /home   //umount home目录
    
    [root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 100G
    resize2fs 1.41.12 (17-May-2010)
    请先运行 'e2fsck -f /dev/mapper/VolGroup-lv_home'.   //提示要先进行磁盘检测
    
    [root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
    e2fsck 1.41.12 (17-May-2010)
    第一步: 检查inode,块,和大小
    第二步: 检查目录结构
    第3步: 检查目录连接性
    Pass 4: Checking reference counts
    第5步: 检查簇概要信息
    /dev/mapper/VolGroup-lv_home: 1459/16384000 files (4.0% non-contiguous), 5914204/65536000 blocks
    
    [root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 100G    //重定大小
    resize2fs 1.41.12 (17-May-2010)
    Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 26214400 (4k) blocks.
    Begin pass 2 (max = 32768)
    正在重定位块 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 3 (max = 2000)
    正在扫描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    The filesystem on /dev/mapper/VolGroup-lv_home is now 26214400 blocks long.
    
    [root@localhost ~]# mount /home/
    
    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root 50G 47G 16M 100% /
    tmpfs 1.9G 72K 1.9G 1% /dev/shm
    /dev/sda1 485M 40M 420M 9% /boot
    /dev/mapper/VolGroup-lv_home 99G 19G 75G 20% /home
    
    [root@localhost ~]# lvreduce -L 100G /dev/mapper/VolGroup-lv_home   //释放空间
     WARNING: Reducing active and open logical volume to 100.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 100.00 GiB
     Logical volume lv_home successfully resized
    
    [root@localhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root 50G 47G 16M 100% /
    tmpfs 1.9G 72K 1.9G 1% /dev/shm
    /dev/sda1 485M 40M 420M 9% /boot
    /dev/mapper/VolGroup-lv_home 99G 19G 75G 20% /home
    
    [root@localhost ~]# 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 465.27 GiB
     PE Size 4.00 MiB
     Total PE 119109
     Alloc PE / Size 39372 / 153.80 GiB
     Free PE / Size 79737 / 311.47 GiB       //空闲空间
     VG UUID Vt2V4t-Byxs-tQqk-cY0h-IDE3-pabX-LUfkRS
    
    [root@localhost ~]# lvextend -L +311.47G /dev/mapper/VolGroup-lv_root   //空闲空间加入到lv_root
     Rounding size to boundary between physical extents: 311.47 GiB
     Extending logical volume lv_root to 361.47 GiB
     Logical volume lv_root successfully resized
    
    [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 = 23    //这儿要耐心等待,扩大越多,时间越长
    Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 94757888 (4k) blocks.
    The filesystem on /dev/mapper/VolGroup-lv_root is now 94757888 blocks long.
    
    [root@localhost openfire]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root 356G 48G 308G 14% /
    tmpfs 1.9G 72K 1.9G 1% /dev/shm
    /dev/sda1 485M 40M 420M 9% /boot
    /dev/mapper/VolGroup-lv_home 99G 19G 75G 20% /home


    • 外贸虚拟主机

      1GB硬盘

      2个独立站点

      1000M带宽

      不限制流量

      美国外贸专用虚拟主机,cPanel面板,每天远程备份.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥180/年

    • 美国/荷兰外贸VPS

      2核CPU

      1G内存

      30硬盘

      10M带宽

      美国/荷兰外贸云服务器,专注外贸服务器行业12年.
      服务器配置:2*E5 32核,96GB 内存,4*2TB 硬盘 RAID10 阵列.

      ¥99/月

    • 全球外贸服务器

      8核CPU

      32G内存

      1TB硬盘

      1000M带宽

      已部署数据中心:美国洛杉矶/亚特兰大、荷兰、加拿大、英国伦敦、德国、拉脱维亚、瑞典、爱沙尼亚
      自有机柜(全球九大数据中心),稳定在线率:99.9%

      ¥999/月 原价1380

    7*24小时 在线提交工单

    如果您的问题没有得到解决,推荐您在线提交工单,我们的客服人员会第一时间为您解决问题

    展开