1、添加2快硬盘分别为/dev/sdb5G与/dev/sdc3G
[root@bogon ~]# fdisk -l
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x26c1bdd2
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10485759 5241856 8e Linux LVM
Disk /dev/sdc: 3221 MB, 3221225472 bytes, 6291456 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: 0xf085ed8d
Device Boot Start End Blocks Id System
/dev/sdc1 2048 6291455 3144704 8e Linux LVM
Disk /dev/sda: 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 label type: dos
Disk identifier: 0x00074139
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 2050047 512000 82 Linux swap / Solaris
/dev/sda3 2050048 41943039 19946496 83 Linux
2、创建pv物理卷组
[root@bogon ~]# pvcreate /dev/sdb /dev/sdc
Device /dev/sdb excluded by a filter.
Device /dev/sdc excluded by a filter.
创建报错
擦除签名信息
parted /dev/sdb
输入:mklabel msdos
输入: Yes
输入:quit
重建就完成了
[root@bogon ~]# pvcreate /dev/sdb /dev/sdc
WARNING: dos signature detected on /dev/sdb at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdb.
WARNING: dos signature detected on /dev/sdc at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdc.
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
创建成功查看
[root@bogon ~]# pvscan #查看物理卷
PV /dev/sdc lvm2 [3.00 GiB]
PV /dev/sdb lvm2 [5.00 GiB]
Total: 2 [8.00 GiB] / in use: 0 [0 ] / in no VG: 2 [8.00 GiB]
3、创建卷组
[root@bogon ~]# vgcreate vgname /dev/sdb /dev/sdc
Volume group "vgname" successfully created
4、卷组内创建逻辑卷
[root@bogon ~]# lvcreate -L 4G -n lvname vgname #创建逻辑卷
Logical volume "lvname" created.
[root@bogon ~]# lvdisplay /dev/vgname/lvname #查看逻辑卷
--- Logical volume ---
LV Path /dev/vgname/lvname
LV Name lvname
VG Name vgname
LV UUID 2yojxb-rBjL-4lcI-ppJd-bcoi-bYv8-HSH3Xu
LV Write Access read/write
LV Creation host, time bogon, 2022-10-04 22:55:06 +0800
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
5、格式化并挂载
[root@bogon ~]# xfs_growfs /dev/vgname/lvname
meta-data=/dev/mapper/vgname-lvname isize=512 agcount=4, agsize=262144 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=1048576, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1048576 to 1310720
[root@bogon ~]# mkdir /lvm2
[root@bogon ~]# mount /dev/vgname/lvname /lvm2
[root@bogon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 20G 1.7G 18G 9% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/vgname-lvname 4.0G 33M 4.0G 1% /lvm2
6、对卷组与逻辑卷扩容
添加一个1G的硬盘
[root@bogon ~]# fdisk /dev/sdd
[root@bogon ~]# pvcreate /dev/sdd
Device /dev/sdd excluded by a filter.#第一次创建物理卷应该是硬盘名打错了,不用做擦除签名信息。
[root@bogon ~]# pvcreate /dev/sdd1 #创建物理卷
Physical volume "/dev/sdd1" successfully created.
[root@bogon ~]# vgextend vgname /dev/sdd1 #把物理卷添加到卷组
Volume group "vgname" successfully extended
[root@bogon ~]# lvextend -L +3G /dev/vgname/lvname
Size of logical volume vgname/lvname changed from 5.00 GiB (1280 extents) to 8.00 GiB (2048 extents).
Logical volume vgname/lvname successfully resized.
[root@bogon ~]# xfs_growfs /dev/vgname/lvname
[root@bogon ~]# df -h #只有8G
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 20G 1.7G 18G 9% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/vgname-lvname 8.0G 33M 8.0G 1% /lvm2
[root@bogon ~]# pvscan #查看物理没问题但是总大小不到9G
PV /dev/sdb VG vgname lvm2 [<5.00 GiB / 0 free]
PV /dev/sdc VG vgname lvm2 [<3.00 GiB / 0 free]
PV /dev/sdd1 VG vgname lvm2 [1020.00 MiB / 1012.00 MiB free]
Total: 3 [<8.99 GiB] / in use: 3 [<8.99 GiB] / in no VG: 0 [0 ]
[root@bogon ~]# vgdisplay vgname #查看卷组也是不到9G
--- Volume group ---
VG Name vgname
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <8.99 GiB
PE Size 4.00 MiB
Total PE 2301
Alloc PE / Size 2048 / 8.00 GiB
Free PE / Size 253 / 1012.00 MiB
VG UUID B3Y05h-Ga8I-lv8F-hlRL-kIXE-Vc3R-tcL1kX
###加0.5G测试
[root@bogon ~]# lvextend -L +0.5G /dev/vgname/lvname
Size of logical volume vgname/lvname changed from 8.00 GiB (2048 extents) to 8.50 GiB (2176 extents).
Logical volume vgname/lvname successfully resized.
[root@bogon ~]# xfs_growfs /dev/vgname/lvname
meta-data=/dev/mapper/vgname-lvname isize=512 agcount=8, agsize=262144 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2097152 to 2228224
[root@bogon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 20G 1.7G 18G 9% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/vgname-lvname 8.5G 33M 8.5G 1% /lvm2
测试成功
参考资料
标签:lvname,vgname,dev,lvm,bogon,512,root From: https://blog.51cto.com/u_756467/5731371