KVM中增加磁盘作为扩展
创建空磁盘
通过qemu-img 命令创建qcow2的磁盘,也可以创建其他类型的磁盘,但扩展磁盘的时候,在kvm里面的命令有所区别
[root@server10 ~]# qemu-img create -f qcow2 /opt/extern.qcow2 100G
Formatting '/opt/extern.qcow2', fmt=qcow2 size=107374182400 encryption=off
[root@server10 opt]# qemu-img info extern.qcow2
image: extern.qcow2
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 294M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
热挂载磁盘 ,注意,增加磁盘必须使用-subdriver,否则不认识kvm内部不认识磁盘
直接挂载磁盘到虚拟机.虚拟机需要在运行状态可直接看到有其他硬盘被挂载
[root@server10 opt]# virsh attach-disk centos7V1-bigdata /opt/extern.qcow2 vdb --subdriver=qcow2 --persistent
virsh help attach-disk
NAME
attach-disk - attach disk deviceSYNOPSIS
attach-disk <domain> <source> <target> [--targetbus <string>] [--driver <string>] [--subdriver <string>] [--iothread <string>] [--cache <string>] [--io <string>] [--type <string>] [--mode <string>] [--sourcetype <string>] [--serial <string>] [--wwn <string>] [--rawio] [--address <string>] [--multifunction] [--print-xml] [--persistent] [--config] [--live] [--current]DESCRIPTION
Attach new disk device.OPTIONS
[--domain] <string> domain name, id or uuid
[--source] <string> source of disk device
[--target] <string> target of disk device
--targetbus <string> target bus of disk device
--driver <string> driver of disk device
--subdriver <string> subdriver of disk device
--iothread <string> IOThread to be used by supported device
--cache <string> cache mode of disk device
--io <string> io policy of disk device
--type <string> target device type
--mode <string> mode of device reading and writing
--sourcetype <string> type of source (block|file)
--serial <string> serial of disk device
--wwn <string> wwn of disk device
--rawio needs rawio capability
--address <string> address of disk device
--multifunction use multifunction pci under specified address
--print-xml print XML document rather than attach the disk
--persistent make live change persistent
--config affect next boot
--live affect running domain
--current affect current domain
创建分区
选择卷标必须使用8e,这个表示是LVM磁盘格式
[root@localhost ~]# fdisk /dev/vdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x14401f11.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number