RHEL7: Install Red Hat Enterprise Linux systems as virtual guests.

Share this link

Note: This is an RHCSA 7 exam objective.

Presentation

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.

Kickstart File

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.

Creation Command

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.

Additional Resources

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.

(5 votes, average: 4.80 out of 5)
Loading...
42 comments on “RHEL7: Install Red Hat Enterprise Linux systems as virtual guests.
  1. tcheung says:

    hi

    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?

  2. hunter86_bg says:

    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=”

  3. travisby says:

    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?

    • CertDepot says:

      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.

  4. ak340 says:

    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.

    • CertDepot says:

      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.

  5. ak340 says:

    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?

  6. langtu1511 says:

    Hi,
    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]”

    • CertDepot says:

      Yes, you can add the following option:
      –extra-args=”console=tty0 console=ttyS0,115200 ks=http://192.168.1.5/conf/ks_
      postfix.cfg”

      Thanks for this useful comment. I updated the tutorial.

  7. eazlan says:

    Hi CertDepot

    After creating a kickstart file, how do I create a VM?

    Thanks in advance

    • CertDepot says:

      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.

      • eazlan says:

        Hi,

        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 \
        –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”

        • CertDepot says:

          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:

          #!/bin/bash

          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:

          # chmod u+x script

          The x means execution right and the u represents the user/owner of the file.

  8. beshooo says:

    Hello CertDepot,
    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.

    • CertDepot says:

      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.

      • beshooo says:

        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
        Bishooo

        • CertDepot says:

          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.

    • Gjorgi says:

      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.

    • blumeout86 says:

      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.

      • Lisenet says:

        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.

  9. asifshabir says:

    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.

    • CertDepot says:

      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.

  10. ylemouel says:

    Hello,

    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?

  11. ntorga says:

    Is it possible to use Kickstart Generator on RHCSA?
    https://access.redhat.com/labs/kickstartconfig/

  12. neuraload says:

    Hello.

    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. 🙂

  13. ercole1977 says:

    Hi guys. Just for info: am I supposed to create a VM from command line on RHCSA exam?

  14. lozingalo says:

    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

    • CertDepot says:

      No, you don’t need to learn all the options.

      • lozingalo says:

        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.

Leave a Reply

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |