centos7下修改分区大小(LVM)

LVM全名是Logical Volume Manage,中文叫做逻辑卷管理器;在操作LVM之前首先要理解几个跟LVM有关的概念:PV、PE、VG、LV。

PV:一般是指整个物理磁盘或是物理磁盘上的某个分区,标识符带有8e的就是PV。

VG:VG跟RAID0差不多,RAID0是将多个磁盘看成是一个大的磁盘,而VG则是将多个PV组合成一个大的磁盘。

LV:如果你在安装centos的时候让centos自动为你使用LVM创建分区的话他会自动为你创建swap、root、home分区,而这些就是LV。

PE:是物理卷中可用于分配的最小存储单元,LV就是由多个PE组成的,我们平时调整分区大小的时候就是将某个LV中的某个PE重新分配给另一个LV。这个PE有点像文件系统中的block。看下图(借用一张鸟哥的图):

PE与VG的相关性

在借一张:

 

[root@centos7meis /]# umount /home/
​​​​​​​[root@centos7meis /]#lvremove /dev/mapper/centos_centos7-home
[root@centos7meis /]# lvremove /dev/mapper/centos_centos7-home
Do you really want to remove active logical volume centos_centos7/home? [y/n]: y
  Logical volume "home" successfully removed
[root@centos7meis /]# lvextend -l +100%free /dev/centos_centos7/root
  Size of logical volume centos_centos7/root changed from 71.92 GiB (18412 extents) to <121.93 GiB (31213 extents).
  Logical volume centos_centos7/root successfully resized.
[root@centos7meis /]# pvs
  PV         VG             Fmt  Attr PSize   PFree
  /dev/sda3  centos_centos7 lvm2 a--  125.80g    0
[root@centos7meis /]# lvs
  LV   VG             Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos_centos7 -wi-ao---- <121.93g
  swap centos_centos7 -wi-ao----   <3.88g
[root@centos7meis /]# xfs_growfs /dev/mapper/centos_centos7-root
meta-data=/dev/mapper/centos_centos7-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 31962112
[root@centos7meis /]# lvs
  LV   VG             Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos_centos7 -wi-ao---- <121.93g
  swap centos_centos7 -wi-ao----   <3.88g
[root@centos7meis /]# df -h
文件系统                         容量  已用  可用 已用% 挂载点
/dev/mapper/centos_centos7-root  122G   11G  112G    9% /
devtmpfs                         3.9G     0  3.9G    0% /dev
tmpfs                            3.9G     0  3.9G    0% /dev/shm
tmpfs                            3.9G  9.3M  3.9G    1% /run
tmpfs                            3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/sda2                       1014M  235M  780M   24% /boot
/dev/sda1                        200M  9.8M  191M    5% /boot/efi
tmpfs                            796M     0  796M    0% /run/user/0

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值