说明:将sdb和sdc了两个盘做成lvm,挂载到/data目录。
[JSUSER@host-10-233-250-28 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 99.5G 0 part
├─centos-root 253:0 0 97.5G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 1000G 0 disk
sdc 8:32 0 1000G 0 disk
sr0 11:0 1 1024M 0 rom
#1、pvcreate 硬盘名称
[root@host-10-233-250-28 JSUSER]# pvcreate /dev/sdb /dev/sdc
Close failed on stray file descriptor 3 (socket:[608552]): File descriptor in bad state Parent PID 4462: bash
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
#2、查看pv:通过命令 pvdisplay或者pvs查看pv
[root@host-10-233-250-28 JSUSER]# pvs
Close failed on stray file descriptor 3 (socket:[44784]): File descriptor in bad state Parent PID 14827: bash
PV VG Fmt Attr PSize PFree
/dev/sdb VGdata lvm2 a-- <1000.00g 0
/dev/sdc VGdata lvm2 a-- <1000.00g 49.99g
#1、vgcreate 自定义VG名称 要加入的PV
[root@host-10-233-250-28 JSUSER]# vgcreate VGdata /dev/sdb /dev/sdc
Close failed on stray file descriptor 3 (socket:[604080]): File descriptor in bad state Parent PID 4462: bash
Volume group "VGdata" successfully created
#2、查看VG:通过命令vgdisplay或vgs来查看创建的卷组
[root@host-10-233-250-28 JSUSER]# vgs
Close failed on stray file descriptor 3 (socket:[44888]): File descriptor in bad state Parent PID 14827: bash
VG #PV #LV #SN Attr VSize VFree
VGdata 2 1 0 wz--n- 1.95t 49.99g
#1、lvcreate -n 自定义逻辑卷名称 -L 要创建的逻辑卷的大小 VG名称
[root@host-10-233-250-28 JSUSER]# lvcreate -n LVdata -L 1950G VGdata
Close failed on stray file descriptor 3 (socket:[608694]): File descriptor in bad state Parent PID 4462: bash
Logical volume "LVdata" created.
#2、查看卷组(LV):通过命令lvs或lvdisplay查看lv的详细信息
[root@host-10-233-250-28 JSUSER]# lvs
Close failed on stray file descriptor 3 (socket:[44998]): File descriptor in bad state Parent PID 14827: bash
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
LVdata VGdata -wi-ao---- 1.90t
#1、创建文件系统(xfs):mkfs.xfs /dev/VGName/LVName -f
[root@host-10-233-250-28 JSUSER]# mkfs.xfs /dev/VGdata/LVdata -f
meta-data=/dev/VGdata/LVdata isize=512 agcount=4, agsize=127795200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=511180800, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=249600, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
#2、挂载LV:mount /dev/VGName/LVName /data
[root@host-10-233-250-28 JSUSER]# mount /dev/VGdata/LVdata /data/
#3、查看分区
[root@host-10-233-250-28 JSUSER]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 98G 1.8G 96G 2% /
devtmpfs devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 16G 0 16G 0% /dev/shm
tmpfs tmpfs 16G 17M 16G 1% /run
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 139M 359M 28% /boot
tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/0
tmpfs tmpfs 3.2G 0 3.2G 0% /run/user/1000
/dev/mapper/VGdata-LVdata xfs 2.0T 33M 2.0T 1% /data
更多详细内容请参考:Linux运维实战总结