创建磁盘: qemu-img create -f qcow2 /data/centos73 _2.qcow25G 关闭虚拟机: virsh destroy centos73 编辑配置文件: virsh edit centos73 复制增加如下:注意是vdb,qcow2 <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/data/kvm/centos733.qcow2'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </disk> <disktype='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/data/kvm/centos733_2.qcow2'/> <target dev='vdb' bus='virtio'/> <address type='pci' domain='0x0000'bus='0x00' slot='0x07' function='0x0'/>(删除,开启domain重新生成) </disk> [root@localhost~]# fdisk -l Disk/dev/vda: 14.0 GB, 13958643712 bytes, 27262976 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk labeltype: dos Diskidentifier: 0x000b21a9 Device Boot Start End Blocks Id System /dev/vda1 * 2048 2099199 1048576 83 Linux /dev/vda2 2099200 20971519 9436160 8e Linux LVM /dev/vda3 20971520 27262975 3145728 8e Linux LVM Disk/dev/vdb: 5368 MB, 5368709120 bytes, 10485760 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk/dev/mapper/cl-root: 11.8 GB, 11802771456 bytes, 23052288 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk/dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes [root@localhost~]# fdisk /dev/vdb Welcome tofdisk (util-linux 2.23.2). Changeswill remain in memory only, until you decide to write them. Be carefulbefore using the write command. Device doesnot contain a recognized partition table Building anew DOS disklabel with disk identifier 0xe3fb71dc. Command (mfor help): n Partitiontype: p primary (0 primary, 0 extended, 4 free) e extended Select(default p): p Partitionnumber (1-4, default 1): Firstsector (2048-10485759, default 2048): Usingdefault value 2048 Lastsector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): Usingdefault value 10485759 Partition 1of type Linux and of size 5 GiB is set Command (mfor help): p Disk/dev/vdb: 5368 MB, 5368709120 bytes, 10485760 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk labeltype: dos Diskidentifier: 0xe3fb71dc Device Boot Start End Blocks Id System /dev/vdb1 2048 10485759 5241856 83 Linux Command (mfor help): t Selectedpartition 1 Hex code(type L to list all codes): 8e Changedtype of partition 'Linux' to 'Linux LVM' Command (mfor help): w Thepartition table has been altered! Callingioctl() to re-read partition table. Syncingdisks. [root@localhost~]# fdisk -l Disk/dev/vda: 14.0 GB, 13958643712 bytes, 27262976 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk labeltype: dos Diskidentifier: 0x000b21a9 Device Boot Start End Blocks Id System /dev/vda1 * 2048 2099199 1048576 83 Linux /dev/vda2 2099200 20971519 9436160 8e Linux LVM /dev/vda3 20971520 27262975 3145728 8e Linux LVM Disk/dev/vdb: 5368 MB, 5368709120 bytes, 10485760 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk labeltype: dos Diskidentifier: 0xe3fb71dc Device Boot Start End Blocks Id System /dev/vdb1 2048 10485759 5241856 8e Linux LVM Disk/dev/mapper/cl-root: 11.8 GB, 11802771456 bytes, 23052288 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk/dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units =sectors of 1 * 512 = 512 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes [root@localhost~]# pvs PV VG Fmt Attr PSize PFree /dev/vda2 cl lvm2 a-- 9.00g 0 /dev/vda3 cl lvm2 a-- 3.00g 0 [root@localhost~]# pvcreate anaconda-ks.cfg .bash_logout .bashrc .tcshrc .bash_history .bash_profile .cshrc [root@localhost~]# pvcreate /dev/vdb1 Physical volume "/dev/vdb1"successfully created. [root@localhost~]# vgex vgexport vgextend [root@localhost~]# vgextend anaconda-ks.cfg .bash_logout .bashrc .tcshrc .bash_history .bash_profile .cshrc [root@localhost~]# vgextend cl /dev/vdb1 Volume group "cl" successfullyextended [root@localhost~]# vgdisplay --- Volume group --- VG Name cl System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 16.99 GiB PE Size 4.00 MiB Total PE 4349 Alloc PE / Size 3070 / 11.99 GiB Free PE / Size 1279 / 5.00 GiB VG UUID Veeoup-1E2G-3E5C-a794-CBrH-C1iY-qrSJzM [root@localhost~]# lvdisplay --- Logical volume --- LV Path /dev/cl/swap LV Name swap VG Name cl LV UUID 4jfTAH-1nQp-XfCX-XVOs-qXwj-REuS-qaSw3Y LV Write Access read/write LV Creation host, time localhost.localdomain,2017-08-21 00:13:02 +0800 LV Status available # open 2 LV Size 1.00 GiB Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl LV UUID 7fM2Qm-YRZc-7iG3-OIej-q5jQ-5NnA-Zdnpmv LV Write Access read/write LV Creation host, time localhost.localdomain,2017-08-21 00:13:03 +0800 LV Status available # open 1 LV Size 10.99 GiB Current LE 2814 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 [root@localhost~]# lvextend anaconda-ks.cfg .bash_logout .bashrc .tcshrc .bash_history .bash_profile .cshrc [root@localhost~]# lvextend /dev/cl/root /dev/vdb1 Size of logical volume cl/root changed from10.99 GiB (2814 extents) to 15.99 GiB (4093 extents). Logical volume cl/root successfully resized. [root@localhost ~]# resize2fs /dev/cl/root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open/dev/cl/root Couldn't find valid filesystem superblock. [root@localhost~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 11G 1.1G 10G 10% / devtmpfs 486M 0 486M 0% /dev tmpfs 497M 0 497M 0% /dev/shm tmpfs 497M 6.6M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 1014M 139M 876M 14% /boot tmpfs 100M 0 100M 0% /run/user/0 [root@localhost~]# resize2fs /dev/mapper/cl-root resize2fs1.42.9 (28-Dec-2013) resize2fs:Bad magic number in super-block while trying to open /dev/mapper/cl-root Couldn'tfind valid filesystem superblock. [root@localhost~]# xfs_growfs /dev/mapper/cl-root meta-data=/dev/mapper/cl-root isize=512 agcount=6, agsize=524032 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=2881536, 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 blockschanged from 2881536 to 4191232 [root@localhost~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 16G 1.1G 15G 7% / devtmpfs 486M 0 486M 0% /dev tmpfs 497M 0 497M 0% /dev/shm tmpfs 497M 6.6M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 1014M 139M 876M 14% /boot tmpfs 100M 0 100M 0% /run/user/0 当然也可以按照上面的思路把/dev/vdb 加入到 lvm里面去,测试成功
转载于:https://blog.51cto.com/m51cto/1958519