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:
- Go to Main Menu > Control Panel > File Services and select the TFTP tab.
- Tick Enable TFTP service.
- 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:
- Go to Main Menu > Control Panel > DHCP Server and select the PXE tab.
- Tick Enable PXE service.
- 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:
- Go to Main Menu > Control Panel > Network Interface.
- Tick Enable DHCP server.
- In the Primary DNS sections enter your DNS IPs. (Your settings and environment will differ from the example below.)
- Click Add
- Enter Start IP, End IP, Netmask, Gateway and Lease time (24hrs is 1440 minutes).
- Should not need any DHCP options.
- Click Enable
To enable FTP on Synology NAS:
- Make sure you have an FTP share already created. In my case I created one called “ftp”.
- Go to Main Menu > Control Panel > File Services and select the FTP tab.
- Tick Enable FTP service.
- 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.)
- 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.
- 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 /email@example.com:/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
menu title ########## PXE Boot Menu ##########
menu label ^1) Install CentOS 7 x64 with Local Repo
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
menu label ^2) Install CentOS 7 x64 with http://mirror.centos.org Repo
append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount ip=dhcp
menu label ^3) Install CentOS 7 x64 with Local Repo using VNC
append initrd=centos7/initrd.img method=ftp://10.0.1.166/pub/centos7 devfs=nomount inst.vnc inst.vncpassword=password
menu label ^4) Install Red Hat 8 x64 with Local Repo
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
menu label ^5) Install RedHat 7 x64 with Local Repo
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
menu label ^6) Install RedHat 7 x64 with AT&T Repo
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
menu label ^7) Install RedHat 6 x64 with Local Repo
append initrd=rh6/initrd.img ip=dhcp ks=ftp://10.0.1.166/pub/rh6/rh6-ks.cfg
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 firstname.lastname@example.org:/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.
timezone America/New_York –isUtc
rootpw $1$HO3ad3ft$6dmLgtB8fNwZRDLy2YIDV1 –iscrypted
#platform x86, AMD64, or Intel EM64T
bootloader –location=mbr –append=”rhgb quiet crashkernel=auto”
clearpart –all –initlabel
auth –passalgo=sha512 –useshadow
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