目的:管理磁盘的一种方式,与前面说的磁盘管理性质差不多
特点:能够随便的扩张或者缩小磁盘,不受磁盘分区的影响,比较方便,企业里面都是进行扩张的
PV:物理卷
VG:卷组
LVM:逻辑卷
//把sdb磁盘变成pv物理卷,
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
//出现这句话说明成功了
物理卷加入卷组//把sdb磁盘加入vg1里面
[root@localhost ~]# vgcreate vg1 /dev/sdb
Volume group "vg1" successfully created
//出现这句话说明成功了
从卷组里面拿点空间做成逻辑卷[root@localhost ~]# lvcreate -L 1G -n lv1 vg1
Logical volume "lv1" created.
格式化/创建系统文件[root@localhost ~]# mkfs.ext4 /dev/vg1/lv1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done //成功
Writing inode tables: done //成功
Creating journal (8192 blocks): done //成功
Writing superblocks and filesystem accounting information: done //成功
挂载[root@localhost ~]# mount -t ext4 /dev/vg1/lv1 /tmp/aaa/
查看
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─vg1-lv1 253:2 0 1G 0 lvm /tmp/aaa
sdc 8:32 0 5G 0 disk
sdd 8:48 0 5G 0 disk
sr0 11:0 1 4.4G 0 rom
扩大VG卷组
针对磁盘不够用的时候进行扩容
把磁盘变成PV