Log in as root on the existing CentOS 7 system and make sure the kickstart configuration file exists by typing the following command and pressing the Return key to execute (this will show you the details of the file):
Next, physically plug in a USB device and then type the following command, which will give you a list of all the hard disk devices currently connected to the computer:
Try to identify the device name by comparing its size, partitions, and identified filesystems with the specifications of your USB device. The device name will be of kind /dev/sdX,
where X
is an alphabetical character, such as b
, c
, d
, e
, … and so on. If you cannot find the right device name for your USB media using the fdisk
command, try the following trick: run fdisk -l
twice - first with plugged-out and then with plugged-in USB device and compare how the second output changed - it has one device name more than the first output: your device name of interest !
If you have found the right device name in the list, create a directory to mount it to the current filesystem:
Next, actually mount the stick to this folder, assuming that your USB partition of choice is at /dev/sdc1
(change this as required):
Now we will create our working copy of the kickstart file on the USB device for customizing:
Next, open the copied kickstart file on the USB device with your favorite text editor (here we will use the editor nano, if you have not installed it yet type yum install nano
):
We will now modify the file for installing CentOS on a new target system. In nano, use the up and down arrow keys to go to the line which starts with (<your_hostname>
will be the name of the hostname you gave during installation e.g. minimal.home
):
Now edit the <your_hostname>
string to give it a new unique hostname. For example, add a -2
to the end of any existing name, as shown next:
Next, move the cursor down using the up and down arrow keys until it stops at the line which says %packages.
Append the following lines right below it (you can further customize this and provide additional packages that you want to install automatically):
Now save and close the file, to do this in the nano editor use the key combination Ctrl+o (which means, hold down the Ctrl key on the keyboard and then the o key without releasing the Ctrl key) to write the changes. Then press Return to confirm the filename and Ctrl+x to exit the editor.
Next, install the following CentOS package:
Now we validate the syntax of our kickstart file using the ksvalidator
program, which is included in the package we just installed:
If the config
file is error-free, unmount the USB stick now by using the following commands:
When you get a new command prompt again, unplug the USB device with the kickstart file for using on the target machine physically from the system.
Now you need physical access to the target machine you want to install CentOS on, using the kickstart file just created. Disconnect any other external file storage(s) that you do not need during the installation.
Power on the computer and put in your prepared CentOS installation media (must be a CentOS DVD or Everything installation disk image prepared on a CD/DVD disc or a USB device installer). Also connect to the computer the USB stick containing the kickstart file you just created in the earlier steps (if you using a USB drive for installing CentOS then you will need two free USB ports in total to complete this recipe).
Next, start the server and press the correct key during the initial bootup screen, associated with booting the CentOS installation media you just connected.
After the CentOS installer starts loading, the common standard CentOS 7 installation welcome screen will show up and the option Test this media & install CentOS 7 will be pre-selected by the cursor.
Next, press the Esc key on your keyboard once to switch to the boot: prompt
.
Now we are ready to start the kickstart installation. To do this, you need to know the exact partition name on the USB device where the kickstart file is located. Type the following command, assuming that your partition is at /dev/sdc1
(change this as required), and press the Return key to start the kickstart installation process:
Note
If you cannot find out the right device and partition name of the USB stick, you have to start the target system in rescue mode (refer to the Troubleshooting the system in rescue mode recipe) to identify the right device name and partition number by comparing its size, partitions, and identified filesystems with the specifications of your stick.
The new system now gets installed automatically using the instructions from the provided kickstart file. You can watch the installation output messages as it is showing the user detailed installation progress.
If the system has finished installing, reboot the system and log in to your new machine to verify that the new system has been setup the way we described using the kickstart file.