Fedora 39
Sponsored Link

KVM : Install VM Management Tools2023/11/15

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

total 28
dr-xr-x---.  3 root root 147 Nov 14 00:14 .
dr-xr-xr-x. 18 root root 235 Nov 14 00:07 ..
-rw-------.  1 root root  16 Nov 14 00:14 .bash_history
-rw-r--r--.  1 root root  18 Jul 21 00:00 .bash_logout
-rw-r--r--.  1 root root 141 Jul 21 00:00 .bash_profile
-rw-r--r--.  1 root root 429 Jul 21 00:00 .bashrc
-rw-r--r--.  1 root root 100 Jul 21 00:00 .cshrc
drwx------.  2 root root   6 Nov 14 00:07 .ssh
-rw-r--r--.  1 root root 129 Jul 21 00:00 .tcshrc
-rw-------.  1 root root 865 Nov 14 00:11 anaconda-ks.cfg
[3] [cat] a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora39 /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 fedora39 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Tue Nov 14 00:07:21 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.
#
UUID=c55317bd-79de-45ad-b58e-1842a027877c /                       xfs     defaults        0 0
UUID=2928b52e-b869-4de8-982d-645fe089cc46 /boot                   xfs     defaults        0 0
[5] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora39

Filesystem                           1K-blocks       Used  Available  Use%
fedora39:/dev/sda2                      983040     235356     747684   24%
fedora39:/dev/fedora/root             15663104    1437976   14225128   10%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora39 -i /media

[root@dlp ~]#
ll /media

total 20
dr-xr-xr-x.   2 root root    6 Jul 21 09:00 afs
lrwxrwxrwx.   1 root root    7 Jul 21 09:00 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Nov 14 09:10 boot
drwxr-xr-x.   2 root root    6 Nov 14 09:07 dev
drwxr-xr-x. 105 root root 8192 Nov 14 09:12 etc
drwxr-xr-x.   3 root root   20 Nov 14 09:10 home
.....
.....
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 09:11:45 - x86_64 8/8CPU 2399MHz 15976MB
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
    -                                           (fedora39)
    -                                           (win2k22)
.....
.....
Matched Content