Fedora 30
Sponsored Link

KVM : Install Management Tools2019/05/09

 
Install useful tools for virtual machine management.
[1] Install required packages.
[root@dlp ~]#
dnf -y install libguestfs-tools virt-top
[2] Create a Virtual machine image.
# display available OS template

[root@dlp ~]#
virt-builder -l

.....
.....
fedora-30                aarch64    Fedora® 30 Server (aarch64)
fedora-30                i686       Fedora® 30 Server (i686)
fedora-30                x86_64     Fedora® 30 Server
freebsd-11.1             x86_64     FreeBSD 11.1
ubuntu-10.04             x86_64     Ubuntu 10.04 (Lucid)
ubuntu-12.04             x86_64     Ubuntu 12.04 (Precise)
ubuntu-14.04             x86_64     Ubuntu 14.04 (Trusty)
ubuntu-16.04             x86_64     Ubuntu 16.04 (Xenial)
ubuntu-18.04             x86_64     Ubuntu 18.04 (bionic)

# create an image of Fedora 30

[root@dlp ~]#
virt-builder fedora-30 --format qcow2 --size 10G -o fedora30.qcow2 --root-password password

[   3.9] Downloading: http://builder.libguestfs.org/fedora-30.xz
[  77.1] Planning how to build this image
[  77.1] Uncompressing
.....
.....
                   Output file: fedora30.qcow2
                   Output size: 10.0G
                 Output format: qcow2
            Total usable space: 9.3G
                    Free space: 8.2G (87%)

# to configure VM with the image above, run virt-install

[root@dlp ~]#
virt-install \
--name fedora-30 \
--ram 4096 \
--disk path=/var/kvm/images/fedora30.qcow2 \
--vcpus 2 \
--os-type linux \
--os-variant fedora29 \
--network bridge=br0 \
--graphics none \
--serial pty \
--console pty \
--boot hd \
--import
[3] [ls] a directory in a virtual machine.
[root@dlp ~]#
virt-ls -l -d fedora30 /root

total 28
dr-xr-x---.  2 root root  135 Nov  3 08:17 .
dr-xr-xr-x. 17 root root  224 Nov  3 08:03 ..
-rw-------.  1 root root   16 Nov  3 08:17 .bash_history
-rw-r--r--.  1 root root   18 Jul 15 07:02 .bash_logout
-rw-r--r--.  1 root root  176 Jul 15 07:02 .bash_profile
-rw-r--r--.  1 root root  176 Jul 15 07:02 .bashrc
-rw-r--r--.  1 root root  100 Jul 15 07:02 .cshrc
-rw-r--r--.  1 root root  129 Jul 15 07:02 .tcshrc
-rw-------.  1 root root 1399 Nov  3 08:13 anaconda-ks.cfg
.....
[4] [cat] a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora30 /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
.....
[5] Edit a file in a virtual machine.
[root@dlp ~]#
virt-edit -d fedora30 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Thu Dec 21 02:42:14 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/fedora-root /                       xfs     defaults        0 0
UUID=3efa9577-8c2c-45d3-8718-4ab4651392db /boot ext4    defaults        1 2
/dev/mapper/fedora-swap swap                    swap    defaults        0 0
[6] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora30

Filesystem                           1K-blocks       Used  Available  Use%
fedora30:/dev/sda1                      999320     128044     802464   13%
fedora30:/dev/fedora/root             15718400    1426412   14291988   10%
[7] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora30 -i /media

[root@dlp ~]#
ll /media

total 20
lrwxrwxrwx.  1 root root    7 Aug  3 08:32 bin -> usr/bin
dr-xr-xr-x.  6 root root 4096 Dec 21 11:49 boot
drwxr-xr-x.  2 root root    6 Dec 21 11:42 dev
drwxr-xr-x. 93 root root 8192 Dec 21 11:57 etc
drwxr-xr-x.  3 root root   20 Dec 21 11:51 home
...
[8] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 10:24:32 - x86_64 6/6CPU 2593MHz 7983MB
2 domains, 1 active, 1 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 500 MB (500 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    -                                           (Win2k19)
    -                                           (fedora30)
Matched Content