How to extend a virtual hard drive - The Red Hat way

How to extend a virtual hard drive

There is no easy way to extend a hard drive on the Red Hat Virtualization platform (RHEV 3.0). Something so simple if you use VMware or XenCenter it's impossible to achieve using the Red Hat Enterprise Virtualization Manager.

Be careful...

How to
 (This is valid for a server or a desktop virtual machine)
1. Shutdown the server.

2. Export the server to the Export Domain. This will be a NFS file system.

3. Log on to the server where the Export Domain is attached.

4. You have to find the exported virtual machine. It will be better if at that moment the exported virtual machine it's the only one on the Export Domain. The virtual machine name it will be something very strange...

"/opt/exports is my NFS mount point"
cd /opt/exports/71439199-46c8-416f-a423-6db1afb68bdd
drwxr-xr-x 2 vdsm kvm 4096 jul 25 12:07 dom_md
drwxr-xr-x 3 vdsm kvm 4096 ago 9 11:51 images
drwxr-xr-x 4 vdsm kvm 4096 jul 25 12:08 master
"Here will be our virtual machine hard drive"

cd images/0d0e949a-ec31-4e15-b5da-6e1a88d1d139
-rw-rw---- 1 vdsm kvm 8589934592 ago 9 12:02 007135e1-7963-40c8-b013-0960b04a8854
-rw-r--r-- 1 vdsm kvm 325 ago 9 11:51 007135e1-7963-40c8-b013-0960b04a8854.meta

5. Extend the hard drive with qemu-img.

Change Size (15 Gb more in this example)
qemu-img resize 04286729-96d0-43a1-a7f4-dd9189f5a161 +15G
Check new size
-rw-rw---- 1 vdsm kvm 24696061952 ago 9 12:14 007135e1-7963-40c8-b013-0960b04a8854
-rw-r--r-- 1 vdsm kvm 325 ago 9 11:51 007135e1-7963-40c8-b013-0960b04a8854.meta
6. Edit the virtual machine file definition.
Change virtual machine values to the new hard drive size (fichero ovf)

cd /opt/exports/71439199-46c8-416f-a423-6db1afb68bdd
cd master/vms/42340635-92db-4395-a39e-405611839972
vi 42340635-92db-4395-a39e-405611839972.ovf

Values to change:
<?xml version='1.0' encoding='UTF-8'?><ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1/" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ovf:version="3.0.0.0"><References><File ovf:href="0d0e949a-ec31-4e15-b5da-6e1a88d1d139/007135e1-7963-40c8-b013-0960b04a8854" ovf:id="007135e1-7963-40c8-b013-0960b04a8854" ovf:size="8589934592" ovf:description="_ActiveImage_xxxxxxx_Tue May xxx xx:xx:xx WEST xxxx" /></References><Section xsi:type="ovf:NetworkSection_Type"><Info>List of networks</Info><Network ovf:name="Network 1" /></Section><Section xsi:type="ovf:DiskSection_Type"><Info>List of Virtual Disks</Info><Disk ovf:diskId="007135e1-7963-40c8-b013-0960b04a8854" ovf:size="8" ovf:actual_size="8" ovf:vm_snapshot_id="939f5e47-5391-46aa-a521-96a4
851a82d9" ovf:parentRef="" ovf:fileRef="0d0e949a-ec31-4e15-b5da-6e1a88d1d139/007135e1-7963-40c8-b013-0960b04a8854" ovf:format="http://www.vmware.com/specifications/vmdk.html#sparse" ovf:volume-format="RAW" ovf:volume-type="Preallocated" ovf:disk-interface="VirtIO" ovf:disk-type="System" ovf:boot="true" ovf:wipe-after-delete="false" /></Section><Content ovf:id="out" xsi:type="ovf:VirtualSystem_Type"><Name>cacharro</Name><TemplateId>00000000-0000-0000-0000-000000000000</TemplateId><TemplateName>Blank</TemplateName><Description>xxxxxxxxxxxx</Description><Domain></Domain><CreationDate>xxxx/xx/xx 06:38:52</CreationDate><IsInitilized>true</IsInitilized><IsAutoSuspend>false</IsAutoSuspend><
TimeZone></TimeZone><IsStateless>false</IsStateless><Origin>0</Origin><default_boot_sequence>0</default_boot_sequence><VmType>1</VmType><DefaultDisplayType>1</DefaultDisplayType><MinAllocatedMem>1024</MinAllocatedMem><Section ovf:id="4234
0635-92db-4395-a39e-405611839972" ovf:required="false" xsi:type="ovf:OperatingSystemSection_Type"><Info>Guest Operating System</Info><Description>OtherLinux</Description></Section><Section xsi:type="ovf:VirtualHardwareSection_Type"><Info>
1 CPU, 1024 Memeory</Info><System><vssd:VirtualSystemType>RHEVM 3.0.0.0</vssd:VirtualSystemType></System><Item><rasd:Caption>1 virtual cpu</rasd:Caption><rasd:Description>Number of virtual CPU</rasd:Description><rasd:InstanceId>1</rasd:In
stanceId><rasd:ResourceType>3</rasd:ResourceType><rasd:num_of_sockets>1</rasd:num_of_sockets><rasd:cpu_per_socket>1</rasd:cpu_per_socket></Item><Item><rasd:Caption>1024 MB of memory</rasd:Caption><rasd:Description>Memory Size</rasd:Description><rasd:InstanceId>2</rasd:InstanceId><rasd:ResourceType>4</rasd:ResourceType><rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits><rasd:VirtualQuantity>1024</rasd:VirtualQuantity></Item><Item><rasd:Caption>Drive 1</rasd:Caption><ras
d:InstanceId>007135e1-7963-40c8-b013-0960b04a8854</rasd:InstanceId><rasd:ResourceType>17</rasd:ResourceType><rasd:HostResource>0d0e949a-ec31-4e15-b5da-6e1a88d1d139/007135e1-7963-40c8-b013-0960b04a8854</rasd:HostResource><rasd:Parent>00000
000-0000-0000-0000-000000000000</rasd:Parent><rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template><rasd:ApplicationList></rasd:ApplicationList><rasd:StorageId>f02a341d-fdce-4abe-8f86-94c26492a088</rasd:StorageId><rasd:Storag
ePoolId>48e51ec0-5ef7-11e1-9407-00505696000d</rasd:StoragePoolId><rasd:CreationDate>xxxx/xx/xx 11:08:13</rasd:CreationDate><rasd:LastModified>xxxx/xx/xx 11:08:13</rasd:LastModified><rasd:last_modified_date>xxxx/xx/xx 11:02:37</rasd:last_modified_date></Item><Item><rasd:Caption>Ethernet adapter on rhevm</rasd:Caption><rasd:InstanceId>3</rasd:InstanceId><rasd:ResourceType>10</rasd:ResourceType><rasd:ResourceSubType>3</rasd:ResourceSubType><rasd:Connection>rhevm</rasd:Connec
tion><rasd:Name>nic1</rasd:Name><rasd:MACAddress>00:1a:4a:a8:02:03</rasd:MACAddress><rasd:speed>1000</rasd:speed></Item><Item><rasd:Caption>USB Controller</rasd:Caption><rasd:InstanceId>4</rasd:InstanceId><rasd:ResourceType>23</rasd:ResourceType><rasd:UsbPolicy>Enabled</rasd:UsbPolicy></Item><Item><rasd:Caption>Graphical Controller</rasd:Caption><rasd:InstanceId>5</rasd:InstanceId><rasd:ResourceType>20</rasd:ResourceType><rasd:VirtualQuantity>1</rasd:VirtualQuantity></Item></Section></Content></ovf:Envelope>
7. You have to remove the exported virtual machine from the VMs prior to import the extended one.

8. Import the extended server.


That's all folks.

Comentarios

Entradas populares