The Great Global Warming Swindle

These days, if you are skeptical about the litany around climate change, you are suddenly like as you are holocaust denier. The environmental movement really it is a political activist movement and they have become hugely influential at a global level. And every politician is aware of that today. Whether you are in the left, in the middle or the right, you to pay homage to the environment.

Mounting partitions within image file

kpartx is a tool which creates device maps from partition tables. Assume that you have a .img disk image which contains various partitions and you want to mount one or more of the partitions. kpartx will map each partition to a loop device under /dev/mapper and will allow you to mount the loop device to a local directory and access the files.
Mapping an image:

# kpartx -a /foo/bar/disk.img

Checking which loop device was used to mount the partitions:

# kpartx -l /foo/bar/disk.img
loop1p1 : 0 8177022 /dev/loop1 63

The disk image has one partition and is mapped to /dev/loop1p1. You can now mount the partition:

# mount /dev/mapper/loop1p1 /mnt/img

Once finished, you can remove the mapper device:

# kpartx -d /foo/bar/disk.img
loop deleted : /dev/loop1

Clone Virtual Machine on VMware Server 2.0

When you need a bunch of virtual machines with the same set up is really boring setting every single on from scratch. Cloning of virtual machines is VMware’s ESX is only a few clicks away. For the VMware Server product you need a bit of extra work as it lucks that functionality.
Bellow are some simple steps to get a virtual machines cloned:

  • Create a new directory named after the name of the new virtual machine. You’ll need to create in the directory you decided to host the virtual machines. This is usually /var/lib/vmware/Virtual\ Machines
  • Copy the disk image of the virtual machines you want to clone into the newly created directory and name it after the name of the new virtual machine. [ shutdown the existing virtual machine before copying the disk image ]
  • Copy the vmname.vmx and vmname.vmxf files form the directory of the existing virtual machine into the directory of the new virtual machine.
  • Changes in vmname.vmx:
    – Replace all the entries that contain the existing virtual machine’s name with the new name. These are the values of the attrubutes: nvram, displayName, extendedConfigFile and scsi0:0.fileName. The last one may be different depending on the controller you’ll be providing to the virtual machine.
    – Replace the existing UUIDs (you can generate new ones using the uuidgen command).
    – Replace MAC address (you can change just a few digits).
    – Replace the (change a few digits here as well).
  • Changes in vmname.vmxf
    – Replace the existing VMId with a new id generated by uuidgen.
    – Replace the vmxPathName attribute.

Once you are done with all these, you can launch the VMware Infrastructure Web Access (type vmware in the console) and add the cloned virtual machine in the inventory:

  • Virtual Machine -> Add Virtual Machine to inventory -> Select the new virtual machine from the inventory.

You can now start up the cloned virtual machine. You’ll need to change a couple of things in the OS settings of the virtual machine:

  • /etc/hosts -> Replace old hostname with new one
  • /etc/sysconfig/network -> Replace old hostname with new one
  • /etc/sysconfig/network-scripts/ifcfg-eth0 -> Replace MAC address with new one and any other settings specific to the host

lcfg-xen component

For the last few months I have been spending some time on writing a proper component for the LCFG platform for managing up to a certain level the the Xen resources. The very first version of the component only managed the Xen daemons, e.g: xend and xendomains. It was performing a check if the Xen virtual network interfaces were up and if not bringing them up. Very basic functionality.

On Friday has been released the second version version of the component with a few improvements:

  • Manage guest’s configuration file
  • Manage list of guest’s disk image
  • Manage list of guest’s virtual networking interfaces
  • Start guest at boot time
  • Shutdown guest at poweroff
  • Option for controlling the xendomains daemon or not

A few words more:

Manage guest’s configuration file

The component provides appropriate resources for setting the name of the guest, the initial memory, the maximum memory, the number of CPUs, the guest’s disks, the guest’s network interfaces, an ISO or CD/DVD path.

– Manage list of guest’s disk images

A list of disk images can be specified. File name, size and root path location is specified for each entry. If the disk image does not exist it will be created with the requested size and ready to be used. If there is already one it will be untouched. If the path is not specified, the default (/var/lib/xen/images) will be assumed.
A physical partition can not be managed at this stage. It will have to created manually and then specify the name in the list and the path in the corresponding resource.

– Manage list of guest’s virtual network interfaces

A list of network interfaces for the guest can be specified. For each interface the MAC address must be specified and can also be specified the bridge interface that will be used as well as the networking script. If there is no specification for the bridge and the script, the default values will be assumed (xenbr0 and network-bridge respectively).

– Start guest at boot time

If boot resource is set to yes for a guest then that guest will boot automatically when the component will start.

– Shutdown guest at poweroff

If boot resource is set to yes for a guest then that guest will shut down automatically when the component will stop.

– Option for controlling the xendomains daemon or not

The xendomains daemon controls the status of the guests. If the resource is set to yes, when the comonent restart or configures itself, the corresponding methods of the xendomains daemon will run and by that the running guests will be affected. If the resource is set to no the guests will keep running and the component will restart only the xend daemon. However, the resource is not taken under consideration when the component stops where any running guest will shutdown.

– Boot from ISO image or CD/DVD disk

The path to the ISO image or the physical CD/DVD drive can be specified. If so the guest will boot from that media rather than the system disk.

Resources example:

 !xen.virtualmachines           mADD(sl5vm)
 !xen.name_sl5vm                mSET(sl5vm)
 !xen.uuid_sl5vm                mSET(6f2cffa1-21f6-43b4-8c52-08b8277a38a3)
 !xen.maxmem_sl5vm              mSET(1024)
 !xen.memory_sl5vm              mSET(1024)
 !xen.vcpus_sl5vm               mSET(2)
 !xen.disks_sl5vm               mADD(osdisk, swap)
 !xen.diskname_sl5vm_osdisk     mSET(sl5vmos)
 !xen.disktype_sl5vm_osdisk     mSET(image)
 !xen.disksize_sl5vm_osdisk     mSET(24)
 !xen.diskname_sl5vm_swap       mSET(sl5vmswap)
 !xen.disktype_sl5vm_swap       mSET(image)
 !xen.disksize_sl5vm_swap       mSET(1)
 !xen.vifs                      mADD(vif1)
 !xen.mac_sl5vm_vif1            mSET(00:1e:c9:52:30:ce)
 !xen.bridge_sl5vm_vif1         mSET(xenbr1)
 !xen.script_sl5vm_vif1         mSET(vif-bridge-private)
 !xen.cdpath_sl5vm              mSET(/opt/xen/iso/sl5.iso)
 !xen.boot_sl5vm                mSET(yes)

Based on these resources the component will create a new guest called sl5vm and its configuration file will be /etc/xen/sl5vm. A specific UUID is given, 1G of memory will be allocated and two CPUs will be used. The component will create two disk images. 24G for the system disk and 1G for a disk image to be used as swap memory. The swap disk image will be stores in a different location than the default, /var/lib/xen/images/swap. The guest will also have two network interfaces (eth0 and eth1). The second one will be assigned a private LAN address.