Centos 新加硬盘向LV卷增加容量

2021-11-10 05:05 阅读 83 次 Centos 新加硬盘向LV卷增加容量已关闭评论

 

1.新建分区

fdisk /dev/sda

2.为分区创建PV

pvcreate /dev/sda5

3.向VG加容量

vgextend /dev/myvg /dev/sda5

4.向LV加容量

lvextend -L +1.8T /dev/myvg/root

5.刷新分区容量

XFS格式:xfs_growfs /dev/myvg/root

ext4格式:resize2fs /dev/myvg/root

示例:

[[email protected] ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 --- <1.82t <1.82t
/dev/sdb1 myvg lvm2 a-- <1.82t 4.00m
[[email protected] ~]# lvcreate -l 100%free -n myvg
No command with matching syntax recognised. Run 'lvcreate --help' for more information.
Nearest similar command has syntax:
lvcreate --type error -L|--size Size[m|UNIT] VG
Create an LV that returns errors when used.

[[email protected] ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name myvg
PV Size <1.82 TiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476931
Free PE 1
Allocated PE 476930
PV UUID 9tR519-2ksL-pOsJ-bZb2-SNKn-T7bd-hExGXY

"/dev/sda5" is a new physical volume of "<1.82 TiB"
--- NEW Physical volume ---
PV Name /dev/sda5
VG Name
PV Size <1.82 TiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID v3KiW6-6I2P-GFWO-gXjH-FOfy-aftr-UV2fRc

[[email protected] ~]# vgcreate myvg /dev/sda5
/dev/myvg: already exists in filesystem
Run `vgcreate --help' for more information.
[[email protected] ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name myvg
PV Size <1.82 TiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476931
Free PE 1
Allocated PE 476930
PV UUID 9tR519-2ksL-pOsJ-bZb2-SNKn-T7bd-hExGXY

"/dev/sda5" is a new physical volume of "<1.82 TiB"
--- NEW Physical volume ---
PV Name /dev/sda5
VG Name
PV Size <1.82 TiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID v3KiW6-6I2P-GFWO-gXjH-FOfy-aftr-UV2fRc

[[email protected] ~]# vgextend /dev/myvg /dev/sda5
Volume group "myvg" successfully extended
[[email protected] ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name myvg
PV Size <1.82 TiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476931
Free PE 1
Allocated PE 476930
PV UUID 9tR519-2ksL-pOsJ-bZb2-SNKn-T7bd-hExGXY

--- Physical volume ---
PV Name /dev/sda5
VG Name myvg
PV Size <1.82 TiB / not usable <2.09 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476756
Free PE 476756
Allocated PE 0
PV UUID v3KiW6-6I2P-GFWO-gXjH-FOfy-aftr-UV2fRc

[[email protected] ~]# vgdisplay
--- Volume group ---
VG Name myvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size <3.64 TiB
PE Size 4.00 MiB
Total PE 953687
Alloc PE / Size 476930 / <1.82 TiB
Free PE / Size 476757 / <1.82 TiB
VG UUID YLaInC-D1Pq-TvH5-vNv6-kMPI-IRuL-FNeDB1

[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 500M 0 part /boot
├─sda3 8:3 0 200M 0 part /boot/efi
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 1.8T 0 part
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part
├─myvg-root 253:0 0 1.8T 0 lvm /
├─myvg-swap 253:1 0 31.5G 0 lvm [SWAP]
└─myvg-tmp 253:2 0 1G 0 lvm /tmp
[[email protected] ~]# lvextend
No command with matching syntax recognised. Run 'lvextend --help' for more information.
[[email protected] ~]# lvextend -L +1.8T /dev/myvg/root
Rounding size to boundary between physical extents: 1.80 TiB.
Size of logical volume myvg/root changed from <1.79 TiB (468610 extents) to <3.59 TiB (940470 e xtents).
Logical volume myvg/root successfully resized.
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 500M 0 part /boot
├─sda3 8:3 0 200M 0 part /boot/efi
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 1.8T 0 part
└─myvg-root 253:0 0 3.6T 0 lvm /
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part
├─myvg-root 253:0 0 3.6T 0 lvm /
├─myvg-swap 253:1 0 31.5G 0 lvm [SWAP]
└─myvg-tmp 253:2 0 1G 0 lvm /tmp

版权声明:本文著作权归原作者所有,欢迎分享,谢谢支持!
转载请保留注明:Centos 新加硬盘向LV卷增加容量 | DXL学习
分类:Centos 标签:

评论已关闭!