How to Create a Backup Server: Using Clonezilla and PXE – Part 1

This is a two-part article that was adapted from the ODROID forum. This first half gives an introduction to the benefits of using Clonezilla, an overview of what will be covered, and the steps used to setup a DHCP server. For more information or to see the complete topic in the forum, which consists of several postings by @lazlo, please visit https://forum.odroid.com/viewtopic.php?f=52&t=33529.

Purpose

The goal of this HOWTO is to walk the reader through the creation of a simple and minimal network boot environment that allows any computer that supports PXE to boot Clonezilla over the local subnet for the purpose of creating and restoring disk images. This will require some knowledge of TCP/IP networking and the installation/configuration of software packages on your *nix distribution of choice. This guide will try to be distribution agnostic, hopefully, allowing the reader to use whichever flavor of *nix they like best. This also means that the location and layout of the configuration files on your system may differ from what is listed in this guide. If you get stuck please consult your distribution’s documentation for the given software package. Once you find a solution please leave a reply here to help other readers that come after you.

Why Clonezilla?

Clonezilla is nothing short of an Enterprise Class disk imaging suite. It runs on any x86 (32bit or 64bit) computer that can run Debian, it can both create and restore images of whole disks or individual partitions, it can compress and encrypt disk images, it supports a wide variety of network protocols, and it is truly free software. Read more at https://www.clonezilla.org and while you are there download the .zip file version of the installer and place it on the system you will using as the PXE server. We will need that later.

Why PXE?

For years my monthly backups went something like this:

  • 1. Look for my Clonezilla USB thumb drive
  • 2. Realize I must have accidentally overwritten it in the past month
  • 3. Create a new Clonezilla USB thumb drive
  • 4. A day later find my old Clonezilla USB thumb drive. Monthly backups have been so much simpler and less frustrating since I learned how to setup PXE.

How PXE booting works, in a nutshell, when the Client system is booted via PXE the first thing that happens is the client broadcasts a request for a DHCP Server to tell it not just what the client’s place is on the network but also where to find the files it needs to boot. The Client contacts the TFTP (Trivial File Transfer Protocol) Server it was referred to by the DHCP Server, and begins downloading the files it needs and stores them in RAM. Once this is complete the client then boots up from the files in RAM and is ready to be used.

What does this mean?

This means we will need a DHCP Server, a TFTP Server, a Client to back up, and optionally a File Server to store the backups. The DHCP server can be a home router, or stand alone server like the ISC DHCP server. If the DHCP server is a home router, or if you have some other DHCP server that you can’t reconfigure on your subnet, then we will need to use the dnsmasq package to act as a proxy between the client and the DHCP server. While dnsmasq is able to act as a TFTP, server, tftp-hpa is much more flexible if you ever want to expand your PXE server beyond the scope of this guide. It’s what I use on my home server and it is what I will explain in this guide. The client can be any x86 (32bit or 64bit) computer that supports booting via PXE and can run Debian. UEFI only mode will not work with this guide. I will start working on that soon though. The file server can be almost anything, it just needs a stable, and hopefully fast, network connection and enough disk space to hold the backups. On my home server I use NFS, but you can also use Samba/CIFS, SSH, Amazon AWS S3, and a few others. Finally, the DHCP, TFTP, and File Servers can all be installed in the same OS or they can all three be on different physical servers, VMs, and/or Containers.

What should you do before changing anything on your computers and/or network? You should read this guide from start to finish before doing anything or changing anything. Read the examples and follow the links. If you are not sure about something please remember that asking a question before you take action is better than asking how to fix a broken network. You should make a backup copy of all configuration files before editing them as you follow this guide. If the system(s) you are working with contain data you care about at all you should back that data up before you start. Remember that a backup is only a backup if you can actually restore it.

Part One: DHCP

dnsmaq as a DHCP Proxy

A word of caution before we begin: The dnsmasq package is used in wide variety of software stacks and you may already have it installed and running on your system. If that is the case then it is wise to ensure any changes you make to it’s configuration will not interfere with how it is being used elsewhere on your computer. There are a lot of ways to configure dnsmasq and a lot of documentation for how to use it. If you have never read the example config file for the package you can usually find it located in /usr/share/doc/dnsmasq-something-something-depending-on-your-distro. The file is well documented and educational thanks to its large number of examples and comments. The man page for dnsmasq can be found at http://www.thekelleys.org.uk/dnsmasq/do … q-man.html

If you do not already have dnsmasq then please install it at this point. The main config file is normally located at /etc/dnsmasq.conf or /etc/dnsmasq/dnsmasq.conf or /etc/dnsmasq.d/some_program_that_uses_dnsmasq.conf depending on your distro.

Here is the config for a bare bones dhcp proxy:

#This option enables some extra logging which might help with troubleshooting:

log-dhcp

#This option disables DNS services.  You should be getting DNS server info from 
#elsewhere if you installed dnsmasq just for the DHCP proxy.  If dnsmasq was
#already installed as part of a virtualization stack this might break your VM’s so
#test it early.  You may have to omit it:

port=0  

#A bit counter intuitive, this entry actually disables DHCP in dnsmasq and 
#tells it act as a proxy for all DHCP requests on the 192.168.0.0/24 subnet.  
#The safest option is to use the ip address of this server’s NIC, but any valid IP 
#address in your subnet will work:

dhcp-range=192.168.0.151,proxy,255.255.255.0

#This option is mainly for compatibility with older or broken DHCP clients.
#It doesn’t hurt to be careful:

dhcp-no-override

#This option tells the PXE what file it needs to start booting and where to get it.
#The path to the file pxelinux.0 is relative to the root directory for tftpd.
#Since this guide is about simple and minimal we will put it in the root dir.
#The IP address is for the TFTP server, which may or may not be the one running 
#our DHCP proxy:

dhcp-boot=pxelinux.0,192.168.0.151

#This option disables multicast and starts the download right away:

dhcp-option=vendor:PXEClient,6,2b
Don’t forget to restart the dnsmasq service after editing its config file.

ISC DHCP Server

The ISC DHCP Server is the standard DHCP server for most versions of Linux and Unix. You will want to use this if you want a powerful yet flexible DHCP server on your subnet. It is very well documented and it’s config is file well commented and that makes it educational as well. It’s home page is at https://www.isc.org/downloads/dhcp/ and a copy of the man pages can be found at https://www.isc.org/dhcp-manual-pages/ so take a bit of time and read over them as well as any distro specific documentation before you install it. The package name can vary from distro to distro but usually it is either “isc-dhcpd-server” or “dhcp” but you might have to search a bit. The main config file for the package is typically found in /etc/dhcp/dhcpd.conf and some distros might have a second file located at /etc/default/dhcp. Below is an excerpt from the dhcpd.conf on my home server with my own comments added:

#Start the subnet definition:
subnet 192.168.123.0 netmask 255.255.255.0 {
#Authoritative means that this is the main DHCP server on this subnet:
        authoritative;  
#This is the range of IP addresses given out by dhcpd:
        range 192.168.123.50 192.168.123.150;
#These next lines define the network topology for the subnet and allow 
#dhcpd to pass the needed parameters to the dhcp clients:
        option broadcast-address 192.168.123.255;
        option domain-name-servers 192.168.123.1, 192.168.0.1;
#I have my server set up to act as a router so this is the address of the LAN
#side NIC.  Otherwise enter the default gateway for your subnet:
        option routers 192.168.123.1;
#This is name of the file needed to start the PXE boot process. It’s path
#is relative to the TFTP root directory:
        filename "pxelinux.0";
#This is the IP address of the TFTP server that will be sending files to
#our PXE clients:
        next-server 192.168.123.1;
}
After you edit the config to meet your needs restart the dhcpd service.

Those are the first steps to setting up your own home backup server. The next half of this guide will be appearing in next month’s issue of ODROID magazine. If you have any questions, or if you want to read the complete forum posting on the ODROID forum please see the following link: https://forum.odroid.com/viewtopic.php?f=52&t=33529

Be the first to comment

Leave a Reply