If you are a GNU/Linux user, their is a high chance that you have used live media images i.e. live CD, live DVD or ISO. I was curious about how live images are created and recently got a chance to do some hands on.
There are multiple tools available for creating live media. However I am going to use livecd-tools to create live ISO. livecd tools need kickstart files to create the images and we will use CentOS upstream kickstart files .
As a first step install livecd-tools . I using CentOS Vagrant box to create live ISOs.
$ sudo yum install livecd-tools git -y
$ git clone https://github.com/CentOS/sig-core-livemedia
$ cd sig-core-livemedia/kickstarts
#You can use any one of the .cfg files in /sig-core-livemedia/kickstarts
$ livecd-creator --config <Kickstart file>
If you are new to kickstart files and want to know more about it refer the documentation: https://github.com/rhinstaller/pykickstart/blob/master/docs/kickstart-docs.rst
RHEL 7 and CentOS 7 moved to systemd from System V init facility. So if we want to run a script at boot, it is highly recommended that you should write a systemd unit file. However to ease the transition to systemd, CentOS7 /RHEL7 offers a backward compatibility mode for init scripts.
In a System V init system you need to add an entry of the script to /etc/rc.local (or equivalent) and the script will be executed during boot at the end of multi user run level.
In CentOS7 /etc/rc.local is a symbolic link to /etc/rc.d/rc.local.
root@localhost ~]# ls -l /etc/rc.local
lrwxrwxrwx. 1 root root 13 Apr 4 2016 /etc/rc.local -> rc.d/rc.local
To enable the init compatibility mode, you need to make /etc/rc.d/rc.local executable and then add the script to /etc/rc.local.
Here are the steps you need to perform to to start a script e.g. hello.sh during boot.
$ chmod +x /etc/rc.d/rc.local
#make the script executable
$ chmod +x hello.sh
#Make a entry in /etc/rc.local
$ cat /etc/rc.local
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
Reference : https://www.centos.org/forums/viewtopic.php?t=48140