将俩块磁盘做成同一个逻辑卷(LVM)及后期lvm扩容操作

  • Post author:
  • Post category:其他



1、创建pv


[root@autodeploy nfs]# pvcreate /dev/vdd1

WARNING: xfs signature detected on /dev/vdd1 at offset 0. Wipe it? [y/n]: y

Wiping xfs signature on /dev/vdd1.

Physical volume “/dev/vdd1” successfully created

[root@autodeploy nfs]# pvcreate /dev/vde1

Physical volume “/dev/vde1” successfully created


2、创建vg


[root@autodeploy nfs]# vgcreate nfs_vg /dev/vdd1 /dev/vde1

Volume group “nfs_vg” successfully created


3、创建lv



此处可以根据需要创建lv,下面只展示做一个lv的列子



[root@autodeploy ~]# lvcreate -l 100%FREE -n nfs_lv nfs_vg

Logical volume “nfs_lv” created.

大小可以指定,比如:

lvcreate -L 100G -n nfs_lv nfs_vg


4、格代化lv为xfs


[root@autodeploy dev]# mkfs.xfs /dev/nfs_vg/nfs_lv

meta-data=/dev/nfs_vg/nfs_lv isize=256 agcount=4, agsize=262143488 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=1048573952, imaxpct=5

= sunit=0 swidth=0 blks

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

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

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

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

到此处磁盘已做成LVM,只需挂载到相应的文件目录就可以使用。

下面讲一下lvm的扩容


新加入一块100G的盘


pvcreate /dev/vdf1

把pv加到VG中:

vgextend nfs_vg /dev/vdf1

将逻辑卷分区VG(nfs_vg)增加100G:

lvextend -L +100G /dev/nfs_vg/nfs_lv

调整刷新xfs:

xfs_growfs /dev/nfs_vg/nfs_lv

resize2fs -p /dev/nfs_vg/nfs_lv



版权声明:本文为ligaoman521原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。