Fedora 37
Sponsored Link

KVM : Install VM Management Tools
2022/11/22
 
Install useful tools for virtual machine management.
[1] Install required packages.
[root@dlp ~]#
dnf -y install guestfs-tools virt-top
[2] [ls] a directory in a virtual machine.
[root@dlp ~]#
virt-ls -l -d fedora37 /root

total 28
dr-xr-x---.  2 root root 135 Nov 21 06:51 .
dr-xr-xr-x. 18 root root 235 Nov 21 06:45 ..
-rw-------.  1 root root  16 Nov 21 06:51 .bash_history
-rw-r--r--.  1 root root  18 Jul 23 01:15 .bash_logout
-rw-r--r--.  1 root root 141 Jul 23 01:15 .bash_profile
-rw-r--r--.  1 root root 429 Jul 23 01:15 .bashrc
-rw-r--r--.  1 root root 100 Jul 23 01:15 .cshrc
-rw-r--r--.  1 root root 129 Jul 23 01:15 .tcshrc
-rw-------.  1 root root 887 Nov 21 06:48 anaconda-ks.cfg
[3] cat] a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora37 /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
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
.....
.....
[4] Edit a file in a virtual machine.
[root@dlp ~]#
virt-edit -d fedora37 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Mon Nov 21 06:44:58 2022
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/fedora-root /                       xfs     defaults        0 0
UUID=9659f2e4-0d20-42fd-a3cf-b6882e2a72e5 /boot xfs     defaults        0 0
[5] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora37

Filesystem                           1K-blocks       Used  Available  Use%
fedora37:/dev/sda2                      983040     179712     803328   19%
fedora37:/dev/fedora/root             15663104    1365096   14298008    9%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora37 -i /media

[root@dlp ~]#
ll /media

total 20
dr-xr-xr-x.   2 root root    6 Aug  9 22:27 afs
lrwxrwxrwx.   1 root root    7 Aug  9 22:27 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Nov 21 15:47 boot
drwxr-xr-x.   2 root root    6 Nov 21 15:44 dev
drwxr-xr-x. 102 root root 8192 Nov 21 15:49 etc
.....
.....
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 16:40:07 - x86_64 4/4CPU 2399MHz 7941MB
2 domains, 0 active, 0 running, 0 sleeping, 0 paused, 2 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 0 MB (0 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    -                                           (fedora37)
    -                                           (win2k22)
.....
.....
Matched Content