Virtualization in Grid'5000: Difference between revisions

From Grid5000
Jump to navigation Jump to search
mNo edit summary
Line 38: Line 38:


=== Now, you can run the guest OS from the kvm disk image ===
=== Now, you can run the guest OS from the kvm disk image ===
  jdoe@griffon-37:~$ screen kvm -m 512 -hda squeeze-x64-base.img -net nic,macaddr=$MACADDR -net tap,ifname=tap0,script=no -nographic
  jdoe@griffon-37:~$ screen kvm -m 512 -hda /tmp/squeeze-x64-base.img -net nic,macaddr=$MACADDR -net tap,ifname=tap0,script=no -nographic


= Misc notes  =
= Misc notes  =

Revision as of 02:55, 30 November 2011


Purpose

This page presents ways to use KVM on production image.

Usage

First submit the job, using habitual oarsub command

jdoe@fnancy:~$ oarsub -I

Copy the kvm disk image to /tmp on the node

jdoe@griffon-37:~$ cp /grid5000/images/KVM/squeeze-x64-base.img /tmp/

Create Tun/Tap interface for your guest OS

jdoe@griffon-37:~$ sudo create_tap
  • Tun/Tap interfaces are listed by issuing the command /sbin/ifconfig.
jdoe@griffon-37:~$ /sbin/ifconfig
[...]
tap0      Link encap:Ethernet  HWaddr 5a:ff:a4:97:c6:a8  
          inet6 addr: fe80::58ff:a4ff:fe97:c6a8/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:29435 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Note.png Note

Create one Tun/Tap interface per guest OS.

Generate a random mac address for the Tun/Tap interface

  • Use the following script
jdoe@griffon-37:~$ MACADDR="00:16:3e:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\).*$/\1:\2:\3/')"; echo $MACADDR
Note.png Note

The first three octets are important (identification for the virtualized network). Don't change it.

Now, you can run the guest OS from the kvm disk image

jdoe@griffon-37:~$ screen kvm -m 512 -hda /tmp/squeeze-x64-base.img -net nic,macaddr=$MACADDR -net tap,ifname=tap0,script=no -nographic

Misc notes

  • Manage console for all your guest OS with Screen
  • Use tunctl if you need to delete a Tun/Tap device.
jdoe@griffon-37:~$ /usr/sbin/tunctl -d tap0