root@vHead-172.16.131.125 ~# virsh list
Id Name State
----------------------------------------------------
7 k8s_node1 running
root@vHead-172.16.131.125 ~#
複製代碼
root@vHead-172.16.131.125 ~# virsh domblklist 7
Target Source
------------------------------------------------
vda /image/image.qcow2
hdc -
root@vHead-172.16.131.125 ~#
複製代碼
建立一個80G大小的虛擬磁盤爲例node
qemu-img create -f qcow2 node1_data.qcow2 80G
複製代碼
root@vHead-172.16.131.125 /image# qemu-img info node1_data.qcow2
image: node1_data.qcow2
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
root@vHead-172.16.131.125 /image#
複製代碼
virsh attach-disk k8s_node1 node1_data.qcow2 vdb --cache none --subdriver qcow2 --persistent
複製代碼
root@vHead-172.16.131.125 /image# virsh domblklist 7
Target Source
------------------------------------------------
vda /image/image.qcow2
vdb /image/node1_data.qcow2
hdc -
root@vHead-172.16.131.125 /image#
複製代碼
[root@k8s-node1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 50G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 49G 0 part
├─rhel-root 253:0 0 47G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm
vdb 252:16 0 80G 0 disk
[root@k8s-node1 ~]#
複製代碼
發現虛擬機裏面已經多了一塊80G大小的磁盤(vdb)bash
[root@k8s-node1 ~]# df -Th /
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 47G 31G 17G 66% /
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/swap
LV Name swap
VG Name rhel
LV UUID YX63U1-53aJ-kMpC-f43q-ghND-MlwG-cyDQ7H
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2018-06-13 11:42:54 +0800
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID lbHA32-rdhb-KJUG-tyzO-4COC-9n6r-4h4Slz
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2018-06-13 11:42:54 +0800
LV Status available
# open 1
LV Size <47.00 GiB
Current LE 12031
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <49.00 GiB
PE Size 4.00 MiB
Total PE 12543
Alloc PE / Size 12543 / <49.00 GiB
Free PE / Size 0 / 0
VG UUID cW9c2V-vr4E-TyTF-WOhy-oCJ7-xXlc-rjLRxT
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 50G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 49G 0 part
├─rhel-root 253:0 0 47G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm
vdb 252:16 0 80G 0 disk
[root@k8s-node1 ~]# pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created.
[root@k8s-node1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name rhel
PV Size <49.00 GiB / not usable 192.00 KiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12543
Free PE 0
Allocated PE 12543
PV UUID hY6OKe-Of3E-GPNj-UhzE-VKHw-XquG-s3Dl4o
"/dev/vdb" is a new physical volume of "80.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdb
VG Name
PV Size 80.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID mQW0ih-HGvO-dsiu-Gjd3-isfW-4rYc-plKJpC
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# vgextend rhel /dev/vdb
Volume group "rhel" successfully extended
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 128.99 GiB
PE Size 4.00 MiB
Total PE 33022
Alloc PE / Size 12543 / <49.00 GiB
Free PE / Size 20479 / <80.00 GiB
VG UUID cW9c2V-vr4E-TyTF-WOhy-oCJ7-xXlc-rjLRxT
[root@k8s-node1 ~]#
複製代碼
lvextend -L +80G /dev/rhel/root
複製代碼
[root@k8s-node1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/swap
LV Name swap
VG Name rhel
LV UUID YX63U1-53aJ-kMpC-f43q-ghND-MlwG-cyDQ7H
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2018-06-13 11:42:54 +0800
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID lbHA32-rdhb-KJUG-tyzO-4COC-9n6r-4h4Slz
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2018-06-13 11:42:54 +0800
LV Status available
# open 1
LV Size 120.00 GiB
Current LE 30720
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# xfs_growfs /dev/rhel/root
meta-data=/dev/mapper/rhel-root isize=512 agcount=19, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=20971520, 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 12319744 to 31457280
[root@k8s-node1 ~]#
複製代碼
[root@k8s-node1 ~]# df -Th /
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 120G 33G 88G 27% /
[root@k8s-node1 ~]#
複製代碼