KVM----Virtual Disk expansion

Source: Internet
Author: User

disk is not available, add a new hard disk, or expanding the current disk .

1, the current disk status of the sub-machine

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/96/wKiom1YiXBGSEgqpAAENvM3dPMY211.jpg "title=" Image.png "alt=" Wkiom1yixbgsegqpaaenvm3dpmy211.jpg "/>

View the system in the master machine

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/96/wKiom1YiXEaQxodAAAFrPP8G_SM586.jpg "title=" Image.png "alt=" Wkiom1yixeaqxodaaafrpp8g_sm586.jpg "/>

[Email protected] ~]# qemu-img resize/caimz/caimz2.img +5g
Image resized.
[Email protected] ~]# qemu-img info/caimz/caimz2.img
Image:/caimz/caimz2.img
File Format:raw
Virtual size: 35G (37580963840 bytes)
Disk size: 30G

[Email protected] ~]# Virsh start caimz2--console
Error:domain is already active

[Email protected] ~]#
[Email protected] ~]# Virsh start caimz2--console
Error:domain is already active

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/96/wKiom1YiXGbRp6zjAAKVR0L0mWs869.jpg "title=" Image.png "alt=" Wkiom1yixgbrp6zjaakvr0l0mws869.jpg "/>


Operation Steps:

[Email protected] ~]# fdisk-l

disk/dev/vda:37.6 GB, 37580963840 bytes
Heads, Sectors/track, 72817 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004583c

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.

disk/dev/mapper/volgroup-lv_root:30.6 GB, 30610030592 bytes
255 heads, Sectors/track, 3721 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000


disk/dev/mapper/volgroup-lv_swap:1073 MB, 1073741824 bytes
255 heads, Sectors/track, cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
28G 720M 26G 3%/
Tmpfs 250M 0 250M 0%/dev/shm
/DEV/VDA1 477M 31M 421M 7%/boot
[Email protected] ~]# fdisk-l

disk/dev/vda:37.6 GB, 37580963840 bytes
Heads, Sectors/track, 72817 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004583c

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.

disk/dev/mapper/volgroup-lv_root:30.6 GB, 30610030592 bytes
255 heads, Sectors/track, 3721 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000


disk/dev/mapper/volgroup-lv_swap:1073 MB, 1073741824 bytes
255 heads, Sectors/track, cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

[Email protected] ~]# Fdisk/dev/vda

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 3
First cylinder (1-72817, default 1): 62417
Last cylinder, +cylinders or +size{k,m,g} (62416-72817, default 72817): 72817

Command (M for help): P

disk/dev/vda:37.6 GB, 37580963840 bytes
Heads, Sectors/track, 72817 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004583c

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 4
First cylinder (1-72817, default 1):62417 #inode in/dev/vda2 are 62416, so we should start with 62417 .
Last cylinder, +cylinders or +size{k,m,g} (62417-72817, default 72817): 72817#结束

Command (M for help): P

disk/dev/vda:37.6 GB, 37580963840 bytes
Heads, Sectors/track, 72817 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004583c

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/DEV/VDA4 62417 728175242104Linux#新增加的那5G

Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition table failed with error 16:device or resource busy.
The kernel still uses the old table. The new table is being used at
The next reboot or after you run Partprobe (8) or KPARTX (8)
Syncing disks.
[Email protected] ~]# fdisk-l

disk/dev/vda:37.6 GB, 37580963840 bytes
Heads, Sectors/track, 72817 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004583c

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 62416 30944256 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/DEV/VDA4 62417 72817 5242104-up Linux

disk/dev/mapper/volgroup-lv_root:30.6 GB, 30610030592 bytes
255 heads, Sectors/track, 3721 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000


disk/dev/mapper/volgroup-lv_swap:1073 MB, 1073741824 bytes
255 heads, Sectors/track, cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

Create a physical volume

then add this/dev/vda4 to the LVM:

LS/DEV/VDA4 If you do not have this partition, you need to reboot.

[email protected] ~]#pvcreate/dev/vda4

Physical volume "/DEV/VDA4" successfully created

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/93/wKioL1YiXLOxka8FAACc7M6-1Mc723.jpg "title=" Image.png "alt=" Wkiol1yixloxka8faacc7m6-1mc723.jpg "/>

Now, VDA4, join the volgroup inside.

[Email protected] ~]# vgextend volgroup/dev/vda4
Volume Group "VolGroup" successfully extended

See if Vda4 belongs to the Volgroup group.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/96/wKiom1YiXK-QwtoDAACzxWmJHAg257.jpg "title=" Image.png "alt=" Wkiom1yixk-qwtodaaczxwmjhag257.jpg "/>

[Email protected] ~]# VGS
VG #PV #LV #SN Attr vsize vfree
VolGroup 2 2 0 wz--n-34.50g 5.00g

See logical volumes

[[email protected] ~]# LVS
LV VG Attr lsize Pool Origin data% meta% Move Log cpy%sync Convert
Lv_root Volgroup-wi-ao----28.51g
Lv_swap Volgroup-wi-ao----1.00g

Now we're going to add the 5G added to the lv_root.

[email protected] ~]# lvextend-l +100%free/dev/volgroup/lv_root
Size of Logical Volume Volgroup/lv_root changed from 28.51 Gib (7298 extents) to 33.50 Gib (8577 extents).
Logical Volume lv_root successfully resized
[[email protected] ~]# LVS
LV VG Attr lsize Pool Origin data% meta% Move Log cpy%sync Convert
lv_root Volgroup-wi-ao----.50g

Lv_swap Volgroup-wi-ao----1.00g

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/96/wKiom1YiXNTy73oDAASKVVNECgg938.jpg "title=" Image.png "alt=" wkiom1yixnty73odaaskvvnecgg938.jpg "/>650" this.width=650; "src=" http://s3.51cto.com/wyfs02/M02 /74/93/wkiol1yixqqjjq7yaapkqauldw8909.jpg "title=" Image.png "alt=" Wkiol1yixqqjjq7yaapkqauldw8909.jpg "/>


Add a new hard drive to enlarge:

1. Create a new disk

[Email protected] ~]# qemu-img create-f raw/caimz/caimz2_extend.img 5G
Formatting '/caimz/caimz2_extend.img ', Fmt=raw size=5368709120

2. Edit the configuration file

[Email protected] ~]# Virsh edit CAIMZ2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/96/wKiom1YiXQXDA6LvAAN8_HpA0vg800.jpg "title=" Image.png "alt=" Wkiom1yixqxda6lvaan8_hpa0vg800.jpg "/>


Add the. img disk that you just created.

Virsh Edit caimz2 is added as follows:

<disk type= ' file ' device= ' disk ' >

    </disk>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/93/wKioL1YiXUHAGQH0AALz8426WJ8141.jpg "title=" Image.png "alt=" Wkiol1yixuhagqh0aalz8426wj8141.jpg "/>

Save exit.

[Email protected] ~]# Virsh edit CAIMZ2

Domain caimz2 XML Configuration edited.

turn on virtual machine: Virsh start ciamz2
Enter virtual machine: Virsh console caizm2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/97/wKiom1YiXTDyojYOAAMtzn3leS0294.jpg "title=" Image.png "alt=" wkiom1yixtdyojyoaamtzn3les0294.jpg "/> format:mkfs.ext4/dev/vdb

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/97/wKiom1YiXUOz3HNOAAJ7YZ0X0W8035.jpg "title=" Image.png "alt=" Wkiom1yixuoz3hnoaaj7yz0x0w8035.jpg "/>

Mount use.

[Email protected] ~]# qemu-img resize/caimz/caimz1.qcow2 +5g
This image format does not the support resize


KVM----Virtual Disk expansion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.