Slc-rootfs

From VNUML-WIKI
Jump to: navigation, search

How to create a Scientific Linux 3 rootfilesystem starting from a SLC3 Xen image

Installation

Download SLC3 image from http://project-xen.web.cern.ch/project-xen/xen/img/img.xml.

Copy the original rootfs image to a new file, mount it and chroot to it:

cp slc3_root_04.img slc3_root_04.img-v1
mount -o loop slc3_root_04.img-v1 /mnt/
chroot /mnt/

Create /mnt/vnuml directory and umlboot link:

mkdir /mnt/vnuml
ln -s /mnt/vnuml/umlboot /etc/rc.d/rc3.d/S11bootuml

Edit /etc/fstab and include:

 /dev/ubda / ext3 defaults 0 1
 /dev/ubdb /mnt/vnuml iso9660 defaults 0 0

and comment entries about /dev/sda1 and /dev/hda5.

Edit /etc/defaults/ssh and add:

 SSHD_OPTS=-u0

Create the /dev/ubd[a-h] nodes using the makeUBDdev.sh script (see the complete script below taken from http://www.theshore.net/~caker/uml/)

vi /tmp/makeUBDdev.sh
chmod +x /tmp/makeUBDdev.sh 
cd /dev/
/tmp/makeUBDdev.sh 

Edit /etc/inittab and create a new tty entry:

0:2345:respawn:/sbin/mingetty tty0

also comment tty3-6 entries.

Edit /etc/ssh/sshd_config to allow root access through ssh:

PermitRootLogin yes

Change root password (set it to "xxxx"):

 passwd

Edit /etc/securetty and add tty0 to allow root login through the xterm console.

Exit form chroot and install kernel modules:

exit
cd /mnt/lib/modules/
tar xfv /usr/local/share/vnuml/kernels/src/linux-2.6.16.27-bs2-xt-1m/modules-2.6.16.27-bs2-xt-1m.tar

Unmount the filesystem:

umount /mnt

Create a test scenario slc3.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd">
<vnuml>
  <global>
    <version>1.7</version>
    <simulation_name>sl3</simulation_name>
    <automac/>
    <vm_mgmt type="private" network="10.250.0.0" mask="24">
       <host_mapping />
    </vm_mgmt>
    <vm_defaults>
       <filesystem type="cow">/usr/local/share/vnuml/filesystems/slc3_root_04.img-v1</filesystem>
       <kernel>/usr/local/share/vnuml/kernels/linux</kernel>
       <console id="0">xterm</console>
       <!--xterm>gnome-terminal,-t,-x</xterm-->
    </vm_defaults>
  </global>

  <!-- NODES -->
  <vm name="host1">
     <mem>200M</mem>
  </vm>

</vnuml>

and test it:

vnumlparser.pl -t sl3.xml -v -u root -Z -w 120

Access the host via slogin (root access from the xterm does not work by now):

slogin host1 -l root

Updating the filesystem

To be able to update the filesystem from the network, you can use a virtual virtual scenario with network connectivity using a NAT in the host.

Copy this scenario to a file named slc3n.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd">
<vnuml>

  <global>
    <version>1.7</version>
    <simulation_name>slc3n</simulation_name>
    <ssh_key>/root/.ssh/identity.pub</ssh_key>
    <automac/>
    <vm_mgmt type="none"/>
    <vm_defaults>
       <console id="0">xterm</console>
    </vm_defaults>
  </global>  

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

  <vm name="vm1">
    <filesystem type="direct">/usr/local/share/vnuml/filesystems/slc3_root_04.img-v1</filesystem>
    <mem>256M</mem>
    <kernel>/usr/share/vnuml/kernels/linux</kernel>
    <if id="1" net="Net0">
     <ipv4 mask="255.255.255.0">192.168.1.2</ipv4>
    </if>
    <route type="ipv4" gw="192.168.1.1">default</route>
  </vm>

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

</vnuml>

On the host execute the following commands (eth0 is the name of the network interface with Internet connectivity):

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

Start the scenario:

 vnumlparser.pl -t slc3n.xml -v -u root -Z -w 120

Login to the virtual machine and check network connectivity (you'll have to configure a dns server in /etc/resolv.conf).



Notes:

Use "chkconfig --off servicename" to disable services on start

makeUBDdev.sh script


#!/bin/bash
device=ubd
major=98
minor=0
for u in a b c d e f g h
        do dev=$device$u
        
        mknod $dev b $major $minor
        chmod 660 $dev
        chgrp disk $dev
        
        for i in $(seq 1 15)
                do 
                mknod $dev$i b $major $(($minor + $i)) 
                chmod 660 $dev$i
                chgrp disk $dev$i
        done
        minor=$(($minor + 16))
done


References

http://project-xen.web.cern.ch/project-xen/xen/howto_slcXen.html

http://project-xen.web.cern.ch/project-xen/xen/img/slc3_root_04.img.gz

http://public.eu-egee.org/files/xen-grid-in-a-box-fzk.pdf