Fedora 38
Sponsored Link

KVM : Install VM Management Tools2023/04/26

 
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 fedora38 /root

total 28
dr-xr-x---.  3 root root 147 Apr 25 23:59 .
dr-xr-xr-x. 18 root root 235 Apr 25 23:54 ..
-rw-------.  1 root root 100 Apr 25 23:59 .bash_history
-rw-r--r--.  1 root root  18 Jan 20 00:00 .bash_logout
-rw-r--r--.  1 root root 141 Jan 20 00:00 .bash_profile
-rw-r--r--.  1 root root 429 Jan 20 00:00 .bashrc
-rw-r--r--.  1 root root 100 Jan 20 00:00 .cshrc
drwx------.  2 root root   6 Apr 25 23:54 .ssh
-rw-r--r--.  1 root root 129 Jan 20 00:00 .tcshrc
-rw-------.  1 root root 901 Apr 25 23:57 anaconda-ks.cfg
[3] [cat] a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora38 /etc/passwd

root:x:0:0:Super User:/root:/bin/bash
bin:x:1:1:bin:/bin:/usr/sbin/nologin
daemon:x:2:2:daemon:/sbin:/usr/sbin/nologin
adm:x:3:4:adm:/var/adm:/usr/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/usr/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:/usr/sbin/nologin
.....
.....
[4] Edit a file in a virtual machine.
[root@dlp ~]#
virt-edit -d fedora38 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Tue Apr 25 23:53:43 2023
#
# 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=0cf11271-6767-4653-bd60-8fac9daa01a3 /boot xfs     defaults        0 0
[5] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora38

Filesystem                           1K-blocks       Used  Available  Use%
fedora38:/dev/sda2                      983040     190732     792308   20%
fedora38:/dev/fedora/root             15663104    1326256   14336848    9%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora38 -i /media

[root@dlp ~]#
ll /media

total 20
dr-xr-xr-x.   2 root root    6 Jan 19 09:00 afs
lrwxrwxrwx.   1 root root    7 Jan 19 09:00 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Apr 26 08:56 boot
drwxr-xr-x.   2 root root    6 Apr 26 08:53 dev
drwxr-xr-x. 104 root root 8192 Apr 26 08:58 etc
.....
.....
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 09:35:04 - x86_64 4/4CPU 2399MHz 7925MB
2 domains, 1 active, 1 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 6144 MB (6144 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    2 R                      0.0  0.0   8:40.37 win2k22
    -                                           (fedora38)
.....
.....
Matched Content