Difference between revisions of "Vnx-rootfscentos"

From VNX
Jump to: navigation, search
(Configuration)
Line 6: Line 6:
 
<ul>
 
<ul>
 
<li>Create the filesystem disk image:</li>
 
<li>Create the filesystem disk image:</li>
  qemu-img create -f qcow2 root_fs_centos-base.qcow2 5GB
+
  qemu-img create -f qcow2 vnx_rootfs_centos-base.qcow2 5GB
 
<li>Get CentOS installation DVD (use the complete DVD; do not use the Live version, as it seems the installation wizard does not include the customization menu). For example:</li>
 
<li>Get CentOS installation DVD (use the complete DVD; do not use the Live version, as it seems the installation wizard does not include the customization menu). For example:</li>
 
  wget http://ftp.gui.uva.es/sites/centos.org/5.6/isos/i386/CentOS-5.6-i386-bin-DVD.iso
 
  wget http://ftp.gui.uva.es/sites/centos.org/5.6/isos/i386/CentOS-5.6-i386-bin-DVD.iso
 
  cp CentOS-5.6-i386-bin-DVD.iso /almacen/iso
 
  cp CentOS-5.6-i386-bin-DVD.iso /almacen/iso
<li>Create a libvirt XML definition (root_fs_centos.xml) containing the virtual machine description:</li>
+
<li>Create a libvirt XML definition (rootfs_centos.xml) containing the virtual machine description:</li>
 
<pre>
 
<pre>
 
<domain type='kvm'>
 
<domain type='kvm'>
Line 30: Line 30:
 
     <emulator>/usr/bin/kvm</emulator>
 
     <emulator>/usr/bin/kvm</emulator>
 
     <disk type='file' device='disk'>
 
     <disk type='file' device='disk'>
       <source file='/usr/share/vnx/filesystems/root_fs_centos-base.qcow2'/>
+
       <source file='/usr/share/vnx/filesystems/vnx_rootfs_centos-base.qcow2'/>
 
       <target dev='hda'/>
 
       <target dev='hda'/>
 
     </disk>
 
     </disk>
Line 53: Line 53:
  
 
<li>Start the virtual machine with:</li>
 
<li>Start the virtual machine with:</li>
  virsh create root_fs_centos.xml
+
  virsh create rootfs_centos.xml
 
<li>Access virtual machine console with:</li>
 
<li>Access virtual machine console with:</li>
 
  virt-viewer CentOS
 
  virt-viewer CentOS
Line 100: Line 100:
 
</ul>
 
</ul>
  
<li>Create a file /etc/vnx_root_fs_version to store version number and informacion about modifications:</li>
+
<li>Create a file /etc/vnx_rootfs_version to store version number and informacion about modifications:</li>
 
<pre>
 
<pre>
 
VER=v0.21
 
VER=v0.21
Line 116: Line 116:
 
rm -f /root/.bash_history
 
rm -f /root/.bash_history
 
while true; do
 
while true; do
     # Ask for a message to save in /etc/vnx_root_fs_version file
+
     # Ask for a message to save in /etc/vnx_rootfs_version file
     echo    "** Save a log message in /etc/vnx_root_fs_version file "
+
     echo    "** Save a log message in /etc/vnx_rootfs_version file "
 
     echo -n "** describing the modifications done? "
 
     echo -n "** describing the modifications done? "
 
     read -n 1 -p "[y/n] " answer
 
     read -n 1 -p "[y/n] " answer
Line 126: Line 126:
 
                 read logmsg
 
                 read logmsg
 
                 DATE=`date`
 
                 DATE=`date`
                 echo "MODDATE=$DATE" >> /etc/vnx_root_fs_version
+
                 echo "MODDATE=$DATE" >> /etc/vnx_rootfs_version
                 echo "MODDESC=$logmsg" >> /etc/vnx_root_fs_version
+
                 echo "MODDESC=$logmsg" >> /etc/vnx_rootfs_version
 
                 break;;
 
                 break;;
 
         [Nn]* ) break;;
 
         [Nn]* ) break;;
Line 147: Line 147:
 
To install additional software or modify your root file system, you just have to start it as described above and make the operations required on the filesystem.
 
To install additional software or modify your root file system, you just have to start it as described above and make the operations required on the filesystem.
 
* Start the virtual machine (directly using virsh or the vnx_modify_rootfs utility):
 
* Start the virtual machine (directly using virsh or the vnx_modify_rootfs utility):
   /usr/share/vnx/bin/vnx_modify_rootfs root_fs_centos.xml  
+
   /usr/share/vnx/bin/vnx_modify_rootfs rootfs_centos.xml  
 
* Install the software:
 
* Install the software:
 
  yum install ...
 
  yum install ...

Revision as of 13:43, 27 July 2011

How to create a CentOS root filesystem for VNX

Basic installation

Follow this procedure to create a CentOS based root filesystem for VNX. The procedure has been tested with CentOS 5.6.

  • Create the filesystem disk image:
  • qemu-img create -f qcow2 vnx_rootfs_centos-base.qcow2 5GB
    
  • Get CentOS installation DVD (use the complete DVD; do not use the Live version, as it seems the installation wizard does not include the customization menu). For example:
  • wget http://ftp.gui.uva.es/sites/centos.org/5.6/isos/i386/CentOS-5.6-i386-bin-DVD.iso
    cp CentOS-5.6-i386-bin-DVD.iso /almacen/iso
    
  • Create a libvirt XML definition (rootfs_centos.xml) containing the virtual machine description:
  • <domain type='kvm'>
      <name>CentOS</name>
      <memory>524288</memory>
      <vcpu>1</vcpu>
      <os>
        <type arch="i686">hvm</type>
        <boot dev='hd'/>
        <boot dev='cdrom'/>
      </os>
      <features>
         <pae/>
         <acpi/>
         <apic/>
      </features>
      <clock sync="localtime"/>
      <devices>
        <emulator>/usr/bin/kvm</emulator>
        <disk type='file' device='disk'>
          <source file='/usr/share/vnx/filesystems/vnx_rootfs_centos-base.qcow2'/>
          <target dev='hda'/>
        </disk>
        <disk type='file' device='cdrom'>
          <source file='/almacen/iso/CentOS-5.6-i386-bin-DVD.iso'/>
          <target dev='hdb'/>
        </disk>
        <interface type='network'>
          <source network='default'/>
        </interface>
        <serial type="pty">
          <target port="1"/>
        </serial>
        <console type="pty">
          <target port="1"/>
        </console>
        <graphics type='vnc'/>
      </devices>
    </domain>
    

    Note: change "source file=" lines to whatever fits your case (use full paths).

  • Start the virtual machine with:
  • virsh create rootfs_centos.xml
    
  • Access virtual machine console with:
  • virt-viewer CentOS
    
  • Follow CentOS installation menus to install:
    • A "minimal" system, if you want a server rootfs without user interface
    • One of the other options (e.g "web server", "desktop system", etc) if you want a system with graphical user interface

Configuration

  • Once installation is finished, configure the RPMForge repository following the procedure described here:
  • wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
    rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
    rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
    rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
    
  • Update the system and install additional packages
  • yum update
    yum install perl perl-XML-DOM perl-XML-Parser acpid daemonize
    
  • Install VNX autoconfiguration daemon:
    • From the host execute:
    • /usr/share/vnx/bin/vnx_update_aced CentOS /usr/share/vnx/aced/vnx-aced-lf-0.1b.tgz 
      
    • From the virtual machine console:
    • mkdir /media/cdrom
      mount /dev/cdrom /media/cdrom
      perl /media/cdrom/install_vnxdaemon
      
  • Configure the serial console following these instructions.
  • Disable the services you are not going to use (you can see the list of active services with "chkconfig --list"). For example to disable sendmail and bluetooth:
  • chkconfig sendmail off
    chkconfig bluetooth off
    
  • Disable eth0 autoconfiguration to avoid delays at startup. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 file and change "ONBOOT" line to:
  • ONBOOT=no
    
  • Optionally:
    • Disable the firewall. Firewall is enabled by default which could be problematic for testing purpose systems. If desired, disable it using the following command:
    • chkconfig iptables off
      chkconfig ip6tables off
      
    • Enable IPv6 by deleting the following lines in /etc/modprobe.conf:
    • alias ipv6 off
      options ipv6 disable=1
      
  • Create a file /etc/vnx_rootfs_version to store version number and informacion about modifications:
  • VER=v0.21
    OS=CentOS 5.6
    DESC=Basic CentOS 5.6 root-filesystem without GUI
    
  • Create a script named /usr/local/bin/vnx_halt:
  • #!/bin/bash
    echo "** Cleaning yum cache..."
    yum clean all
    echo "** Deleting /etc/resolv.conf..."
    rm -f /etc/resolv.conf
    echo "** Cleaning command history...."
    rm -f /root/.bash_history
    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
    echo ""
    echo "** Halting the system..."
    halt
    
  • Give the script execution permissions:
  • chmod +x /usr/local/bin/vnx_halt
    
  • Stop the machine with that script:
  • vnx_halt
    

Installing additional software

To install additional software or modify your root file system, you just have to start it as described above and make the operations required on the filesystem.

  • Start the virtual machine (directly using virsh or the vnx_modify_rootfs utility):
 /usr/share/vnx/bin/vnx_modify_rootfs rootfs_centos.xml 
  • Install the software:
yum install ...
  • Stop the machine with:
vnx_halt

Known issues

  • When executing commands using vnx "--exe" option, traces like the followinf appear on the consoles:
  • hdb: tray open
    end_request: I/O error, dev hdb, sector 8388352
    

    They are generated as a result of mount command execution by the VNX daemon. Commands are correctly executed. To be further investigated.