.. _Configuring TFTP Server:

Configuring TFTP Server
-----------------------

Configuring TFTP Server for Installation on BIOS-based Client Servers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note:: If you get the "Permission denied" error when trying to connect to the TFTP server from the client server, try running ``# restorecon -Rv /tftboot/`` on the TFTP server.

To configure the TFTP server for installation on BIOS-based client servers, do the following:

1. Make sure the TFTP server, Xinetd, and SYSLINUX bootloader are installed:

   ::

       # yum install tftp-server syslinux xinetd

2. Edit the ``/etc/xinetd.d/tftp`` file to have the following:

   ::

       service tftp
       {
       disable         = no
       socket_type     = dgram
       protocol        = udp
       wait            = yes
       user            = root
       server          = /usr/sbin/in.tftpd
       server_args     = -v -s /tftpboot
       per_source      = 11
       cps             = 100 2
       flags           = IPv4
       }

3. Copy the following files to the ``/tftpboot`` directory (if this directory does not exist, create it under the root (``/``) directory):

   -  ``/images/pxeboot/vmlinuz`` and ``/images/pxeboot/initrd.img`` from the Virtuozzo distribution,

   -  ``menu.c32`` and ``pxelinux.0`` from the ``syslinux`` directory (usually ``/usr/share/syslinux`` or ``/usr/lib/syslinux``).

4. In the ``/tftpboot`` directory, create the ``/pxelinux.cfg`` directory. In it, create the file ``default``.

5. Add the following lines to ``/tftpboot/pxelinux.cfg/default``:

   ::

       default menu.c32
       prompt 0
       timeout 60
       ontimeout VZ
       menu title Virtuozzo Boot Menu
       label 1
            menu label Install Virtuozzo 7 with GUI management
            kernel vmlinuz
            append initrd=initrd.img ui ip=dhcp inst.repo=http://<HTTP_server_IP_address>/vz
       label 2
            menu label Install Virtuozzo 7 with CLI management
            kernel vmlinuz
            append initrd=initrd.img ip=dhcp inst.repo=http://<HTTP_server_IP_address>/vz

   .. note:: For more details on the parameters you can specify in ``/tftpboot/pxelinux.cfg/default``, see the documentation for ``syslinux``.

6. Start the ``xinetd`` service:

   ::

       # systemctl start xinetd.service

   Or restart it if already running:

   ::

       # systemctl restart xinetd.service

7. If necessary, allow incoming connections to the TFTP service in the firewall:

   ::

       # firewall-cmd --add-service=tftp --permanent
       # systemctl restart firewalld.service

.. _Configuring TFTP Server for Installation on EFI-based Client Servers:

Configuring TFTP Server for Installation on EFI-based Client Servers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note:: If you get the "Permission denied" error when trying to connect to the TFTP server from the client server, try running ``# restorecon -Rv /tftboot/`` on the TFTP server.

To configure the TFTP server for installation on EFI-based client servers, do the following:

1. Make sure the TFTP server and Xinetd are installed:

   ::

       # yum install tftp-server xinetd

2. Edit the ``/etc/xinetd.d/tftp`` file to have the following:

   ::

       service tftp
       {
       disable         = no
       socket_type     = dgram
       protocol        = udp
       wait            = yes
       user            = root
       server          = /usr/sbin/in.tftpd
       server_args     = -v -s /tftpboot
       per_source      = 11
       cps             = 100 2
       flags           = IPv4
       }

3. Copy the following files  from the Virtuozzo distribution to the ``/tftpboot`` directory (if this directory does not exist, create it under the root (``/``) directory):

   -  ``/images/pxeboot/vmlinuz``,

   -  ``/images/pxeboot/initrd.img``,
   
   -  ``/EFI/BOOT/grubx64.efi``.

4. In the ``/tftpboot`` directory, create the ``grub.cfg`` file. 

5. Add the following lines to ``/tftpboot/grub.cfg``:

   ::

       set timeout=60
           menuentry 'Virtuozzo 7 with GUI management' {
           linuxefi vmlinuz ui ip=dhcp inst.repo=http://<HTTP_server_IP_address>/vz
           initrdefi initrd.img
       }
           menuentry 'Virtuozzo 7 with CLI management' {
           linuxefi vmlinuz ip=dhcp inst.repo=http://<HTTP_server_IP_address>/vz
           initrdefi initrd.img
       }

6. Start the ``xinetd`` service:

   ::

       # systemctl start xinetd.service

   Or restart it if already running:

   ::

       # systemctl restart xinetd.service

7. If necessary, allow incoming connections to the TFTP service in the firewall:

   ::

       # firewall-cmd --add-service=tftp --permanent
       # systemctl restart firewalld.service

