Note: This is an RHCSA 7 exam objective.
Installing an RHEL 7 system as virtual guest requires two steps:
- creating a Kickstart file with all the configuration parameters (ip address, disk partitioning, etc),
- running the command for the creation itself.
To create a VM called postfix.example.com (here with an IP address of 192.168.1.10, a gateway in 192.168.1.1, a DNS server in 192.168.1.5, a repository server in 192.168.1.5, Pass1234 as a password, and a total disk size of 6GB), create the file /var/www/html/conf/ks_postfix.cfg and paste the following lines:
keyboard --vckeymap=us --xlayouts='us' lang en_US.UTF-8 network --device=eth0 --bootproto=static --ip=192.168.1.10 --netmask=255.255.255.0 --gateway=192.168.1.1 --nameserver=192.168.1.5 --activate --ipv6=auto network --hostname=postfix.example.com rootpw Pass1234 timezone America/Los_Angeles --isUtc bootloader --location=mbr --boot-drive=vda clearpart --all --initlabel --drives=vda ignoredisk --only-use=vda part pv.9 --fstype="lvmpv" --ondisk=vda --size=5000 #part /boot/efi --fstype=efi --grow --maxsize=200 --size=20 part /boot --fstype="ext4" --ondisk=vda --size=300 volgroup rhel --pesize=4096 pv.9 logvol swap --fstype="swap" --size=500 --name=swap --vgname=rhel logvol / --fstype="ext4" --size=3072 --name=root --vgname=rhel %packages @base @core %end reboot
Note: Uncomment the line beginning with “part /boot/efi” in case of an EFI-based system.
Run the following command:
# /bin/virt-install \ --virt-type kvm \ --name=postfix.example.com \ --disk path=/var/lib/libvirt/images/postfix.example.com.img,size=6 \ --ram=1024 \ --vcpus=1 \ --os-variant=rhel7 \ --accelerate \ --graphics vnc \ -v -l http://192.168.1.5/repo/CentOS/7/os/x86_64/ \ --network bridge:br0 \ --extra-args="console=tty0 console=ttyS0,115200 ks=http://192.168.1.5/conf/ks_ postfix.cfg"
Note1: http in the previous command can be replaced with nfs, ftp, etc.
Note2: If you get this message “ERROR internal error: process exited while connecting to monitor: qemu-kvm: -chardev pty,id=charserial0: Failed to create chardev“, follow this thread.
Replace “devpts /dev/pts devpts defaults 0 0” with “devpts /dev/pts devpts gid=5,mode=620 0 0” in the /etc/fstab file of the KVM host.
Note3: Since RHEL 7.4, 1024MB of memory is not enough anymore, use at least 1064MB.
There is a documentation about the Anaconda installer and a repository with sample Kickstarts.
Frank Caviggia has written a script that installs a system that is configured and hardened to meet government-level regulations.
Giovanni Torres provides a Bash script to build local virtual machines using KVM/libvirt and cloud-init.
when I clicked the link “Install Red Hat Enterprise Linux automatically using Kickstart” from the web page “http://www.certdepot.net/rhel7-rhcsa-exam-objectives/”, I was re-directed to here. The hyperlink is wrong?
No, to me both objectives are parts of the same topic: server installation.
If you want to install RedHat from CD and you get your kickstart on another machine:
Press “Esc” key, type “linux ks=nfs:/192.168.1.1/config/ks.cfg”
nfs in the previous command can be replaced by “http” “ftp”, etc.
Additional boot time options “ip=” “mask=255.255.255.0” “ksdevice=”
I’m adding your comment. Thanks.
Hi! Just noticed that you mentioned to use 192.168.1.1 for the nameservers. Should that instead be 192.168.1.5, the master host we setup as DNS?
Or is this article meant to be separate-able from the ‘lab setup’ portion?
This tutorial was called from two different places.
I have put 192.168.1.5 as the IP address of the nameserver to keep the lab settings simple.
Hi CertDepot, wondering if from the exam we will be installing a VM server via kickstart, think it may consume a lot of exam period.
Even though installing a VM server via kickstart is an exam objective, it is very unlikely that this happens. You guessed: it consumes too much time.
Thanks CertDepot, I understand now that rhcsa exam is regarding fast execution, does this means as well that scripting will not be part of it?
No, you need to be ready to write small Bash scripts.
I prefer to use “console” parameter in the extra-args:
-x “ks=http://192.168.1.5/conf/ks_postfix.cfg console=ttyS0”
so that I can connect to VM by console directly “virsh console [vm-name]”
Yes, you can add the following option:
–extra-args=”console=tty0 console=ttyS0,115200 ks=http://192.168.1.5/conf/ks_
Thanks for this useful comment. I updated the tutorial.
After creating a kickstart file, how do I create a VM?
Thanks in advance
If you use KVM, after the creation of a kickstart file, you need to execute the virt-install command.
You should read the tutorial about Installing RHEL systems as virtual guests.
I’m new in RHEL. Appreciate if you can help me on “CREATION COMMAND”. How to build? Do I need to create a new *.sh file?
# /bin/virt-install \
–virt-type kvm \
–disk path=/var/lib/libvirt/images/postfix.example.com.img,size=6 \
–graphics vnc \
-v -l http://192.168.1.5/repo/CentOS/7/os/x86_64/ \
–network bridge:br0 \
–extra-args=”console=tty0 console=ttyS0,115200 ks=http://192.168.1.5/conf/ks_
You can either type the virt-install command at the prompt or create a Bash script.
If you create a Bash script, you need to start the script with the following line:
This line defines which binary needs to be called when the script starts.
You also need to give execution right on the script at the prompt:
The x means execution right and the u represents the user/owner of the file.
I am required to remember the world for the Kickstart script? Is this too long to remember? Is there a easy way to create this kickstart from testing machine in exam?
I think it is rare to come in exam?
Sorry for my bad English.
Yes, You are right. You shouldn’t need to learn everything about Kickstart because it doesn’t usually happen in the exam. The main reason is: it would take too long to install a VM from scratch. However, you should know the basics about Kickstart in case. Also, after the exam, Kickstart is a valuable skill to have.
Appreciate your fast feedback,
Sorry I have another question:
1-What is the exam redhat version 7 OR 7.2?
2-If I use the old method of IP configuration by editing in ifcfg-eth0, is this a risky method so I wouldn’t get mark?
Thanks in advance
1-Until this friday the exam was using version 7.0. This should change in the coming weeks.
2-You can perfectly use the old method but you need to reload the NetworkManager configuration through a nmcli con reload command.
You could use anaconda-ks.cfg file in /root as a template to create a full-blown customized Kickstart file. Appropriate man pages that would further explain options in that file can be found by rpm -qd pykickstart (though formatting makes the document kind of hard to read).
Sander Van Vugt’s guide has the greatest of all tutorials out there that explains how to set up a full-scale remote installation server and is a lot of fun.
I know this question is older, but these days, RedHat is relying more on Kubernetes and Ansible. I don’t know if those two can completely eliminate the need for Kickstart (I’m thinking of partitioning *physical* drives), but the Ansible route has quite a few advantages.
Kickstart is used for provisioning, Ansible is used for configuration management. They serve different purposes.
You can easily do Kickstart provisioning with Foreman, and then pass configuration management to Ansible once the system is up.
“Ansible can provision the latest cloud platforms, virtualized hosts and hypervisors, network devices and bare-metal servers.”
RedHat is committed to Ansible, and I wouldn’t be shocked if they completely remove KickStart from version 8 of the exam
I’m aware. Red Hat bought Ansible, of course they are going to push it hard.
I am trying to install centos 7 using ks method. It picks up ks file, setting everything else fine. But I always get the error “For Installation source”
“Error setting up base repository”. This is my ks.cfg file: http://www.heypasteit.com/clip/2LF9 . I have searched over net but could not solve this issue so far, Please extend your support for this.
The problem seems to reside in the way you configured your repository at “http://192.168.1.200/rhel/”.
I would advise you to check the following points:
– an Apache webserver is correctly set (DOCUMENTROOT, etc) and started at 192.168.1.200 that gives access to servers at least in the 192.168.1.0/24 network (Require all granted),
– SELinux is correctly configured for the /rhel directory for this webserver,
– a copy of a CentOS/RHEL CDRom has been done according to the rules,
– the firewall on this webserver leaves the 80 TCP port goes through and there is nothing in the /etc/hosts.deny file.
Thanks for your help, I’m also using Linux Academy, and they proposed using Virtual Manager for creating a VM via an iso downloaded from internet, is it enough?
To use Virtual Manager, you first need to install a Linux distribution (CentOS 7, RHEL 7, etc), then the virtualization packages (QEMU, KVM, etc). On PC, you can also use Virtual Box.
Do we have a Redhat iso available during the exam?
I don’t think so. However, if you need to install some packages (and you will), you will be given the details about the repository to put in place.
Is it possible to use Kickstart Generator on RHCSA?
Don’t spend too much time on Kickstart. It’s something you need to be aware of but you shouldn’t come across during the exam.
1.) I don’t know how is this supposed to work but if you don’t specify bus=virtio for the –disk parameter the autoinstaller won’t start because there is now ‘vda’ with default bus which is IDE ( sda ).
2.) “console=tty0 console=ttyS0” won’t work with graphical installer since the installation program will use ttyS0. I know, there is no reason to use the graphical installer. 🙂
Hi guys. Just for info: am I supposed to create a VM from command line on RHCSA exam?
No, you shouldn’t need to do that because it takes too much time to create a VM and because the exam is not really about this kind of task.
Thank you very much!
Hi, I’ll have the RHCSA exam on next Friday. In the objectives is not mentioned the installation using Kickstart but in this page it’s explained. Is it a requirement? How could I remember all the options to put in the kickstart file? Thank you
No, you don’t need to learn all the options.
Hi, here I am another time on this topic.
As we already spoke about, the installation of a vm using kickstart is no longer belonging to the RHCSA objectives. In this page you explain the installation with kickstart. I hope there will be nothing like this in the exam but, which is the procedure that I have to know in order to install a vm? Thank you very much.