Example-update-rootfs

Authors: Ferm&iacute;n Gal&aacute;n (galan at dit.upm.es) David Fern&aacute;ndez (david at dit.upm.es) version 1.7, February 15th, 2007

Scenario
This is a simple example useful to install or update applications inside a UML root filesystem. It just creates a virtual machine with external network access. Once started you can use typical applications like dselect or apt-get in Debian to update the filesystem.

Two versións of the scenario are presented:
 * Direct connection, where the virtual machine is connected by means of a new subinterface configured in the host machine network interface.
 * Connection through NAT, where the virtual machine is connected to an internal virtual private network which is connected to Internet through a NAT configured in the host machine.

Important notes:


 * As this example interacts with the host machine network interface, an incorrect use of it can let the host unaccesible. Even if correctly used, the host will be unaccesible during short periods of time while the simulation starts/stops. So, it is recomended to execute it from the host console (at least not being far from it :).


 * If you are experiencing problems with the conventional xterm, we recommend you to uncomment the  tag in each virtual machine, in order to use gnome-terminal, that seems to be more stable. Of course, you will need the gnome-terminal installed in your system.


 * Note the use of  in order to make the changes in the filesystem (e.g., installed software) permantent. If you were using for example type="cow" changes won't be stored in the /usr/share/vnuml/filesystems/root_fs_tutorial file. More information about installing software in the User Manual.

Direct Connection
In this case, the virtual machine is connected to Internet using its own IP address configured over the network interface of the host.



To configure this example, you need an aditional IP network address from the subnet where the host is connected. The relevant data used in the example follows:
 * Host address: 192.168.11.16
 * Virtual Machine address: 192.168.11.30
 * Router address: 192.168.11.254
 * Subnet Mask: 255.255.255.0 (/24)

After starting the scenario you will have to access the virtual machine and configure the address of a DNS server in your network in order to have full Intenter access. To do that, you just have to edit /etc/resolv.conf file and add a line like:

nameserver x.y.z.v

being x.y.z.v the IP address of your DNS server.

Connection through NAT
In this case the virtual machine is connected to a virtual private network using private addresses. The host is configured to run a NAT that allows sharing the host IP address between the host and the virtual machine.



In the example we use a private network (192.168.1.0/24), having the virtual machine the address 192.168.1.2 and the host 192.168.1.1.

In order to configure the NAT in your host, you will have to execute the following commands:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward

being "eth0" the name of the host interface you will use to conncet to Internet.

After starting the scenario you will have to access the virtual machine and configure the address of a DNS server in your network in order to have full Intenter access. To do that, you just have to edit /etc/resolv.conf file and add a line like:

nameserver x.y.z.v

being x.y.z.v the IP address of your DNS server.

Direct Connection
 <!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd" [ <!ENTITY VNUMLDIR "/usr/share/vnuml/"> <!ENTITY BASEDIR "/usr/share/vnuml/examples/update-fs/"> <!ENTITY REDIR "&lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;"> ]>

1.7      update-fs /root/.ssh/identity.pub 



&VNUMLDIR;filesystems/root_fs_tutorial 64M &VNUMLDIR;linux xterm  192.168.11.30  default 

 192.168.11.16  default

Connection through NAT
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE vnuml SYSTEM "/usr/local/share/xml/vnuml/vnuml.dtd" [ <!ENTITY VNUMLDIR "/usr/share/vnuml/"> <!ENTITY BASEDIR "/usr/share/vnuml/examples/update-fs/"> <!ENTITY REDIR "&lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;"> ]>

1.7    update-fs</simulation_name> /root/.ssh/identity.pub</ssh_key> <vm_mgmt type="none"/> <vm_defaults> xterm </vm_defaults>

<net name="Net0" mode="uml_switch"/>

&VNUMLDIR;filesystems/root_fs_tutorial 64M &VNUMLDIR;linux  <ipv4 mask="255.255.255.0">192.168.1.2 </if> <route type="ipv4" gw="192.168.1.1">default </vm>

<hostif net="Net0"> <ipv4 mask="255.255.255.0">192.168.1.1

Download

 * VNUML specification file: update-fs.xml
 * VNUML specification file: update-fs-nat.xml

Old Releases

 * 1.3
 * 1.6