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 --fstype="ext4" --ondisk=vda --size=500
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

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.

Additional Resources

There is a documentation about the Anaconda installer.
Naftuli Tzvi Kay wrote a tutorial about using Packer to make Kickstart configuration easier.
Frank Caviggia has written a script that installs a system that is configured and hardened to meet government-level regulations.

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4.80 out of 5)
Loading...

Leave a Reply

31 Comments on "RHEL7: Install Red Hat Enterprise Linux systems as virtual guests."

Notify of
Sort by:   newest | oldest
tcheung
Member
tcheung

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?

hunter86_bg
Member

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

travisby
Member
travisby

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?

ak340
Member
ak340

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.

ak340
Member
ak340

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?

langtu1511
Member
langtu1511

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

eazlan
Member
eazlan

Hi CertDepot

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

Thanks in advance

beshooo
Member
beshooo

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.

Gjorgi
Member
Gjorgi

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.

asifshabir
Member
asifshabir

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.

ylemouel
Member
ylemouel

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?

ntorga
Member

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

wpDiscuz

RHCSA7: Task of the day

Allowed time: 10 minutes.
Create an EXT4 file system mounted by UUID in /etc/fstab under /vol based on a logical volume of 28 logical extents.

RHCE7: Task of the day

Allowed time: 3 minutes.
Configure your machine to be a router.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Recent Comments