Difference between revisions of "Vnx-rootfsdebian"
(Created page with "{{Title|How to create a User-Mode-Linux Debian root-file-system for VNX}} Follow this procedure to create a UML Debian Squeeze (6.0) root filesystem for VNX. == Basic inst...") |
(→A. Starting a virtual machine that mounts the rootfs in direct mode:) |
||
Line 209: | Line 209: | ||
<ul> | <ul> | ||
− | <li>Create a VNX scenario named, for example, '''update_uml.xml''':</li> | + | <li>Create a VNX scenario named, for example, '''update_uml.xml''' (available in /usr/share/vnx/examples):</li> |
<pre> | <pre> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> |
Revision as of 19:01, 10 June 2012
How to create a User-Mode-Linux Debian root-file-system for VNX
Follow this procedure to create a UML Debian Squeeze (6.0) root filesystem for VNX.
Contents
Basic installation and configuration
- Requirements:
apt-get install debootstrap
dd bs=1M if=/dev/zero of=vnx_rootfs_uml_debian.img count=2048 mkfs.ext4 vnx_rootfs_uml_debian.img
mkdir mnt mount -o loop vnx_rootfs_uml_debian.img mnt/ debootstrap --arch i386 squeeze mnt/ ftp://ftp.debian.org/debian/
Note: change ftp.debian.org to the mirror nearest you (e.g. ftp.es.debian.org).
mount -t proc none mnt/proc chroot mnt env -update ln -sf /usr/share/zoneinfo/Europe/Madrid /etc/localtime
apt-get install locales aptsh file less perl-modules vim openssh-server \ openssh-client telnet sudo lsof ssh ncurses-term bzip2 strace \ tcpdump tshark apache2 apache2-utils dnsutils finger ftp ftpd \ ipsec-tools iputils-tracepath ipv6calc ipvsadm lpr lynx \ nfs-common openssl pidentd portmap ppp procmail python \ python-central python-newt quagga racoon radvd sharutils squid \ squid-common ssl-cert vlan whois iptables bind9 sudo dpkg-reconfigure locales
/etc/init.d/apache2 stop /etc/init.d/squid stop /etc/init.d/bind9 stop /etc/init.d/exim4 stop /etc/init.d/lpd stop update-rc.d -f apache2 remove update-rc.d -f squid remove update-rc.d -f bind9 remove update-rc.d -f exim4 remove update-rc.d -f lpd remove
apt-get clean
echo vnx > /etc/hostname
echo '0:2345:respawn:/sbin/getty 38400 tty0' >> /etc/inittab echo 'tty0' >> /etc/securetty echo 'ssh' >> /etc/securetty echo 'auto lo' >> /etc/network/interfaces echo 'iface lo inet loopback' >> /etc/network/interfaces
echo 'proc /proc proc defaults 0 0' >> /etc/fstab echo 'devpts /dev/pts devpts mode=0622 0 0' >> /etc/fstab echo '/dev/ubda / ext4 defaults 0 1' >> /etc/fstab echo '/dev/ubdb /mnt/vnuml iso9660 defaults 0 0' >> /etc/fstab
passwd
mkdir /mnt/vnuml mkdir /mnt/hostfs
#! /bin/sh ### BEGIN INIT INFO # Provides: vnxboot # Required-Start: $remote_fs $syslog $all # Required-Stop: # Default-Start: 2 # Default-Stop: # Short-Description: Run /mnt/vnuml/umlboot if it exist ### END INIT INFO PATH=/sbin:/usr/sbin:/bin:/usr/bin . /lib/init/vars.sh . /lib/lsb/init-functions do_start() { if [ -x /mnt/vnuml/umlboot ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running vnxboot (/mnt/vnuml/umlboot)" /mnt/vnuml/umlboot ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi } case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac
chmod +x /etc/init.d/vnxboot cd /etc/rc2.d ln -s ../init.d/vnxboot S11vnxboot update-rc.d vnxboot enable
#!/bin/bash if [ "$1" == '-y' ]; then NOINTMODE='yes' fi # Clean apt cache apt-get clean apt-get -y autoremove # Delete /etc/resolv.conf rm -f /etc/resolv.conf # Clean command history rm -f /root/.bash_history # Delete udev net rules files: rm -f /etc/udev/rules.d/70-persistent-net.rules if [ ! $NOINTMODE ]; then while true; do # Ask for a message to save in /etc/vnx_rootfs_version file echo "** Save a log message in /etc/vnx_rootfs_version file " echo -n "** describing the modifications done? " read -n 1 -p "[y/n] " answer echo "" case $answer in [Yy]* ) echo "** Log message (1 line maximum):" read logmsg DATE=`date` echo "MODDATE=$DATE" >> /etc/vnx_rootfs_version echo "MODDESC=$logmsg" >> /etc/vnx_rootfs_version break;; [Nn]* ) break;; * ) echo "** Error: please answer 'y' or 'n'.";; esac done fi # Check whether we are running chrooted or not if [ ! -e /proc/1/root ]; then # Probably running chrooted. Do not halt! echo "**" echo "** Cannot read /proc. Probably running chrooted. Not halting" echo "** Type 'exit' to exit from chroot" exit elif [ ! -e /proc/1/root -o "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then # We are chrooted! Do not halt echo "**" echo "** Running chrooted. Not halting" echo "** Type 'exit' to exit from chroot" exit fi # We are NOT chrooted! We halt the virtual machine halt -p
chmod +x /usr/local/bin/vnx_halt
VER=v0.24 OS=Debian Squeeze (6.0) DESC=Debian Squeeze root-file-system without GUI
cd /dev mknod --mode=660 ubda b 98 0 mknod --mode=660 ubdb b 98 0 chown root:disk ubda chown root:disk ubdb
vnx_halt
exit umount mnt/proc/ umount mnt
Note: if you cannot umount 'mnt' directory, check which process is blocking the unmounting operation with 'lsof mnt' and stop it.
Installing additional software
There is two basic ways to update a UML root filesystems:
A. Starting a virtual machine that mounts the rootfs in direct mode:
- Create a VNX scenario named, for example, update_uml.xml (available in /usr/share/vnx/examples):
<?xml version="1.0" encoding="UTF-8"?> <!-- ~~~~~~~~~~~~~~~~~~~~ VNX Sample scenarios ~~~~~~~~~~~~~~~~~~~~ Name: update_uml Description: Simple scenario to start a uml virtual machine in direct mode to make modifications in a filesystem. Tha VM is connected to virbr0, the default network used by libvirt, to gain network connectivity. This file is part of the Virtual Networks over LinuX (VNX) Project distribution. (www: http://www.dit.upm.es/vnx - e-mail: vnx@dit.upm.es) Departamento de Ingenieria de Sistemas Telematicos (DIT) Universidad Politecnica de Madrid SPAIN --> <vnx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/usr/share/xml/vnx/vnx-2.00.xsd"> <global> <version>2.0</version> <scenario_name>update_uml</scenario_name> <automac/> <vm_mgmt type="none" /> <vm_defaults> <exec_mode type="uml">mconsole</exec_mode> </vm_defaults> </global> <net name="virbr0" mode="virtual_bridge" /> <vm name="uml" type="uml" subtype="" os=""> <filesystem type="direct">ROOTFS_PATHNAME</filesystem> <mem>64M</mem> <kernel trace="on">UML_KERNEL</kernel> <console id="0" display="yes">xterm</console> <if id="1" net="virbr0"> </if> <exec seq="on_boot" type="verbatim">dhclient eth1</exec> </vm> </vnx>
Change ROOTFS_PATHNAME and UML_KERNEL by the full pathname of the root filesystem to be modified and the UML kernel to be used to start it.
vnx -f update_uml.xml -v -t
dhclient eth1
vnx_halt
B. Mounting the rootfs and chrooting to it:
- Mount the rootfs:
mkdir mnt mount -o loop vnx_rootfs_uml_debian.img mnt/ mount -t proc none mnt/proc
chroot mnt env -update
vnx_halt
exit umount mnt/proc umount mnt
Note: if you cannot umount 'mnt' directory, check which process is blocking the unmounting operation with 'lsof mnt' and stop it.