Difference between revisions of "Vnx-rootfsfedora"

From VNX
Jump to: navigation, search
(Basic installation)
 
(55 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Title|How to create a Fedora root filesystem for VNX}}
+
{{Title|How to create a KVM Fedora root filesystem for VNX}}
  
Follow this procedure to create a fedora based root filesystem for VNX. The procedure has been tested with Fedora 14.
+
Follow this procedure to create a KVM Fedora based root filesystem for VNX. The procedure has been tested with Fedora 24, 20, 18, 16 and 14.
  
 
== Basic installation ==
 
== Basic installation ==
 
<ul>
 
<ul>
 
<li>Create the filesystem disk image:</li>
 
<li>Create the filesystem disk image:</li>
  qemu-img create -f qcow2 root_fs_fedora-base.qcow2 5GB
+
  qemu-img create -f qcow2 vnx_rootfs_kvm_fedora.qcow2 20G
 
<li>Get Fedora 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 Fedora 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 ftp://ftp.rediris.es/mirror/fedora/14/Fedora/i386/iso/Fedora-14-i386-DVD.iso
+
  wget ftp://ftp.rediris.es/mirror/fedora/16/Fedora/i386/iso/Fedora-16-i386-DVD.iso
  cp Fedora-14-i386-DVD.iso /almacen/iso
+
  cp Fedora-16-i386-DVD.iso /almacen/iso
<li>Create a libvirt XML definition (root_fs_freebsd.xml) containing the virtual machine description:</li>
+
<li>Create the virtual machine with:</li>
 +
vnx --create-rootfs vnx_rootfs_kvm_fedora.qcow2 --install-media /almacen/iso/Fedora-16-i386-DVD.iso --mem 768M
 +
Note: add '''"--arch x86_64"''' option for 64 bits virtual machines
 +
<li>Follow the Fedora installation assistant. At some point, you will have to choose among different system profiles: desktop, web server, minimal, etc.</li>
 +
<li>Enable login on the first serial line:</li>
 +
<ul>
 +
<li>Fedora 18, 20 and 24:</li>
 +
<ul>
 +
<li>Edit /etc/default/grub and add:</li>
 
<pre>
 
<pre>
<domain type='kvm'>
+
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8  net.ifnames=0 biosdevname=0"
  <name>Fedora</name>
+
GRUB_TERMINAL="serial"
  <memory>524288</memory>
+
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
  <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/root_fs_fedora-base.qcow2'/>
 
      <target dev='hda'/>
 
    </disk>
 
    <disk type='file' device='cdrom'>
 
      <source file='/almacen/iso/Fedora-14-i386-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>
 
 
</pre>
 
</pre>
Note: change "source file=" lines to whatever fits your case (use full paths).
+
<li>And afterwards execute:</li>
 
+
  grub2-mkconfig -o /boot/grub2/grub.cfg
<li>Start the virtual machine with and access its console with:</li>
+
</ul>
  virsh create root_fs_fedora.xml
+
<li>Fedora 16. Execute this command:</li>
virt-viewer Fedora
+
ln -s /usr/lib/systemd/system/getty@.service  /etc/systemd/system/getty.target.wants/getty@ttyS0.service
<li>Follow Fedora installation menus to install:</li>
+
<li>Fedora 14. Create a file named /etc/init/serial-ttyS0.conf with the following content:</li>
<ul>
+
#This service maintains a getty on /dev/ttyS0.
<li>A "minimal" system, if you want a server rootfs without user interface</li>
+
start on stopped rc RUNLEVEL=[2345]
<li>One of the other options (e.g "web server", "desktop system", etc) if you want a system with graphical user interface</li>
+
stop on starting runlevel [016]
 +
respawn
 +
exec /sbin/agetty /dev/ttyS0 9600 vt100-nav
 +
And add ttyS0 to /etc/securetty file if you want to login root on that console:
 +
echo "ttyS0" >> /etc/securetty
 
</ul>
 
</ul>
<li>Once installation is finished, stop the machine, edit root_fs_fedora.xml file and comment the following line in cdrom disk specification:</li>
+
<li>Finally, delete the net udev rules file and halt the system:</li>
  <!--source file='/almacen/iso/Fedora-14-i386-DVD.iso'/-->
+
  rm /etc/udev/rules.d/70-persistent-net.rules
<li>Start the virtual machine again with:</li>
+
  halt -p
virsh create root_fs_fedora.xml
 
  virt-viewer Fedora
 
 
</ul>
 
</ul>
  
 
== Configuration ==
 
== Configuration ==
 
<ul>
 
<ul>
 +
<li>Restart the system with the following command:</li>
 +
vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2 --update-aced --mem 768M
 +
Note: ignore the errors "timeout waiting for response on VM socket". 768M are needed if you are installing a root filesystem with desktop interface
 +
Note: add '''"--arch x86_64"''' option for 64 bits virtual machines
 +
<li>Access the system through the text console to easy the copy-paste of commands:</li>
 +
virsh console vnx_rootfs_kvm_fedora.qcow2
 +
<li>Check that you have network connectivity. Maybe you have to activate the network interface by hand:</li>
 +
dhclient eth0
 +
Note: use "ip link show" to know which network interface to use.
 
<li>Update the system and install additional packages</li>
 
<li>Update the system and install additional packages</li>
 
  yum update
 
  yum update
  yum install perl perl-XML-DOM acpid udisks
+
  yum install perl perl-XML-LibXML perl-NetAddr-IP acpid udisks perl-Sys-Syslog xterm
 
Note: if yum fails, check that the network is working. Maybe you will have to manually execute "dhclient eth0", at least in the case of a minimal installation.
 
Note: if yum fails, check that the network is working. Maybe you will have to manually execute "dhclient eth0", at least in the case of a minimal installation.
 
<li>Install VNX autoconfiguration daemon:</li>
 
<li>Install VNX autoconfiguration daemon:</li>
<ul>
+
mount /dev/sdb /mnt/
 +
perl /mnt/vnxaced-lf/install_vnxaced
 +
<li>Disable Network Manager to avoid problems with autoconfiguration daemon</li>
 +
systemctl stop NetworkManager.service
 +
systemctl disable NetworkManager.service
 +
systemctl enable network.service
 +
<!--ul>
 
<li>From the host execute:</li>
 
<li>From the host execute:</li>
 
  /usr/share/vnx/bin/vnx_update_aced Fedora /usr/share/vnx/aced/vnx-aced-lf-0.1b.tgz  
 
  /usr/share/vnx/bin/vnx_update_aced Fedora /usr/share/vnx/aced/vnx-aced-lf-0.1b.tgz  
Line 80: Line 71:
 
  ln -s /media/CDROM /media/cdrom
 
  ln -s /media/CDROM /media/cdrom
 
  udisks --mount /dev/sr0
 
  udisks --mount /dev/sr0
  perl /media/cdrom/install_vnxdaemon
+
  perl /media/cdrom/install_vnxaced
</ul>
+
</ul-->
<li>Enable login on the first serial line by creating a file named /etc/init/serial-ttyS0.conf with the following content:</li>
 
#This service maintains a getty on /dev/ttyS0.
 
start on stopped rc RUNLEVEL=[2345]
 
stop on starting runlevel [016]
 
respawn
 
exec /sbin/agetty /dev/ttyS0 9600 vt100-nav
 
<li>Besides, you have to add ttyS0 to /etc/securetty file if you want to login root on that console:</li>
 
echo "ttyS0" >> /etc/securetty
 
 
<li>If you have chosen a "minimum installation", activate network services (they are disabled by default):</li>
 
<li>If you have chosen a "minimum installation", activate network services (they are disabled by default):</li>
 
  chkconfig --level 3 network on
 
  chkconfig --level 3 network on
Line 96: Line 79:
 
<li>Install other services needed, for example, an apache server:</li>
 
<li>Install other services needed, for example, an apache server:</li>
 
  yum install httpd
 
  yum install httpd
  update-rc.d -f apache2 remove  # to avoid automatic start
+
  chkconfig httpd off  # if you want to avoid automatic start of apache server
 
<li>Or, if using a "minumum installation", install network utilities:</li>
 
<li>Or, if using a "minumum installation", install network utilities:</li>
 
  yum install telnet wget openssh-clients
 
  yum install telnet wget openssh-clients
Line 103: Line 86:
 
  AutomaticLogin=vnx
 
  AutomaticLogin=vnx
 
<li>Disable the firewall. Firewall is enabled by default; that could be problematic for testing purpose systems. If desired, disable it graphically in "System|Administration|Firewall" option, or using the following command from the command line:</li>
 
<li>Disable the firewall. Firewall is enabled by default; that could be problematic for testing purpose systems. If desired, disable it graphically in "System|Administration|Firewall" option, or using the following command from the command line:</li>
 +
# Fedora 18
 +
chkconfig firewalld off
 +
 +
# Fedora 16 & 14
 
  chkconfig iptables off
 
  chkconfig iptables off
 +
chkconfig ip6tables off
 +
<li>Change grub timeout to 0 by editing /etc/default/grub file and setting:</li>
 +
GRUB_TIMEOUT=0
 +
and executing:
 +
grub2-mkconfig -o /boot/grub2/grub.cfg 
 +
<li>Disable screensaver if using a GUI.</li>
 
</ul>
 
</ul>
<li>Create a file /etc/vnx_root_fs_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. For example:</li>
 
<pre>
 
<pre>
VER=v0.21
+
VER=v0.25
OS=Fedora 14
+
OS=Fedora 18
DESC=Basic Fedora 14 root-filesystem without GUI
+
DESC=Basic Fedora 18 root-filesystem without GUI
 
</pre>
 
</pre>
<li>Create a script named /usr/local/bin/vnx_halt:</li>
+
<li>Finally, stop the virtual machine with:</li>
<pre>
 
#!/bin/bash
 
# Clean yum cache
 
yum clean all
 
# 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
 
# Ask for a message to save in /etc/vnx_root_fs_version file
 
echo "Describe the modifications done to the root-fs to log them into /etc/vnx_r
 
oot_fs_version file (1 line maximum):"
 
read logmsg
 
DATE=`date`
 
echo "MODDATE=$DATE" >> /etc/vnx_root_fs_version
 
echo "MODDESC=$logmsg" >> /etc/vnx_root_fs_version
 
# Halt the system
 
halt
 
</pre>
 
<li>Give the script execution permissions:</li>
 
chmod +x /usr/local/bin/vnx_halt
 
<li>Stop the machine with that script:</li>
 
 
  vnx_halt
 
  vnx_halt
</ul>
+
''vnx_halt'' deletes some caches and log files and optionally lets you write a short message to ''/etc/vnx_rootfs_version file'' describing the latest modifications done.</ul>
  
 
== Installing additional software ==
 
== Installing additional software ==
  
To install additional software or modify your root filesystem, you just have to start it as described above and make the operations required on the filesystem.
+
To install additional software or to modify your root file system, you just have to:
* Start the virtual machine (directly using virsh or the vnx_modify_rootfs utility):
+
<ul>
  /usr/share/vnx/bin/vnx_modify_rootfs root_fs_fedora.xml
+
<li>Start a virtual machine from it:</li>
* Install the software:
+
vnx --modify-rootfs vnx_rootfs_kvm_fedora.qcow2
  yum install ...
+
<li>Check network connectivity. Maybe you have to activate the network interface by hand:</li>
* Stop the machine with:
+
  dhclient eth1
 +
Note: use "ip link show" to know which network interface to use.
 +
<li>Do the modifications you want.</li>
 +
<li>Finally, halt the system using:</li>
 
  vnx_halt
 
  vnx_halt
 +
</ul>
 +
 +
== 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 /dev/sdb /mnt/
 +
perl /mnt/vnxaced-lf/install_vnxaced
  
 
== Known problems ==
 
== Known problems ==

Latest revision as of 00:07, 3 November 2016

How to create a KVM Fedora root filesystem for VNX

Follow this procedure to create a KVM Fedora based root filesystem for VNX. The procedure has been tested with Fedora 24, 20, 18, 16 and 14.

Basic installation

  • Create the filesystem disk image:
  • qemu-img create -f qcow2 vnx_rootfs_kvm_fedora.qcow2 20G
    
  • Get Fedora 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 ftp://ftp.rediris.es/mirror/fedora/16/Fedora/i386/iso/Fedora-16-i386-DVD.iso
    cp Fedora-16-i386-DVD.iso /almacen/iso
    
  • Create the virtual machine with:
  • vnx --create-rootfs vnx_rootfs_kvm_fedora.qcow2 --install-media /almacen/iso/Fedora-16-i386-DVD.iso --mem 768M
    

    Note: add "--arch x86_64" option for 64 bits virtual machines

  • Follow the Fedora installation assistant. At some point, you will have to choose among different system profiles: desktop, web server, minimal, etc.
  • Enable login on the first serial line:
    • Fedora 18, 20 and 24:
      • Edit /etc/default/grub and add:
      • GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8  net.ifnames=0 biosdevname=0"
        GRUB_TERMINAL="serial"
        GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
        
      • And afterwards execute:
      • grub2-mkconfig -o /boot/grub2/grub.cfg
        
    • Fedora 16. Execute this command:
    • ln -s /usr/lib/systemd/system/getty@.service   /etc/systemd/system/getty.target.wants/getty@ttyS0.service
      
    • Fedora 14. Create a file named /etc/init/serial-ttyS0.conf with the following content:
    • #This service maintains a getty on /dev/ttyS0.
      start on stopped rc RUNLEVEL=[2345]
      stop on starting runlevel [016]
      respawn
      exec /sbin/agetty /dev/ttyS0 9600 vt100-nav
      

      And add ttyS0 to /etc/securetty file if you want to login root on that console:

      echo "ttyS0" >> /etc/securetty
      
  • Finally, delete the net udev rules file and halt the system:
  • rm /etc/udev/rules.d/70-persistent-net.rules
    halt -p
    

Configuration

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

    Note: ignore the errors "timeout waiting for response on VM socket". 768M are needed if you are installing a root filesystem with desktop interface Note: add "--arch x86_64" option for 64 bits virtual machines

  • Access the system through the text console to easy the copy-paste of commands:
  • virsh console vnx_rootfs_kvm_fedora.qcow2
    
  • Check that you have network connectivity. Maybe you have to activate the network interface by hand:
  • dhclient eth0
    

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

  • Update the system and install additional packages
  • yum update
    yum install perl perl-XML-LibXML perl-NetAddr-IP acpid udisks perl-Sys-Syslog xterm
    

    Note: if yum fails, check that the network is working. Maybe you will have to manually execute "dhclient eth0", at least in the case of a minimal installation.

  • Install VNX autoconfiguration daemon:
  • mount /dev/sdb /mnt/
    perl /mnt/vnxaced-lf/install_vnxaced
    
  • Disable Network Manager to avoid problems with autoconfiguration daemon
  • systemctl stop NetworkManager.service 
    systemctl disable NetworkManager.service
    systemctl enable network.service 
    
  • If you have chosen a "minimum installation", activate network services (they are disabled by default):
  • chkconfig --level 3 network on
    
  • Optionally:
    • Install other services needed, for example, an apache server:
    • yum install httpd
      chkconfig httpd off  # if you want to avoid automatic start of apache server
      
    • Or, if using a "minumum installation", install network utilities:
    • yum install telnet wget openssh-clients
      
    • If you want automatic login, just edit /etc/gdm/custom.conf and add the following lines:
    • AutomaticLoginEnable=true
      AutomaticLogin=vnx
      
    • Disable the firewall. Firewall is enabled by default; that could be problematic for testing purpose systems. If desired, disable it graphically in "System|Administration|Firewall" option, or using the following command from the command line:
    • # Fedora 18
      chkconfig firewalld off
      
      # Fedora 16 & 14
      chkconfig iptables off
      chkconfig ip6tables off
      
    • Change grub timeout to 0 by editing /etc/default/grub file and setting:
    • GRUB_TIMEOUT=0
      

      and executing:

      grub2-mkconfig -o /boot/grub2/grub.cfg  
      
    • Disable screensaver if using a GUI.
  • Create a file /etc/vnx_rootfs_version to store version number and informacion about modification. For example:
  • VER=v0.25
    OS=Fedora 18
    DESC=Basic Fedora 18 root-filesystem without GUI
    
  • Finally, stop the virtual machine with:
  • vnx_halt
    
    vnx_halt deletes some caches and log files and optionally lets you write a short message to /etc/vnx_rootfs_version file describing the latest modifications done.

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 eth1
    

    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 /dev/sdb /mnt/
perl /mnt/vnxaced-lf/install_vnxaced

Known problems