KVM如何在线添加新硬盘到Linux虚拟机上

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,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值