Pages

Showing posts with label vm. Show all posts
Showing posts with label vm. Show all posts

Sunday, August 28, 2011

Clone VM in ESX without vCenter



Login to the ESX/ESXi console to clone vm1 datastore to vm2. 


$ cd /vmfs/volumes/datastore/
$ mkdir vm2
$ vmkfstools -i vm1/vm1.vmdk vm2/vm2.vmdk


Next, create vm2 from the client GUI and choose existing disk option pointing to the newly created vm2.vmdk. 


More details available in the excellent article here.


To read how to access the hidden ESXi console, refer to this article.



Thursday, August 25, 2011

Could not power on VM : No space left on device - Failed to power on VM

With VMWare's ESX or ESXi, "Could not power on VM : No space left on device - Failed to power on VM" is a common sight when trying to start a VM.

This error seems bizarre especially when you are actually trying to increase the guest RAM and the error is about disk space. The cause could be the following:
  1. By default, ESX will configure a swap on the VM's datastore equal to the RAM. So, when RAM is increased, more disk space is required. The fix is to reserve memory in resource allocation settings for the VM.
  2. There really isn't enough disk space on the datastore. Reduce Hard Disk size for the VM.

Sunday, May 22, 2011

Editing Xen System.img

This post is useful when you want to change system configuration files of a stopped guest VM without botting up the guest first. This method can be used especially when your guest VM crashes or hangs during boot up due to a configuration error.


The following steps have been tested on Xen 4 and Oracle VM 2.2 as well for a Linux guest VM. From DOM0: 


Check FS Type
fdisk -u -l System.img

If FS type is ext3, you can directly mount a partition using lomount, otherwise follow the mounting LV's steps.

Mount Ext3 Partitions

Linux system.img with ext3 partitions can be mounted as:
lomount -diskimage System.img -partition 2 /mnt

Mounting LV's

# Mounting guest's root partition locally
# Find a free loop device
loop_dev=`losetup -f`

# Now bind the image file to that loop device
losetup ${loop_dev} System.img

# Next, scan the loop device for partitions
kpartx -av ${loop_dev}

# If /dev/mapper doesn't list LVs for the partitions from kpartx, find LV:
vgscan
vgchange -ay sysvg

# Mount the desired LVM
mount /dev/mapper/loop0p2 /mnt

LVs UnMounting
# After editing in /mnt, unmount and remove partitions:
umount /mnt

# Disable the LV
vgchange -an /dev/mapper/loop0p2

# Remove the discovered partitions
kpartx -dv ${loop_dev}

# Delete the loop device
losetup -d ${loop_dev}