Deploy a virtualized environment -- other alternatives
From Grid5000
Coupling Xen, LVM and Snapshotting methods
The problem with the method explained in Deploy a virtualized environment is that each virtual machines (vm) created will lead in duplicating the base image file. This file is about 400MB and thus the host's local disk may be unnecessarily solicited. Thus the LVM + snapshotting system may be interesting. With this method, instead of duplicating the same file N times for the N virtual machines, Xen will use the same base image and then for each vm create a "snapshot" of only a few MB.
- Connect the Nancy site frontend:
Reserve a node for deployment
Deploy the xen environment
- Then connect to the Xen host machine (<NODE> is the name of the node you reserved, to get it type cat $OAR_NODE_FILE | uniq):
- Add a virtual machine automatically by running the xen-lvm-add-domu script:
This will start a new vm based on the original domU image. Each time you call this script a new vm is thus created. Since we use LVM+snapshoting the total size used regardless of how many virtual machines we created will be less than 1GB. Try adding more than one vm, you'll see that Xen is able to run a lot of vms with this method...
List the vms with:
Connect to a vm (login: root -- password: grid5000):
Exit the vm with:
Modifying the domU image without connecting the virtual machine
You may want to do some changes on the domU image without connecting the machine. This is possible by mounting the image.
Now, you'll be able to access the vm file system, mounted on /mnt/domU.
Then, once the changes are done, just unmount the vm image file
Using KVM instead of Xen
An other alternative to Xen is KVM. This virtualization tool is also very efficient but needs a little bit more work to do to be used on G5k. As Xen was able to connect the virtual machines directly through the "xm console" command, KVM doesn't offer such tool. When the vm boots for the first time it is not possible to know in advance its IP address. Thus we have to connect it by another method. An "easy" way to do this is through VNC. We will have to manage the network bridging ourselves too, but don't worry :-) some scripts are here to help you in this procedure.
- On Nancy site frontend, deploy the squeeze-x64-kvm-TP environment (don't forget to submit a job first...):
- On the deployed node:
Get network interface for bridge creation (INTERFACE=`ifconfig | grep eth | awk -F ' ' '{print $1}'`)
Create bridge for managing hosts network (replace <$INTERFACE> by what you got typing ifconfig | grep eth | awk -F ' ' '{print $1}')
Restart networking
Verify that the bridge was actually created:
should display the bridge information
Now, a new interface br0 should appear in ifconfig
Generate a random mac address for use in the vm
Start the Virtual Machine
node:
| #
kvm -m 512 -hda /root/kvm/debian.qcow2 -net nic,macaddr=00:16:3E:6D:FB:4C -net tap -nographic -vnc :1 |
| Note | |
|---|---|
Don't forget to replace the macaddr field by the one you got by running the command "random_mac.sh" otherwise we will all use the same IP address and it will not work!!! | |
- On your laptop/desktop machine:
Create an ssh tunnel to your deployed node (<NODE>)
Then, to open the vnc console through the tunnel
You should have a window that opened. This is your virtual machine (login:root -- password: kameleon).
Now, you can be able to know its IP address (with "ifconfig") and then connect it directly through ssh from within Grid'5000.
