LVM在线扩容

一:LVM

刚刚加入一个盘

  1.创建物理卷

[root@nfs ~]# pvcreate /dev/sdb

  Physical volume "/dev/sdb" successfully created.

  2.创建卷组

[root@nfs ~]# vgcreate vgnfs /dev/sdb

  Volume group "vgnfs" successfully created

  3.创建逻辑卷

[root@nfs ~]# lvcreate vgnfs -l 100%free -n lvnfs

  Logical volume "lvnfs" created.

  4.格式化磁盘

[root@nfs ~]# mkfs.xfs /dev/vgnfs/lvnfs

meta-data=/dev/vgnfs/lvnfs       isize=512    agcount=4, agsize=1310464 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=5241856, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

  5.创建挂载目录

[root@nfs ~]# mkdir /projent

  6.查看UUID

[root@nfs ~]# blkid

/dev/mapper/vgnfs-lvnfs: UUID="8dfdb783-8793-4a6a-9f23-7f91d0793a41" TYPE="xfs"

 

  7.写入挂载文件/etc/fstab

[root@nfs ~]# vim /etc/fstab

UUID=8dfdb783-8793-4a6a-9f23-7f91d0793a41 /projent  xfs     defaults        0 0

 

  8.自动挂载

[root@nfs ~]# mount -a

  9.完成

 

 

二:在线扩容

添加一个盘扩容/

 

挂载/的盘叫centos-root

卷组名是centos   逻辑卷名是root 现在盘大小为17G,加一个20G的盘最后是37G

 

  1.创建物理盘

[root@nfs ~]# pvcreate /dev/sdc

  Physical volume "/dev/sdc" successfully created.

        2.使用扩容命令对centos卷组扩容

[root@nfs ~]# vgextend centos /dev/sdc

  Volume group "centos" successfully extended

         3.扩展逻辑卷

[root@nfs ~]# lvextend -l +100%FREE /dev/centos/root

  Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to 36.99 GiB (9470 extents).

  Logical volume centos/root successfully resized.

  4.调整文件系统格式

[root@nfs ~]# xfs_growfs /dev/centos/root

meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1113856 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0 spinodes=0

data     =                       bsize=4096   blocks=4455424, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal               bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 4455424 to 9697280

  5.完成扩容,从17G扩容到37G

[root@nfs ~]# df -h

 

 

posted @ 2023-08-07 16:09  虞岩  阅读(40)  评论(0编辑  收藏  举报