Kickstart Server on Synology

This was performed on this release of DSM: DSM 6.2.2-24922 Update 4 and a DS418+

Synology Diskstations can offer allot of flexibility to a home lab. Originally I had a Centos7 kickstart instance running in VMware but I wanted something that was always available. Since I use my DS418+ for backups and media I wanted to leverage it for doing Kickstarts. Using some of the guides available on Synology I was able to devise a solution that worked.

Note: Some of the verbiage came from Synology guide.

What is PXE?

Preboot Execution Environment (PXE) is an environment that allows devices to boot up over the network prior to booting up with the operating system on local storage. Instead of using the operating system on its local storage, a client device can boot up using a network bootstrap program (NBP) stored on your Synology NAS.

In this type of environment, operating systems can be installed on client devices from your Synology NAS, eliminating the need to physically visit each client PC with a stack of installation CDs. Setting up a new client PC is as simple as connecting it to the network and powering it on. This can dramatically reduce administration time.

To implement PXE, network bootstrap programs are stored on your Synology NAS in the folder of your choice. After modifying the settings of your existing DHCP server to redirect client devices to the appropriate file path, client devices can access the network bootstrap programs via TFTP. Alternatively, you can set up Synology’s DHCP services, which allow you to provide both DHCP and TFTP service with the same Synology NAS, implementing an all-in-one PXE solution.

2. Before you start

Before starting, please do the following:

  • Set up your Synology NAS and install Synology DiskStation Manager (DSM).
  • Create at least one volume (see here) and shared folder (see here).
  • Make sure your client device supports PXE.

For information about basic hardware and software setup, please refer to the Quick Installation Guide for your Synology product. In addition, you can also see Synology DiskStation User’s Guide for additional information related to this article. Both documents are available at the Synology Download Center.

3. Setting up TFTP, PXE, DHCP, & FTP

In the sections below, we’ll take a look at two ways Synology NAS can help you implement PXE:

In this scenario FTP, TFTP and DHCP service with a single Synology NAS.

To enable TFTP on Synology NAS:

  1. Go to Main Menu > Control Panel > File Services and select the TFTP tab.
  2. Tick Enable TFTP service.
  3. In the TFTP root folder section, select the folder where you stored the network bootstrap program for Linux (pxelinux.0) and any other files required for booting up your client device. (Your settings and environment will differ from the example below.)

To enable PXE on Synology NAS:

  1. Go to Main Menu > Control Panel > DHCP Server and select the PXE tab.
  2. Tick Enable PXE service.
  3. In the Boot loader section, select the file for the bootstrap program. In this case for Linux (pxelinux.0). (Your settings and environment will differ from the example below.)

To enable DHCP on Synology NAS:

  1. Go to Main Menu > Control Panel > Network Interface.
  2. Tick Enable DHCP server.
  3. In the Primary DNS sections enter your DNS IPs. (Your settings and environment will differ from the example below.)
  4. Click Add
  1. Enter Start IP, End IP, Netmask, Gateway and Lease time (24hrs is 1440 minutes).
  2. Should not need any DHCP options.
  3. Click Enable

To enable FTP on Synology NAS:

  1. Make sure you have an FTP share already created. In my case I created one called “ftp”.
  2. Go to Main Menu > Control Panel > File Services and select the FTP tab.
  3. Tick Enable FTP service.
  4. Leave defaults, also make sure your permissions are correct on your ftp and tftp folders otherwise you will get a failure. You need at least read permissions on “other” Since its in my house and behind a firewall I don’t care as much and its open. (Your settings and environment will differ from the example below.)
  1. Click on General and click on Advanced Settings and under the Security Settings:
    • Check “Change user root directories”
    • Check “Change Anonymous root”
      • Add shared folder. If its setup correctly you will see “ftp” in my case.
  2. Test FTP, use a client or terminal session and ftp anonymously and you should be able to see the directory that your FTP service is tied to. Remember you have to create a share

Getting the appropriate Linux files over.

Copy over SYSLINUX files

The next task is fairly straight forward. You need to copy SYSLINUX bootloaders to the “tftpboot” directory. I had a RedHat 7 VM that I used to accomplish this.

# yum install syslinux -y

Once you have them installed copy them to the “tftpboot” directory on the Synology that you would have created aready. In my case I created a share called tftp and a directory called tftpboot:

# scp -r /usr/share/syslinux/*admin@10.0.1.166:/volume2/tftp/tftpboot

Note: If you get permission denied errors, you can open up the directory temporarily. Just make sure you have at least read/execute permissions for other. Assuming no files under this: i.e. chmod -R 777 tftp/tftpboot

Create PXE Server Configuration File

I have a Macbook Pro as my primary system so to create this I use “vi” in a terminal session. Doesn’t matter where you edit it but on Windows can use notepad as it will not add in special characters. This file will end up going into your tftpboot directory. Yours will be different but I use this one that I copied from Techmint. The example below was modified to suit my needs:

ssh to Diskstation: 
# cd /<VOLUME_NAME>/tftp/tftpboot
# vi default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

menu title ########## PXE Boot Menu ##########

label 1
menu label ^1) Install CentOS 7 x64 with Local Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://10.0.1.166/pub/centos7 devfs=nomount inst.repo=ftp://10.0.1.166/pub/centos7 inst.ks=ftp://10.0.1.166/pub/centos7/centos7-ks.cfg

label 2
menu label ^2) Install CentOS 7 x64 with http://mirror.centos.org Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount ip=dhcp

label 3
menu label ^3) Install CentOS 7 x64 with Local Repo using VNC
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://10.0.1.166/pub/centos7 devfs=nomount inst.vnc inst.vncpassword=password

label 4
menu label ^4) Install Red Hat 8 x64 with Local Repo
kernel rh8/vmlinuz
append initrd=rh8/initrd.img ip=dhcp inst.repo=ftp://10.0.1.166/pub/rh8 inst.ks=ftp://10.0.1.166/pub/rh8/rh8-ks.cfg

label 5
menu label ^5) Install RedHat 7 x64 with Local Repo
kernel rh7/vmlinuz
append initrd=rh7/initrd.img ip=dhcp inst.repo=ftp://10.0.1.166/pub/rh7 inst.ks=ftp://10.0.1.166/pub/rh7/rh7-ks.cfg

label 6
menu label ^6) Install RedHat 7 x64 with AT&T Repo
kernel rh7/vmlinuz
append initrd=rh7/initrd.img ip=dhcp inst.repo=ftp://10.0.1.166/pub/rh7 inst.ks=ftp://10.0.1.166/pub/rh7/kickstart_att.cfg

label 7
menu label ^7) Install RedHat 6 x64 with Local Repo
kernel rh6/vmlinuz
append initrd=rh6/initrd.img ip=dhcp ks=ftp://10.0.1.166/pub/rh6/rh6-ks.cfg

label 10
menu label ^10) Boot from local drive

In your terminal enter the following to get it copied over to the right place:

If you created the file on your workstation then we need to get it to the right spot: # scp -r default admin@10.0.1.166:/volume2/tftp/tftpboot/pxelinux.cfg

Here is an example Red Hat 7 kickstart file. If you want more details refer to: Techmint. The encrypted password is “changeme” if you want to change the password in the kickstart file do the following:

# openssl passwd -1 password
The ouput will be the encrypyed password.  Just replace the content of the "rootpw" line.

rh7-ks.cfg

lang en_US
keyboard us
timezone America/New_York –isUtc
rootpw $1$HO3ad3ft$6dmLgtB8fNwZRDLy2YIDV1 –iscrypted
#platform x86, AMD64, or Intel EM64T
text
url –url=ftp://ftp@10.0.1.166//pub/rh7
bootloader –location=mbr –append=”rhgb quiet crashkernel=auto”
zerombr
clearpart –all –initlabel
autopart
auth –passalgo=sha512 –useshadow
selinux –disabled
firewall –disabled
skipx
firstboot –disable
%packages
@base
%end

I tested this in a virtual machine. If you do this make sure it has at least 2G of memory otherwise it will fail.

Thanks, have fun

One thought on “Kickstart Server on Synology

Comments are closed.