How to install KVM Guest in Text Mode

Share on Social Media

In this guide, you will learn how to install KVM guest in text mode on QEMU/libvirt based KVM virtualization host. #centlinux #linux #virtualization

What is a KVM Guest?

A KVM guest refers to a virtual machine (VM) that runs on a host system using Kernel-based Virtual Machine (KVM) technology. KVM is an open-source virtualization solution for Linux that turns the Linux kernel into a hypervisor, allowing it to run multiple isolated virtual environments (guests) on a single physical machine (host).

Here are some key points about KVM guests:

  1. Virtual Machine: Each KVM guest is a virtual machine that runs its own operating system and applications, independently of the host system and other guests.
  2. Isolation: KVM provides isolation between guests, ensuring that they do not interfere with each other’s operation or with the host system.
  3. Resource Allocation: Resources such as CPU, memory, and storage can be allocated to each guest as needed. These resources can be adjusted dynamically to optimize performance.
  4. Management: KVM guests can be managed using various tools and interfaces, such as virsh (a command-line interface for managing virtual machines) and graphical tools like Virtual Machine Manager (virt-manager).
  5. Performance: KVM leverages hardware virtualization extensions (like Intel VT or AMD-V) to provide near-native performance for virtual machines.
  6. Use Cases: KVM guests are commonly used for server consolidation, development and testing environments, and running multiple operating systems on a single physical machine.

Overall, KVM provides a robust and efficient way to run multiple virtual machines on a Linux host, making it a popular choice for virtualization in both enterprise and personal use cases.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021

Problem Statement

We have configured a KVM Hypervisor in CentOS 8. Now, we are creating a KVM guest and installing CentOS 8 operating system in text mode.

KVM Hypervisor Specification

We are using a pre-configured KVM virtualization host with following specification.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 60 GB
  • Operating System – CentOS Linux 8.0
  • Hostname – kvm-virtualization-01.recipes.com
  • IP Address – 192.168.116.206 /24

Create a VM on KVM Hypervisor

To create a CentOS 8 virtual machine, we are required the CentOS 8 ISO file on our KVM Hypervisor.

Create a directory to store operating systems’ ISO files.

# mkdir /var/lib/libvirt/iso

Transfer the CentOS 8 ISO file to the KVM virtualization host using WinSCP.

Connect with kvm-virtualization-01.recipes.com using ssh as root user.

# ls /var/lib/libvirt/iso -alh
total 7.0G
drwxr-xr-x.  2 root root   80 Dec 30 14:39 .
drwxr-xr-x. 10 root root  117 Dec 30 14:20 ..
-rw-r--r--.  1 root root 330M Mar  1  2013 CentOS-6.3-x86_64-minimal.iso
-rw-r--r--.  1 root root 6.7G Sep 26 03:36 CentOS-8-x86_64-1905-dvd1.iso

Create a VM by using following command.

# virt-install --name kvm-guest-01 
> --memory 512 
> --vcpus 1 
> --disk size=20 
> --os-variant rhel8.0 
> --location /var/lib/libvirt/iso/CentOS-8-x86_64-1905-dvd1.iso 
> --graphics none 
> --extra-args='console=ttyS0'

Above command will create a VM and the Anaconda installer will be launched automatically.

Install KVM Guest in Text Mode

After scrolling through a lot of information and messages, the Anaconda installer will take you to the main installation menu.

Starting installer, one moment...
anaconda 29.19.0.40-1.el8 for CentOS Linux 8.0.1905 started.
 * installation log files are stored in /tmp during the installation
 * shell is available on TTY2
 * if the graphical installation interface fails to start, try again with the
   inst.text bootoption to start text installation
 * when reporting a bug add logs from /tmp as separate text/plain attachments
10:12:52 Not asking for VNC because we don't have a network
================================================================================
================================================================================
Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (America/New_York timezone)
3) [!] Installation source               4) [!] Software selection
       (Processing...)                          (Processing...)
5) [!] Installation Destination          6) [x] Kdump
       (No disks selected)                      (Kdump is enabled)
7) [!] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 2

Language settings are ok, therefore, no need to change it.

We entered the ‘2’ to set Time settings.

Time settings

Timezone: America/New_York

NTP servers:not configured

1) Change timezone
2) Configure NTP servers

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 1

Enter ‘1’ to set timezone.

Timezone settings

Available regions
1) Europe                  5) Antarctica              9) Indian
2) Asia                    6) Pacific                 10) Arctic
3) America                 7) Australia               11) US
4) Africa                  8) Atlantic                12) Etc

Please select the timezone. Use numbers or type names directly ['b' back to
region list, 'c' to continue, 'q' to quit, 'r' to refresh]: 2

Select your required region, we have selected ‘2’ for Asia.

Timezone settings

Available timezones in region Asia
1) Aden                    29) Hong_Kong              57) Pyongyang
2) Almaty                  30) Hovd                   58) Qatar
3) Amman                   31) Irkutsk                59) Qostanay
4) Anadyr                  32) Jakarta                60) Qyzylorda
5) Aqtau                   33) Jayapura               61) Riyadh
6) Aqtobe                  34) Jerusalem              62) Sakhalin
7) Ashgabat                35) Kabul                  63) Samarkand
8) Atyrau                  36) Kamchatka              64) Seoul
9) Baghdad                 37) Karachi                65) Shanghai
10) Bahrain                38) Kathmandu              66) Singapore
11) Baku                   39) Khandyga               67) Srednekolymsk
12) Bangkok                40) Kolkata                68) Taipei
13) Barnaul                41) Krasnoyarsk            69) Tashkent
14) Beirut                 42) Kuala_Lumpur           70) Tbilisi
15) Bishkek                43) Kuching                71) Tehran
16) Brunei                 44) Kuwait                 72) Thimphu
17) Chita                  45) Macau                  73) Tokyo
18) Choibalsan             46) Magadan                74) Tomsk
19) Colombo                47) Makassar               75) Ulaanbaatar
20) Damascus               48) Manila                 76) Urumqi
21) Dhaka                  49) Muscat                 77) Ust-Nera
22) Dili                   50) Nicosia                78) Vientiane
23) Dubai                  51) Novokuznetsk           79) Vladivostok
24) Dushanbe               52) Novosibirsk            80) Yakutsk
25) Famagusta              53) Omsk                   81) Yangon
26) Gaza                   54) Oral                   82) Yekaterinburg
27) Hebron                 55) Phnom_Penh             83) Yerevan
28) Ho_Chi_Minh            56) Pontianak

Please select the timezone. Use numbers or type names directly ['b' back to
region list, 'c' to continue, 'q' to quit, 'r' to refresh]: 37

Select your timezone, we have set ’37’ for Karachi.

Timezone has been set and we are at the main installation menu again.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Server with GUI)
5) [!] Installation Destination          6) [x] Kdump
       (No disks selected)                      (Kdump is enabled)
7) [ ] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 4

Now enter ‘4’ to choose Software selection.

Software selection

Base environment

1) [x] Server with GUI                  4) [ ] Workstation
2) [ ] Server                           5) [ ] Custom Operating System
3) [ ] Minimal Install                  6) [ ] Virtualization Host

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 3

Enter ‘3’ to choose Minimal Install option.

Software selection

Base environment

1) [ ] Server with GUI                  4) [ ] Workstation
2) [ ] Server                           5) [ ] Custom Operating System
3) [x] Minimal Install                  6) [ ] Virtualization Host

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

Enter ‘c’ to continue to next software selection menu.

Software selection

Add-ons for selected environment

1) [ ] Guest Agents                     8) [ ] Headless Management
2) [ ] Standard                         9) [ ] Network Servers
3) [ ] Legacy UNIX Compatibility        10) [ ] RPM Development Tools
4) [ ] Container Management             11) [ ] Scientific Support
5) [ ] Development Tools                12) [ ] Security Tools
6) [ ] .NET Core Development            13) [ ] Smart Card Support
7) [ ] Graphical Administration Tools   14) [ ] System Tools

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

Select optional add-ons here and enter ‘c’ to continue to the main menu.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [!] Installation source               4) [!] Software selection
       (Processing...)                          (Processing...)
5) [!] Installation Destination          6) [x] Kdump
       (No disks selected)                      (Kdump is enabled)
7) [ ] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: r

Setup is processing the settings, enter ‘r’ to refresh the menu.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Minimal Install)
5) [!] Installation Destination          6) [x] Kdump
       (No disks selected)                      (Kdump is enabled)
7) [ ] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 5

Enter ‘5’ to configure Installation Destination.

Installation Destination

1) [x] : 20 GiB (vda)

1 disk selected; 20 GiB capacity; 20 GiB free ...

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

We have only one disk and it is already selected as the Installation Destination.

Enter ‘c’ to continue to Partitioning Options.

Partitioning Options

1) [ ] Replace Existing Linux system(s)
2) [ ] Use All Space
3) [ ] Use Free Space
4) [ ] Manually assign mount points

Installation requires partitioning of your hard drive. Select what space to use
for the install target or manually assign mount points.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 2

Enter ‘2’ to choose Use All Space option.

Partitioning Options

1) [ ] Replace Existing Linux system(s)
2) [x] Use All Space
3) [ ] Use Free Space
4) [ ] Manually assign mount points

Installation requires partitioning of your hard drive. Select what space to use
for the install target or manually assign mount points.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

Enter ‘c’ to continue to Partition Scheme Options.

Partition Scheme Options

1) [ ] Standard Partition
2) [x] LVM
3) [ ] LVM Thin Provisioning

Select a partition scheme configuration.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c
Generating updated storage configuration
Checking storage configuration...

Go with the default option and enter ‘c’ to continue.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Minimal Install)
5) [x] Installation Destination          6) [x] Kdump
       (Automatic partitioning                  (Kdump is enabled)
       selected)
7) [ ] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 6

Disable kdump by selecting option ‘6’.

Kdump

1) [x] Enable kdump
2) Reserve amount (0 - 0 MB)
   auto

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 1

Enter ‘1’ to disable kdump.

Kdump

1) [ ] Enable kdump

Please make a selection from the above ['c' to continue, 'q' to quit, '
refresh]: c

Enter ‘c’ to continue to the main menu.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Minimal Install)
5) [x] Installation Destination          6) [x] Kdump
       (Automatic partitioning                  (Kdump is disabled)
       selected)
7) [ ] Network configuration             8) [!] Root password
       (Not connected)                          (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q'
'r' to refresh]: 7

Enter ‘7’ for Network configuration.

Network configuration

Wired (enp1s0) disconnected

Host Name: localhost.localdomain

Current host name: localhost

1) Set host name
2) Configure device enp1s0

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 1

Set hostname by selecting option ‘1’.

Enter a new value for 'Host Name' and press ENTER: kvm-guest-01.recipes.com

Provide the required hostname of your VM here.

Network configuration

Wired (enp1s0) disconnected

Host Name: kvm-guest-01.recipes.com

Current host name: localhost

1) Set host name
2) Configure device enp1s0

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 2

Now choose option ‘2’ to configure network interface.

Device configuration

1) IPv4 address or "dhcp" for DHCP
   dhcp
2) IPv4 netmask
3) IPv4 gateway
4) IPv6 address[/prefix] or "auto" for automatic, "dhcp" for DHCP, "ignore" to
   turn off
   auto
5) IPv6 default gateway
6) Nameservers (comma separated)
7) [ ] Connect automatically after reboot
8) [ ] Apply configuration in installer

Configuring device enp1s0.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 7

Choose option ‘7’ to autoconnect network connection.

Device configuration

1) IPv4 address or "dhcp" for DHCP
   dhcp
2) IPv4 netmask
3) IPv4 gateway
4) IPv6 address[/prefix] or "auto" for automatic, "dhcp" for DHCP, "ignore" to
   turn off
   auto
5) IPv6 default gateway
6) Nameservers (comma separated)
7) [x] Connect automatically after reboot
8) [ ] Apply configuration in installer

Configuring device enp1s0.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: 8

Choose option ‘8’ to apply changes.

Device configuration

1) IPv4 address or "dhcp" for DHCP
   dhcp
2) IPv4 netmask
3) IPv4 gateway
4) IPv6 address[/prefix] or "auto" for automatic, "dhcp" for DHCP, "ignore" to
   turn off
   auto
5) IPv6 default gateway
6) Nameservers (comma separated)
7) [x] Connect automatically after reboot
8) [x] Apply configuration in installer

Configuring device enp1s0.

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

Enter ‘c’ to continue to Network configuration menu.

Network configuration

Wired (enp1s0) disconnected

Host Name: kvm-guest-01.recipes.com

Current host name: localhost

1) Set host name
2) Configure device enp1s0

Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to
refresh]: c

Enter ‘c’ again to skip to main menu.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Minimal Install)
5) [x] Installation Destination          6) [x] Kdump
       (Automatic partitioning                  (Kdump is disabled)
       selected)
7) [x] Network configuration             8) [!] Root password
       (Wired (enp1s0) connected)               (Password is not set.)
9) [!] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: 8

Enter ‘8’ to set the root password .

Root password

Please select new root password. You will have to type it twice.

Password:
Password (confirm):

After setting a password, we are automatically skipped to main menu.

Installation

1) [x] Language settings                 2) [x] Time settings
       (English (United States))                (Asia/Karachi timezone)
3) [x] Installation source               4) [x] Software selection
       (Local media)                            (Minimal Install)
5) [x] Installation Destination          6) [x] Kdump
       (Automatic partitioning                  (Kdump is disabled)
       selected)
7) [x] Network configuration             8) [x] Root password
       (Wired (enp1s0) connected)               (Password is set.)
9) [ ] User creation
       (No user will be created)

Please make a selection from the above ['b' to begin installation, 'q' to quit,
'r' to refresh]: b

Press ‘b’ to begin installation.

Progress

.
Setting up the installation environment
.
Configuring storage
..
Creating disklabel on /dev/vda
Creating ext4 on /dev/vda1
Creating lvmpv on /dev/vda2
Creating swap on /dev/mapper/cl-swap
Creating xfs on /dev/mapper/cl-root
..
Running pre-installation scripts
.
Discovering realm to join
.
Running pre-installation tasks
......
Installing.
Starting package installation process
Downloading packages
Preparing transaction from installation source
Installing libgcc.x86_64 (1/390)
Installing geolite2-country.noarch (2/390)
Installing geolite2-city.noarch (3/390)
Installing tzdata.noarch (4/390)
Installing hwdata.noarch (5/390)
Installing xkeyboard-config.noarch (6/390)
Installing publicsuffix-list-dafsa.noarch (7/390)
Installing pkgconf-m4.noarch (8/390)
Installing ncurses-base.noarch (9/390)
Installing linux-firmware.noarch (10/390)
Installing libreport-filesystem.x86_64 (11/390)
Installing dnf-data.noarch (12/390)
Installing kbd-misc.noarch (13/390)
Installing kbd-legacy.noarch (14/390)
Installing firewalld-filesystem.noarch (15/390)
Installing dhcp-common.noarch (16/390)
Installing dbus-common.noarch (17/390)
Installing centos-release.x86_64 (18/390)
Installing setup.noarch (19/390)
Installing filesystem.x86_64 (20/390)
...
Installing iwl4965-firmware.noarch (382/390)
Installing iwl3945-firmware.noarch (383/390)
Installing iwl3160-firmware.noarch (384/390)
Installing iwl2030-firmware.noarch (385/390)
Installing iwl2000-firmware.noarch (386/390)
Installing iwl135-firmware.noarch (387/390)
Installing iwl105-firmware.noarch (388/390)
Installing iwl1000-firmware.noarch (389/390)
Installing iwl100-firmware.noarch (390/390)
Performing post-installation setup tasks
Configuring filesystem.x86_64
Configuring kernel-core.x86_64
Configuring authselect-libs.x86_64
Configuring sssd-common.x86_64
Configuring tuned.noarch
Configuring microcode_ctl.x86_64
...
Verifying python3-rhnlib.noarch (384/390)
Verifying python3-unbound.x86_64 (385/390)
Verifying qemu-guest-agent.x86_64 (386/390)
Verifying rhn-client-tools.x86_64 (387/390)
Verifying rsyslog.x86_64 (388/390)
Verifying unbound-libs.x86_64 (389/390)
Verifying xkeyboard-config.noarch (390/390)
.
Configuring storage
.
Installing boot loader
.
Performing post-installation setup tasks
.

Configuring installed system
..........
Writing network configuration
.
Creating users
....
Configuring addons
Executing org_fedora_oscap addon
Executing com_redhat_kdump addon
.
Generating initramfs
.
Running post-installation scripts
.
Storing configuration files and kickstarts
..
Installation complete. Press ENTER to quit:

Press <ENTER> to restart virtual machine.

CentOS Linux 8 (Core)
Kernel 4.18.0-80.el8.x86_64 on an x86_64

kvm-guest-01 login:

After restart it shows you the CentOS 8 login prompt.

Press Ctrl+] to exit from KVM guest.

We have successfully install KVM Guest in Text mode.

If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.

Final Thoughts

Installing a KVM guest in text mode can be a straightforward and efficient way to manage virtual machines on your Linux host. By following the steps outlined in this guide, you can quickly set up and configure a KVM guest, allowing you to leverage the full power of virtualization for your projects. Whether you’re setting up a development environment, testing software, or running multiple operating systems, KVM provides the flexibility and performance you need.

If you need further assistance or personalized support with your KVM Hypervisor setup, feel free to reach out to me on Fiverr: Linux Admin. I’m here to help with all your virtualization needs.

Leave a Comment