KVM如何在线添加新硬盘:
1)新建一个qcow2格式的大小为5G,磁盘名称为centos67_add.qcow2的磁盘
1
2
3
4
5
|
[root@kvm-server01 ~]
# cd /kvmdata/
[root@kvm-server01 kvmdata]
# ls
centos67.qcow2 win2003.qcow2
[root@kvm-server01 kvmdata]
# qemu-img create -f qcow2 centos67_add.qcow2 5G
Formatting
'centos67_add.qcow2'
,
fmt
=qcow2 size=5368709120 encryption=off cluster_size=65536
|
2)查看磁盘的详细信息
1
2
3
4
5
6
|
[root@kvm-server01 kvmdata]
# qemu-img info centos67_add.qcow2
image: centos67_add.qcow2
file
format
: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 136K
cluster_size: 65536
|
3)将磁盘附加到虚拟机centos67中
1
2
|
[root@kvm-server01 kvmdata]
# virsh attach-disk centos67 /kvmdata/centos67_add.qcow2 vda --cache=none --subdriver=qcow2
Disk attached successfully
|
4)在虚拟机中进行验证
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
[root@centos67-mini ~]
# fdisk -l
Disk
/dev/sda
: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors
/track
, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical
/physical
): 512 bytes / 512 bytes
I
/O
size (minimum
/optimal
): 512 bytes / 512 bytes
Disk identifier: 0x0007bea2
Device Boot Start End Blocks Id System
/dev/sda1
* 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2
64 1306 9972736 8e Linux LVM
Disk
/dev/mapper/VolGroup-lv_root
: 9168 MB, 9168748544 bytes
255 heads, 63 sectors
/track
, 1114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical
/physical
): 512 bytes / 512 bytes
I
/O
size (minimum
/optimal
): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk
/dev/mapper/VolGroup-lv_swap
: 1040 MB, 1040187392 bytes
255 heads, 63 sectors
/track
, 126 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical
/physical
): 512 bytes / 512 bytes
I
/O
size (minimum
/optimal
): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk
/dev/vda
: 5368 MB, 5368709120 bytes
16 heads, 63 sectors
/track
, 10402 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical
/physical
): 512 bytes / 512 bytes
I
/O
size (minimum
/optimal
): 512 bytes / 512 bytes
Disk identifier: 0x00000000
|
注:再次说明只有RHEL/CentOS/OEL6.x及高版本的在线添加磁盘,虚拟机直接可以在线识别。
本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1712754,如需转载请自行联系原作者