改变lvm挂载大小

先备份

描述:


[mongo@mongo1 ~]$ df -hT
Filesystem                   Type   Size  Used Avail Use% Mounted on
/dev/mapper/vg_mould-lv_root ext4    50G  3.9G   43G   9% /
tmpfs                        tmpfs  9.8G     0  9.8G   0% /dev/shm
/dev/vda1                    ext4   485M   33M  427M   8% /boot
/dev/mapper/vg_mould-lv_home ext4    47G  180M   45G   1% /home

磁盘分区 / 目录下分配磁盘份额不够,/home有剩余

如果是lvm就好办,把其中一个分区的lv删除,然后扩展另一个分区。

步骤:

解除挂载

[root@localhost ~]# umount /dev/vg_mould/lv_home (-l 标示强制删除挂载)

[root@localhost ~]# lvchange -an /dev/mapper/vg_mould-lv_home    改变状态[-a|--activate[a|e|l]{y|n}]

若提示 Logical volume vg_mould/lv_home contains a filesystem in use.
则[root@mongo2 /]# fuser -m /dev/mapper/vg_mould-lv_home
/home:                1527c  3035c

[root@mongo2 /]# kill -9 1527

[root@localhost ~]# lvdisplay /dev/mapper/vg_mould-lv_home

  LV Path                /dev/vg_mould/lv_home
  LV Name                lv_home
  VG Name                vg_mould
  LV UUID                GcWBGI-pgsF-wplR-OQFg-pqfq-V0CE-ifmBii
  LV Write Access        read/write
  LV Creation host, time mould, 2018-08-07 13:59:40 +0800
  LV Status              NOT available  #状态不可用
  LV Size                47.54 GiB
  Current LE             12170
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

[root@localhost ~]#lvremove /dev/mapper/vg_mould-lv_home 移除逻辑卷
  Logical volume "lv_home" successfully removed

[root@localhost ~]# lvdisplay /dev/mapper/vg_mould-lv_home  查看发现已经没有了

  Oneor more specified logical volume(s) not found.


[root@mongo2 ~]# lvextend -L +42G /dev/mapper/vg_mould-lv_root

[root@mongo1 vg_mould]#  resize2fs /dev/mapper/vg_mould-lv_root 更新系统识别的容量

创建一个较小的lv_home挂载到/home

[root@mongo1 vg_mould]# lvcreate -L 5G -n lv_home vg_mould
[root@mongo1 vg_mould]# mkfs -t ext4 /dev/mapper/vg_mould-lv_home
[root@mongo1 vg_mould]# mount /dev/mapper/vg_mould-lv_home /home

[root@mongo1 vg_mould]# blkid /dev/mapper/vg_mould-lv_home
/dev/mapper/vg_mould-lv_home: UUID="407518c8-06e5-4ae8-8d6a-3efcb321e075" TYPE="ext4"

 

注:若挂载路径改变需修改/etc/fstab

你可能感兴趣的:(改变lvm挂载大小)