KVM : Install VM Management Tools2024/11/05 |
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 fedora41 /root total 28 dr-xr-x---. 3 root root 147 Nov 5 00:19 . dr-xr-xr-x. 18 root root 235 Nov 5 00:12 .. -rw-------. 1 root root 269 Nov 5 00:19 .bash_history -rw-r--r--. 1 root root 18 Jul 19 00:00 .bash_logout -rw-r--r--. 1 root root 141 Jul 19 00:00 .bash_profile -rw-r--r--. 1 root root 429 Jul 19 00:00 .bashrc -rw-r--r--. 1 root root 100 Jul 19 00:00 .cshrc drwx------. 2 root root 6 Nov 5 00:12 .ssh -rw-r--r--. 1 root root 129 Jul 19 00:00 .tcshrc -rw-------. 1 root root 835 Nov 5 00:15 anaconda-ks.cfg |
[3] | [cat] a file in a virtual machine. |
[root@dlp ~]# virt-cat -d fedora41 /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 operator:x:11:0:operator:/root:/usr/sbin/nologin games:x:12:100:games:/usr/games:/usr/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/usr/sbin/nologin ..... ..... |
[4] | Edit a file in a virtual machine. |
[root@dlp ~]# virt-edit -d fedora41 /etc/fstab # # /etc/fstab # Created by anaconda on Tue Nov 5 00:12:10 2024 # # 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=c9a46f5f-3181-4154-8c3d-a44b79951a0c / xfs defaults 0 0 UUID=a1a021fb-c8c2-4281-8dc4-5ae1aa9266a7 /boot xfs defaults 0 0 |
[5] | Display disk usage in a virtual machine. |
[root@dlp ~]# virt-df -d fedora41 Filesystem 1K-blocks Used Available Use% fedora41:/dev/sda2 983040 217748 765292 23% fedora41:/dev/fedora/root 15663104 1649800 14013304 11% |
[6] | Mount a disk for a virtual machine. |
[root@dlp ~]# guestmount -d fedora41 -i /media [root@dlp ~]# ll /media total 20 dr-xr-xr-x. 2 root root 6 Jul 17 09:00 afs lrwxrwxrwx. 1 root root 7 Jul 17 09:00 bin -> usr/bin dr-xr-xr-x. 5 root root 4096 Nov 5 09:14 boot drwxr-xr-x. 2 root root 6 Nov 5 09:12 dev drwxr-xr-x. 107 root root 8192 Nov 5 09:19 etc drwxr-xr-x. 3 root root 20 Nov 5 09:15 home ..... ..... |
[7] | Display the status of virtual machines. |
[root@dlp ~]# virt-top virt-top 10:22:50 - x86_64 8/8CPU 2400MHz 15981MB 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 - (fedora41) - (win2k25) ..... ..... |
Sponsored Link |
|