创建物理卷 [[email protected] ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [[email protected] ~]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created [[email protected] ~]# 创建卷组 [[email protected] ~]# vgcreate lvmdisk /dev/sdb1 /dev/sdc1 Volume group "lvmdisk" successfully created [[email protected] ~]# 查看创建的信息 [[email protected] ~]# pvdisplay --- Physical volume --- PV Name /dev/sdb1 VG Name lvmdisk PV Size 5.01 GiB / not usable 2.10 MiB Allocatable yes PE Size 4.00 MiB Total PE 1282 Free PE 1282 Allocated PE 0 PV UUID fguwZS-C82R-at0C-oMjR-yeoo-FCAx-XqHs4n --- Physical volume --- PV Name /dev/sdc1 VG Name lvmdisk PV Size 10.00 GiB / not usable 4.54 MiB Allocatable yes PE Size 4.00 MiB Total PE 2560 Free PE 2560 Allocated PE 0 PV UUID PNLzcH-JvyU-BQa3-2I6U-as35-r4QJ-c2G7pd [[email protected] ~]# vgdisplay --- Volume group --- VG Name lvmdisk System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 15.01 GiB PE Size 4.00 MiB Total PE 3842 Alloc PE / Size 0 / 0 Free PE / Size 3842 / 15.01 GiB VG UUID daYbkb-BN42-dgdp-lCYD-sQAD-kPwv-657HPr [[email protected] ~]# 创建逻辑卷 [[email protected] ~]# lvcreate -L 12G -n mysqldata lvmdisk mkfs.ext4 /dev/lvmdisk/mysqldata [[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 2.2G 26G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 40M 141M 23% /boot /dev/mapper/lvmdisk-mysqldata 12G 30M 12G 1% /mnt/mysqldata [[email protected] ~]# 给卷组添加容量 磁盘分区的时候 partx -a /dev/sdb 让系统识别分区 [[email protected] ~]# pvcreate /dev/sdb2 [[email protected] ~]# vgextend lvmdisk /dev/sdb2 从卷组中去掉一块分区 如果有数据移动到别的盘里面 [[email protected] ~]# pvmove /dev/sdb1 /dev/sdc1 [[email protected] ~]# vgreduce lvmdisk /dev/sdb1 逻辑卷的扩展和减少 lvextend -L +3G /dev/lvmdisk/mysqldata #mysqldata 创建的时候就指定了卷组 [[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 2.2G 26G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 40M 141M 23% /boot /dev/mapper/lvmdisk-mysqldata 15G 30M 14G 1% /mnt/mysqldata [[email protected] ~]# resize2fs /dev/mapper/lvmdisk-mysqldata #df -h 查看出来的文件系统边界
时间: 2024-12-24 09:09:49