Difference between revisions of "Vnx-rootfsfreebsd"

From VNX
Jump to: navigation, search
(FreeBSD tips)
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Title|How to create a Freebsd root-file-system for VNX}}
+
{{Title|How to create a KVM Freebsd root filesystem for VNX}}
  
 +
Follow this procedure to create a KVM FreeBSD based root filesystem for VNX. The procedure has been tested with FreeBSD 10.0, 9.0, 8.2 and 7.4.
 +
 +
== Basic installation ==
 
<ul>
 
<ul>
 
<li>Create the filesystem disk image:</li>
 
<li>Create the filesystem disk image:</li>
  qemu-img create -f qcow2 vnx_rootfs_freebsd-base.qcow2 5GB
+
  qemu-img create -f qcow2 vnx_rootfs_kvm_freebsd.qcow2 8G
 
<li>Get FreeBSD installation CD. For example:</li>
 
<li>Get FreeBSD installation CD. For example:</li>
  wget ftp://ftp.rediris.es/mirror/FreeBSD/ISO-IMAGES-i386/8.2/FreeBSD-8.2-RELEASE-i386-disc1.iso
+
  wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-i386-disc1.iso
  cp FreeBSD-8.2-RELEASE-i386-disc1.iso /almacen/iso
+
  cp FreeBSD-9.1-RELEASE-i386-disc1.iso /almacen/iso
<li>Create a libvirt XML definition (rootfs_freebsd.xml) containing the virtual machine description:</li>
+
<li>Create the virtual machine with:</li>
 +
vnx --create-rootfs vnx_rootfs_kvm_freebsd.qcow2 --install-media /almacen/iso/FreeBSD-9.1-RELEASE-i386-disc1.iso --mem 512M
 +
<li>Follow FreeBSD installation menus to install a basic system with DHCP configured in the network interface and a user named "vnx".</li>
 +
<li>Configure the serial console by editting /etc/ttys file and changing the line:</li>
 +
ttyu0 "/usr/libexec/getty std.9600"  dialup  off secure
 +
to:
 +
ttyu0 "/usr/libexec/getty std.9600"  vt100  on secure
 +
<li>Set dual console configuration (see http://www.cct.lsu.edu/~ccui/diary/August19_2010.php):</li>
 +
echo "-Dh" > /boot.config
 +
echo 'boot_multicons="YES"' >> /boot/loader.conf
 +
echo 'boot_serial="YES"' >> /boot/loader.conf
 +
echo 'console="comconsole,vidconsole"' >> /boot/loader.conf
 +
IMPORTANT: in Ubuntu 13.04 the rootfs created adding this lines does not start! It hangs on bootloader consuming 100% of CPU. Seems to be a problem with the kvm/seabios versions in Ubuntu 13.04. Just skip this step to avoid the problem (you lose startup traces on serial console).
 +
<li>Finally, halt the system:</li>
 +
halt -p
 +
<!--li>Create a libvirt XML definition (rootfs_freebsd.xml) containing the virtual machine description:</li>
 
<pre>
 
<pre>
 
<domain type='kvm'>
 
<domain type='kvm'>
Line 49: Line 67:
 
</pre>
 
</pre>
 
Note: change "source file=" lines to whatever fits your case (use full paths).  
 
Note: change "source file=" lines to whatever fits your case (use full paths).  
 +
-->
 +
 +
</ul>
 +
 +
== Configuration ==
  
<li>Start the virtual machine with:</li>
 
virsh create rootfs_freebsd.xml
 
<li>Access virtual machine console with:</li>
 
virt-viewer Freebsd
 
<li>Follow FreeBSD installation menus to install a basic system with DHCP configured in the network interface and a user named "vnx".</li>
 
<li>Once the installation is finished, stop the machine and edit rootfs_freebsd.xml file and comment the following line in cdrom disk specification:
 
<pre>
 
<!--source file='/almacen/iso/FreeBSD-8.1-RELEASE-i386-disc1.iso'/-->
 
</pre>
 
<li>Start the virtual machine again and:</li>
 
 
<ul>
 
<ul>
<li>Install bash and change package repository:</li>
+
<li>Restart the system with the following command:</li>
  pkg_add -r bash
+
vnx --modify-rootfs vnx_rootfs_kvm_freebsd.qcow2 --update-aced --mem 512M
 +
Note: ignore the errors "timeout waiting for response on VM socket".
 +
<li>Access the system through the text console to easy the copy-paste of commands:</li>
 +
virsh console vnx_rootfs_kvm_freebsd.qcow2
 +
<li>Install bash and change package repository (change ftp.es.freebsd.org to your nearest mirror):</li>
 +
pkg install bash # for FreeBSD 10.0
 +
  pkg_add -r bash # for previous FreeBSD versions
 
  pw usermod root -s /usr/local/bin/bash
 
  pw usermod root -s /usr/local/bin/bash
 
  pw usermod vnx -s /usr/local/bin/bash  
 
  pw usermod vnx -s /usr/local/bin/bash  
  echo "export PACKAGEROOT=ftp://ftp.es.freebsd.org" > ~/.bash_profile
+
# only for FreeBSD 9.X
<li>Install perl and XML::DOM library:</li>
+
  echo "export PACKAGESITE=ftp://ftp.es.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/Latest/" > ~/.bash_profile
  pkg_add -r perl p5-libxml-enno
+
<li>Install perl and XML::LibXML library:</li>
 +
pkg install perl5 p5-XML-LibXML p5-NetAddr-IP  # FreeBSD 10.0
 +
  pkg_add -r perl p5-XML-LibXML p5-NetAddr-IP  # previous versions
 
<li>Disable DHCP on network interface by editing the /etc/rc.conf file and commenting the following line:</li>
 
<li>Disable DHCP on network interface by editing the /etc/rc.conf file and commenting the following line:</li>
 
  ifconfig_re0="DHCP"
 
  ifconfig_re0="DHCP"
 
<li>Install VNX autoconfiguration daemon:</li>
 
<li>Install VNX autoconfiguration daemon:</li>
 +
mount -t msdosfs /dev/ad1 /mnt/
 +
perl /mnt/vnxaced-lf/install_vnxaced
 +
<li>Optionally:
 
<ul>
 
<ul>
<li>From the host execute:</li>
+
<li>Allow root login thorugh ssh by editing /etc/ssh/sshd_config file:</li>
/usr/share/vnx/bin/vnx_update_aced Freebsd /usr/share/vnx/aced/vnx-aced-lf-0.1b.tgz
 
<li>From the virtual machine console:</li>
 
mount /cdrom
 
/cdrom/install_vnxdaemon
 
</ul>
 
<!--li>Configure the console by executing:</li>
 
echo 'console="comconsole"' >> /boot/loader.conf
 
-->
 
<li>Configure the serial console by editting /etc/ttys file and changing the line:</li>
 
ttyu0 "/usr/libexec/getty std.9600"  dialup  off secure
 
by:
 
ttyu0 "/usr/libexec/getty std.9600"  vt100  on secure
 
<li>Set dual console configuration (see http://www.cct.lsu.edu/~ccui/diary/August19_2010.php):</li>
 
echo "-Dh" > /boot.config
 
echo 'boot_multicons="YES"' >> /boot/loader.conf
 
echo 'boot_serial="YES"' >> /boot/loader.conf
 
echo 'console="comconsole,vidconsole"' >> /boot/loader.conf
 
 
 
<li>Optional: allow root login thorugh ssh by editing /etc/ssh/sshd_config file:</li>
 
 
  PermitRootLogin yes
 
  PermitRootLogin yes
<li>Optional: set locales according to your preferences in /etc/profile:</li>
+
<li>Set locales according to your preferences in /etc/profile:</li>
 
  export LANG=es_ES.UTF-8
 
  export LANG=es_ES.UTF-8
 
  export LC_ALL=es_ES.UTF-8
 
  export LC_ALL=es_ES.UTF-8
<li>Optional: add gnome window manager with:</li>
+
<li>Add gnome window manager with:</li>
 
<ul>
 
<ul>
 
<li>Install packages needed:</li>
 
<li>Install packages needed:</li>
  pkg_add -r xorg-minimal gnome2-lite gdm detach xeyes xhost wmctrl
+
  pkg_add -r xorg-minimal gnome2-lite gdm gnome-keyring detach xeyes xhost wmctrl # Previous FreeBSD versions
 
<li>Add the following line to /etc/rc.conf:</li>
 
<li>Add the following line to /etc/rc.conf:</li>
 
  gnome_enable="YES"
 
  gnome_enable="YES"
Line 106: Line 111:
 
<li>Disable the screensaver and change keyboard configuration in "System->Keyboard" menu.</li>
 
<li>Disable the screensaver and change keyboard configuration in "System->Keyboard" menu.</li>
 
</ul>
 
</ul>
<li>Optional: reduce the boot timeout from 10 seconds to, for example, 3 seconds. Edit /boot/loader.conf and add:</li>
+
<li>Reduce the boot timeout from 10 seconds to, for example, 3 seconds. Edit /boot/loader.conf and add:</li>
 
  autoboot_delay="3"
 
  autoboot_delay="3"
<li>Optional: give vnx user (or whatever one you have created during installation) permissions tu su root:</li>
+
<li>Give vnx user (or whatever one you have created during installation) permissions tu su root:</li>
 
  pw usermod vnx -G wheel
 
  pw usermod vnx -G wheel
<li>Optional: if you have installed gnome, you can add automatic login following the instructions in:</li>
+
<li>If you have installed gnome, you can add automatic login following the instructions in:</li>
 
  http://www.freebsd.org/gnome/docs/faq2.html#q23
 
  http://www.freebsd.org/gnome/docs/faq2.html#q23
 
+
</ul>
 
<li>Create a file /etc/vnx_rootfs_version to store version number and informacion about modification:</li>
 
<li>Create a file /etc/vnx_rootfs_version to store version number and informacion about modification:</li>
 
<pre>
 
<pre>
VER=v0.21
+
VER=v0.25
OS=FreeBSD 8.2
+
OS=FreeBSD 9.1
DESC=Basic FreeBSD 8.2 root filesystem without GUI
+
DESC=Basic FreeBSD 9.1 root filesystem without GUI
</pre>
 
 
 
<li>Create a script named /usr/local/bin/vnx_halt:</li>
 
<pre>
 
#!/usr/local/bin/bash
 
# Delete /etc/resolv.conf
 
rm -f /etc/resolv.conf
 
# Clean command history
 
rm -f /root/.bash_history
 
# Delete VNXACE log
 
rm -f /var/log/vnxaced.log
 
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
 
# Halt the system
 
halt -p
 
 
</pre>
 
</pre>
 
<li>Give the script execution permissions:</li>
 
chmod +x /usr/local/bin/vnx_halt
 
 
 
<li>Stop the machine with that script:</li>
 
<li>Stop the machine with that script:</li>
 
  vnx_halt
 
  vnx_halt
 
 
</ul>
 
</ul>
 
</ul>
 
</ul>
Line 167: Line 136:
 
  hal-disable-polling --device /dev/acd0
 
  hal-disable-polling --device /dev/acd0
  
=== Installing additional software ===
+
== Installing additional software ==
  
To install additional software or modify your root file system, you just have to start it as described above and:
+
To install additional software or to modify your root file system, you just have to:
 
<ul>
 
<ul>
<li>Configure network interface with:</li>
+
<li>Start a virtual machine from it:</li>
 +
vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2
 +
<li>Check network connectivity. Maybe you have to activate the network interface by hand:</li>
 
  dhclient re0
 
  dhclient re0
<li>Install new packages using "pkg_add -r ..." commands or using "sysinstall" utility. For example, to install apache web server:</li>
+
Note: use "ip link show" to know which network interface to use.
pkg_add -r apache22
+
<li>Do the modifications you want.</li>
<li>Stop de virtual machine with:</li>
+
<li>Finally, halt the system using:</li>
  halt -p
+
  vnx_halt
 
</ul>
 
</ul>
  
=== Updating ACE daemon ===
+
== Updating VNXACED ==
 +
 
 +
You can automatically update the VNXACE daemon with the following command:
 +
vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2 --update-aced -y
 +
If VNXACE daemon is not updated automatically, you can do it manually by accessing the virtual machine console and type:
 +
mount -t msdosfs /dev/ada1 /mnt/  # if virtio=no in /etc/vnx.conf
 +
mount -t msdosfs /dev/vtbd1 /mnt/  # if virtio=yes in /etc/vnx.conf
 +
perl /mnt/vnxaced-lf/install_vnxaced
 +
 
 +
== Known problems ==
 +
 
 +
<ul>
 +
<li>Textual consoles hang when copy-pasting. With FreeBSD 8.2 and 9.0, the textual console works well when manually typing commands. But, for an unkonwn reason, if you paste something, they get blocked and you have to restart the viertual machine to get the console working again. This problem did not happen with FreeBSD 7.4</li>
 +
 
 +
</ul>
  
If you have a root filesystem with the autoconfiguration and command execution daemon (ACE) already installed, you can use the autoupdate functionallity to update the daemon to a newer version. Just follow this procedure:
+
== FreeBSD tips ==
  
* Edit the xml described above and comment the line defining the Freebsd iso file for the cdrom:
+
<ul>
<!--source file='/almacen/iso/FreeBSD-8.1-RELEASE-i386-disc1.iso'/-->
+
<li>To update/upgrade FreeBSD use "freebsd-update" command. For example to upgrade from FreeBSD 9.0 to 9.1:</li>
* Start the virtual machine (directly using virsh or the vnx_modify_rootfs utility):
+
freebsd-update -r 9.1-RELEASE upgrade
  /usr/share/vnx/bin/vnx_modify_rootfs rootfs_freebsd.xml
+
<li>'''Use of virtio drivers in FreeBSD'''</li>
* Execute the update utility:
+
<ul>
  /usr/share/vnx/bin/vnx_update_aced Freebsd /usr/share/vnx/aced/vnx-aced-lf-0.1b.tgz
+
<li>If you start a FreeBSD image created to use ''virtio'' drivers in a non-virtio environment (virtio=no in vnx.conf), the vm will not start and a "mountroot>" propmt will appear. In that case just type:</li>
* Once the ace daemon is updated the virtual machine will be rebooted automatically.
+
mountroot> ufs:/dev/ada0p2
 +
<li>Similarly, if you start a non-virtio FreeBSD image in a virtio enviroment, you have to type:</li>
 +
mountroot> ufs:/dev/vtbd0p2
 +
<li>The content of /etc/fstab when using virtio should be:</li>
 +
  /dev/vtbd0p2    /               ufs    rw      1      1
 +
/dev/vtbd0p3    none            swap    sw      0      0
 +
<li>Similarly, the content of /etc/fstab when not using virtio should be:</li>
 +
/dev/ada0p2    /               ufs    rw      1      1
 +
/dev/ada0p3    none            swap    sw      0      0
 +
</ul>
 +
</ul>

Latest revision as of 23:52, 16 May 2016

How to create a KVM Freebsd root filesystem for VNX

Follow this procedure to create a KVM FreeBSD based root filesystem for VNX. The procedure has been tested with FreeBSD 10.0, 9.0, 8.2 and 7.4.

Basic installation

  • Create the filesystem disk image:
  • qemu-img create -f qcow2 vnx_rootfs_kvm_freebsd.qcow2 8G
    
  • Get FreeBSD installation CD. For example:
  • wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-i386-disc1.iso
    cp FreeBSD-9.1-RELEASE-i386-disc1.iso /almacen/iso
    
  • Create the virtual machine with:
  • vnx --create-rootfs vnx_rootfs_kvm_freebsd.qcow2 --install-media /almacen/iso/FreeBSD-9.1-RELEASE-i386-disc1.iso --mem 512M
    
  • Follow FreeBSD installation menus to install a basic system with DHCP configured in the network interface and a user named "vnx".
  • Configure the serial console by editting /etc/ttys file and changing the line:
  • ttyu0 "/usr/libexec/getty std.9600"   dialup  off secure
    

    to:

    ttyu0 "/usr/libexec/getty std.9600"   vt100  on secure
    
  • Set dual console configuration (see http://www.cct.lsu.edu/~ccui/diary/August19_2010.php):
  • echo "-Dh" > /boot.config
    echo 'boot_multicons="YES"' >> /boot/loader.conf
    echo 'boot_serial="YES"' >> /boot/loader.conf
    echo 'console="comconsole,vidconsole"' >> /boot/loader.conf
    

    IMPORTANT: in Ubuntu 13.04 the rootfs created adding this lines does not start! It hangs on bootloader consuming 100% of CPU. Seems to be a problem with the kvm/seabios versions in Ubuntu 13.04. Just skip this step to avoid the problem (you lose startup traces on serial console).

  • Finally, halt the system:
  • halt -p
    

Configuration

  • Restart the system with the following command:
  • vnx --modify-rootfs vnx_rootfs_kvm_freebsd.qcow2 --update-aced --mem 512M
    

    Note: ignore the errors "timeout waiting for response on VM socket".

  • Access the system through the text console to easy the copy-paste of commands:
  • virsh console vnx_rootfs_kvm_freebsd.qcow2
    
  • Install bash and change package repository (change ftp.es.freebsd.org to your nearest mirror):
  • pkg install bash # for FreeBSD 10.0
    pkg_add -r bash  # for previous FreeBSD versions
    pw usermod root -s /usr/local/bin/bash
    pw usermod vnx -s /usr/local/bin/bash 
    # only for FreeBSD 9.X 
    echo "export PACKAGESITE=ftp://ftp.es.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/Latest/" > ~/.bash_profile
    
  • Install perl and XML::LibXML library:
  • pkg install perl5 p5-XML-LibXML p5-NetAddr-IP  # FreeBSD 10.0
    pkg_add -r perl p5-XML-LibXML p5-NetAddr-IP   # previous versions
    
  • Disable DHCP on network interface by editing the /etc/rc.conf file and commenting the following line:
  • ifconfig_re0="DHCP"
    
  • Install VNX autoconfiguration daemon:
  • mount -t msdosfs /dev/ad1 /mnt/
    perl /mnt/vnxaced-lf/install_vnxaced
    
  • Optionally:
    • Allow root login thorugh ssh by editing /etc/ssh/sshd_config file:
    • PermitRootLogin yes
      
    • Set locales according to your preferences in /etc/profile:
    • export LANG=es_ES.UTF-8
      export LC_ALL=es_ES.UTF-8
      
    • Add gnome window manager with:
      • Install packages needed:
      • pkg_add -r xorg-minimal gnome2-lite gdm gnome-keyring detach xeyes xhost wmctrl # Previous FreeBSD versions
        
      • Add the following line to /etc/rc.conf:
      • gnome_enable="YES"
        
      • Add the following line to /etc/fstab:
      • proc    /proc   procfs  rw      0       0
        
      • Disable the screensaver and change keyboard configuration in "System->Keyboard" menu.
    • Reduce the boot timeout from 10 seconds to, for example, 3 seconds. Edit /boot/loader.conf and add:
    • autoboot_delay="3"
      
    • Give vnx user (or whatever one you have created during installation) permissions tu su root:
    • pw usermod vnx -G wheel
      
    • If you have installed gnome, you can add automatic login following the instructions in:
    • http://www.freebsd.org/gnome/docs/faq2.html#q23
      
  • Create a file /etc/vnx_rootfs_version to store version number and informacion about modification:
  • VER=v0.25
    OS=FreeBSD 9.1
    DESC=Basic FreeBSD 9.1 root filesystem without GUI
    
  • Stop the machine with that script:
  • vnx_halt
    

</ul>

If everything went well, your root filesystem will be ready to be used with VNX. You can make a simple test using the simple_freebsd.xml scenario distributed with VNX.

Note: after installing gnome, you probaly will get the following error message on the console:

acd0: FAILURE - unknown CMD (0x03) ILLEGAL REQUEST asc=0x20 ascq=0x00

To eliminate them you can execute:

hal-disable-polling --device /dev/acd0

Installing additional software

To install additional software or to modify your root file system, you just have to:

  • Start a virtual machine from it:
  • vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2
    
  • Check network connectivity. Maybe you have to activate the network interface by hand:
  • dhclient re0
    

    Note: use "ip link show" to know which network interface to use.

  • Do the modifications you want.
  • Finally, halt the system using:
  • vnx_halt
    

Updating VNXACED

You can automatically update the VNXACE daemon with the following command:

vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2 --update-aced -y

If VNXACE daemon is not updated automatically, you can do it manually by accessing the virtual machine console and type:

mount -t msdosfs /dev/ada1 /mnt/   # if virtio=no in /etc/vnx.conf
mount -t msdosfs /dev/vtbd1 /mnt/  # if virtio=yes in /etc/vnx.conf
perl /mnt/vnxaced-lf/install_vnxaced

Known problems

  • Textual consoles hang when copy-pasting. With FreeBSD 8.2 and 9.0, the textual console works well when manually typing commands. But, for an unkonwn reason, if you paste something, they get blocked and you have to restart the viertual machine to get the console working again. This problem did not happen with FreeBSD 7.4

FreeBSD tips

  • To update/upgrade FreeBSD use "freebsd-update" command. For example to upgrade from FreeBSD 9.0 to 9.1:
  • freebsd-update -r 9.1-RELEASE upgrade
    
  • Use of virtio drivers in FreeBSD
    • If you start a FreeBSD image created to use virtio drivers in a non-virtio environment (virtio=no in vnx.conf), the vm will not start and a "mountroot>" propmt will appear. In that case just type:
    • mountroot> ufs:/dev/ada0p2
      
    • Similarly, if you start a non-virtio FreeBSD image in a virtio enviroment, you have to type:
    • mountroot> ufs:/dev/vtbd0p2
      
    • The content of /etc/fstab when using virtio should be:
    • /dev/vtbd0p2    /               ufs     rw      1       1
      /dev/vtbd0p3    none            swap    sw      0       0
      
    • Similarly, the content of /etc/fstab when not using virtio should be:
    • /dev/ada0p2    /               ufs     rw      1       1
      /dev/ada0p3    none            swap    sw      0       0