2020-03-23 LVM
2020-03-23 本文已影响0人
点亮生活501
1.创建lvm
1.fdisk -l
[root@lb01 ~]# fdisk -l 显示磁盘信息
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a2c65
Device Boot Start End Blocks Id System
/dev/sda1 2048 4196351 2097152 82 Linux swap / Solaris
/dev/sda2 * 4196352 104857599 50330624 83 Linux
2.[root@lb01 ~]# pvcreate /dev/sdb 将物理磁盘设备初始化为物理卷
Physical volume "/dev/sdb" successfully created.
3.vgcreate easyits /dev/sdb 创建卷组,将pv加入卷组中
4.lvcreate -n mylv -L 2G easyits 基于卷组创建逻辑卷
-n 指定逻辑卷名称
-L 指定逻辑卷大小
lvs 显示逻辑卷
lvdisplay 显示逻辑卷详细信息
[root@lb01 ~]# lvs 显示逻辑卷
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
mylv easyits -wi-a----- 2.00g
5. mkfs.ext4 /dev/easyits/mylv 为创建好的逻辑卷创建文件系统
6.mount /dev/easyits/mylv /mnt 将格式化好的逻辑卷挂载使用
7.[root@lb01 mnt]# df -h 显示挂载信息
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 48G 1.7G 47G 4% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.8M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/easyits-mylv 2.0G 6.0M 1.8G 1% /mnt
2.删除lvm
删除之前先卸载 umount /mnt
一定要按照顺序删除
1.删除lv 逻辑卷 lvremove /dev/easyits/mylv
2.删除vg 卷组 vgremove easyits
3.删除物理卷 pvremove /dev/sdb
3.lvm fs扩容
image.png image.png4.vg扩容
pvcreate /dev/sdd
vgextend centos /dev/sdd centos卷组名称
项目实例演示
image.pngpvresize -v /dev/sdb
lvextend -L +511g /dev/mapper/VG--data-LV--data
resize2fs -p /dev/mapper/VG--data-LV--data