Search This Blog

Showing posts with label vmware. Show all posts
Showing posts with label vmware. Show all posts

Tuesday, September 26, 2017

Export oVirt Image/Template for VMware

oVirt supports exporting your VM or template to multiple formats.  You can find a decent overview of the utility here, [[https://docs.openstack.org/image-guide/convert-images.html] https://docs.openstack.org/image-guide/convert-images.html]

 QCOW2 (KVM, Xen) - *.qcow2 QED (KVM) - *.qed raw - *.raw (Sometimes no file extension provided) VDI (VirtualBox) - *.vdi VHD (Hyper-V) - *.vpc VMDK (VMware) - *.vmdk

The utility to perform Exports is 'qemu-img' with the sub-command 'convert'

For example, I currently have a VM Template Image in my GlusterFS storage domain.  This storage domain is mounted through the hypervisor "rosie-carreiro", so I first SSH in to the hypervisor, and 'cd' to the path where the RAW template resides.

Using the oVirt admin console, I am able to identify that the template/image has a UUID of, bbb58b82-7252-41e2-9b28-72cbf74d98e4.
There are other CLI tools that allow you to query storage domains and resolve UUIDs to names, however the UI is pretty intuitive for new users.

When you run 'df -h' on an oVirt hypervisor, you can see the mount points used:
pedro-godines.mycompany.com:/home/exports/iso  399G   25G  374G   7% /rhev/data-center/mnt/pedro-godines.mycompany.com:_home_exports_isoterri-wolven.mycompany.com:/home/exports       847G  136G  711G  17% /rhev/data-center/mnt/terri-wolven.mycompany.com:_home_exportsrosie-carreiro.mycompany.com:/home/exports     8.2T  761G  7.4T  10% /rhev/data-center/mnt/rosie-carreiro.mycompany.com:_home_exportsglusterfs.mycompany.com:/gv0                   1.9T   82G  1.8T   5% /rhev/data-center/mnt/glusterSD/glusterfs.mycompany.com:_gv0

In this case the Template is in the GlusterFS "gv0" volume, so I first 'cd' to /rhev/data-center/mnt/rosie-carreiro... and find the directory with the UUID, bbb58b82-7252-41e2-9b28-72cbf74d98e4.

  [root@devops bbb58b82-7252-41e2-9b28-72cbf74d98e4]# ls -ahlt  total 33G  drwxr-xr-x. 9 36 36 4.0K Aug 25 19:08 ..  drwxr-xr-x. 2 36 36 4.0K Aug 25 13:16 .  -rw-r--r--. 1 36 36  318 Aug 25 13:16 4b66fd92-99a6-4651-8288-24f50fd3596a.meta  -rw-rw----. 1 36 36  40G Aug 25 13:16 4b66fd92-99a6-4651-8288-24f50fd3596a  -rw-rw----. 1 36 36 1.0M Aug 25 12:58 4b66fd92-99a6-4651-8288-24f50fd3596a.lease

You can also view the metadata which specifies the format and description.

  [root@devops bbb58b82-7252-41e2-9b28-72cbf74d98e4]# cat 4b66fd92-99a6-4651-8288-24f50fd3596a.meta  DOMAIN=8fe3f7f3-15c9-4376-b20e-5e237b31b185  CTIME=1503680317  FORMAT=RAW  DISKTYPE=2  LEGALITY=LEGAL  SIZE=83886080  VOLTYPE=SHARED  DESCRIPTION={"DiskAlias":"Windows7_Disk1","DiskDescription":""}  IMAGE=bbb58b82-7252-41e2-9b28-72cbf74d98e4  PUUID=00000000-0000-0000-0000-000000000000  MTIME=0  POOL_UUID=  TYPE=SPARSE  GEN=0  EOF

You can now export the template/image to your desired format:

  [root@rosie-carreiro bbb58b82-7252-41e2-9b28-72cbf74d98e4]# qemu-img convert -f raw -O vmdk -o adapter_type=lsilogic 4b66fd92-99a6-4651-8288-24f50fd3596a /root/DevImage-1.1.vmdk
Once completed, verify:  [root@rosie-carreiro bbb58b82-7252-41e2-9b28-72cbf74d98e4]# ls -halt /root/DevImage-1.1.vmdk  -rw-r--r--. 1 root root 33G Aug 27 16:58 /root/DevImage-1.1.vmdk

NOTE: adapter_type=lsilogic is important because qemu-img VMDK output defaults to using IDE.  This means that you cannot later extend the size of the disk in VMware, as the option will actually be grayed out/disabled in vSphere.  Use the lsilogic scsi controller format to support extending your disks.

Friday, November 1, 2013

Export OVF from VMware Player

Get OVF Tool: https://my.vmware.com/web/vmware/details?downloadGroup=OVFTOOL350&productId=352

From CLI (windows for me, but should be same on other platforms):

C:\Program Files\VMware\VMware OVF Tool\> ovftool "C:\Users\Sam\Documents\Virtual Machines\VmDemo\VmDemo.vmx" C:\Users\Sam\Desktop\VmDemo.ovf

Opening VMX source: C:\Users\Sam\Documents\Virtual Machines\VmDemo\VmDemo.vmx
Opening OVF target: C:\Users\Sam\Desktop\VmDemo.ovf
Writing OVF package: C:\Users\Sam\Desktop\VmDemo.ovf
Transfer Completed
Completed successfully

C:\Program Files\VMware\VMware OVF Tool> _

Wednesday, May 29, 2013

Export virtual machine from ESX server to OVF file

Previously I have posted an article on how to upload an OVA file to an VMware ESX server.  I recently had a task doing the opposite.  Here is an example using ovftool to download a vm from ESX server and creating portable OVF to deploy on another VMware server.

C:\Program Files\VMware\VMware OVF Tool>ovftool --noImageFiles "vi://root:password@esxHostname/ha-datacenter?ds=[datastore1] JBOSS 5.0.1.GA/JBOSS 5.0.1.GA.vmx" C:\Users\Charles\Desktop\l1-server.ovf


I have underlined above what you will need to change for your environment.  You can determine where your .vmx file is by looking at the disk settings for your VM in vSphere:




Tuesday, January 29, 2013

Deploy VMware OVA to Remote ESX

Often my customer site provides us with VMs that contain the framework which replicates their environment.  The big issue we have is that with only 8GB of RAM on the older corporate issued development laptops floating around, a VM that needs 6GB to run doesnt leave much space for jboss, eclipse and gwt developer. (And the usual Pandora, Outlook and Instant message client).

A work around I discovered is to deploy these virtual machines to a dedicated server running VMware ESX.

Traditionally I would upload an ISO to the datastore, create a VM configuration.  Mount the ISO, install the OS and configure the network settings manually.

If you already have a VM configured to use DHCP, then its a breeze with the ovftool offered by VMware.

The command is as follows:

ovftool -ds=datastore1 -nw="VM Network" -st=OVA C:\Users\Charles\Downloads\GM_Dev_Local-OWF6.ova vi://root:[password]@[host]



After 100%




That's it!

Thursday, November 29, 2012

Adding Space to Linux LVM

After looking around at many different forums I have figured out how to properly add additional space to your VM.

In my situation I had a RHEL5 Virtual Machine running in VMware ESXi.  The machine had 50GB of space and we quickly ran out.

The first thing I did was go into the Settings for the VM using vSphere and resized the physical disk from 50GB to 256GB.

The next step was to reboot the Virtual Machine so that it would recognize the larger physical disk.  I rebooted the machine and the larger physical disk was apparent when typing the command,

#fdisk -l


Disk /dev/sda: 274.8 GB, 274877906944 bytes
255 heads, 63 sectors/track, 33418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        6527    52323705   8e  Linux LVM


Notice that although there are 33418 cylinders in my new 274.8 GB disk, that my second primary partition /dev/sda2 is only using cylinders 14-6527.  Resizing the Partition was not a safe option and I found many links showing users that had tried and failed.

The proper way to add space is to create an additional partition.  This can be done with fdisk.

#fdisk /dev/sda

Once you are in the fdisk utility you will want to create a new partition. 'n'
Specify this as a primary partition (1-4).  I chose 3 , as I already have 2 primary partitions.

You should notice that it will than ask you where to 'start'.  It should default to the 1st cylinder available (6528 in my case).  Press Enter.  Then 'end' should default to the last cylinder on the disk. (33418 in my case).  Press Enter.

Once the partition has been created you will need to change the partition ID to LVM.  The ID for a Linux LVM partition is 8e.  

Remember to press 'w' to write your fdisk changes to disk.  Once this is done reboot your VM.

Once the VM is back up you will want to run #vgdisplay to see your VolumeGroup name.



[root@ssdev ~]# vgdisplay
  /dev/hdc: open failed: No medium found
  --- Volume group ---
  VG Name               VolGroup00...


# pvcreate /dev/sda3
# vgextend VolGroup00 /dev/sda3

Next extend the LV:
[root@ssdev ~]# vgdisplay
  /dev/hdc: open failed: No medium found
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                7
  Open LV               7
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               255.84 GB
  PE Size               32.00 MB
  Total PE              8187
  Alloc PE / Size       1120 / 35.00 GB
  Free  PE / Size       7067 / 220.84 GB
  VG UUID               iF1177-sihW-YEb3-sLIj-AhVl-m6Fd-fMKQjg

[root@ssdev ~]# lvextend -L +220.84G /dev/VolGroup00/RootVol

In the last step i specified RootVol, as that is the volume i wanted resized ( / ).  lvdisplay will list the different volumes you have, and where they are mounted:

[root@ssdev ~]# lvdisplay
  /dev/hdc: open failed: No medium found
  --- Logical volume ---
  LV Name                /dev/VolGroup00/RootVol
  VG Name                VolGroup00
  LV UUID                N7lwvY-uqMg-2PfL-R4Ph-Dnh6-9hpu-a2vWeo
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                4.00 GB
  Current LE             128
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


Last step, resize the filesystem on the LV you just extended:

[root@ssdev ~]# resize2fs -p /dev/VolGroup00/RootVol
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/RootVol is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/RootVol to 58941440 (4k) blocks.

The filesystem on /dev/VolGroup00/RootVol is now 58941440 blocks long.

[root@ssdev ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-RootVol
                        223030      2322    209198   2% /
/dev/mapper/VolGroup00-VarVol
                          2976       137      2686   5% /var
/dev/mapper/VolGroup00-SrvVol
                         19839       855     17960   5% /srv
/dev/mapper/VolGroup00-VarLogVol
                          3968       182      3582   5% /var/log
/dev/mapper/VolGroup00-VarLogAuditVol
                           992        46       895   5% /var/log/audit
/dev/mapper/VolGroup00-HomeVol
                          1984        68      1815   4% /home
/dev/sda1                   99         9        86   9% /boot
tmpfs                     1510         0      1510   0% /dev/shm
[root@ssdev ~]#

This step should take a while, you can see the disk I/O in vSphere: