KVM : Install VM Management Tools2024/05/09 |
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 fedora40 /root total 32 dr-xr-x---. 3 root root 163 May 9 04:51 . dr-xr-xr-x. 18 root root 235 May 9 04:42 .. -rw-------. 1 root root 191 May 9 04:51 .bash_history -rw-r--r--. 1 root root 18 Jan 26 00:00 .bash_logout -rw-r--r--. 1 root root 141 Jan 26 00:00 .bash_profile -rw-r--r--. 1 root root 429 Jan 26 00:00 .bashrc -rw-r--r--. 1 root root 100 Jan 26 00:00 .cshrc -rw-------. 1 root root 20 May 9 04:50 .lesshst drwx------. 2 root root 6 May 9 04:43 .ssh -rw-r--r--. 1 root root 129 Jan 26 00:00 .tcshrc -rw-------. 1 root root 903 May 9 04:46 anaconda-ks.cfg |
[3] | [cat] a file in a virtual machine. |
[root@dlp ~]# virt-cat -d fedora40 /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 ..... ..... |
[4] | Edit a file in a virtual machine. |
[root@dlp ~]# virt-edit -d fedora40 /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=61c79c7e-7c97-419d-9354-1d1d5ae9a825 / xfs defaults 0 0 UUID=2f6bd45e-26f3-4b5b-bc34-5d9e7859d72a /boot xfs defaults 0 0 |
[5] | Display disk usage in a virtual machine. |
[root@dlp ~]# virt-df -d fedora40 Filesystem 1K-blocks Used Available Use% fedora40:/dev/sda2 983040 239952 743088 25% fedora40:/dev/fedora/root 15663104 1611960 14051144 11% |
[6] | Mount a disk for a virtual machine. |
[root@dlp ~]# guestmount -d fedora40 -i /media [root@dlp ~]# ll /media total 20 dr-xr-xr-x. 2 root root 6 Jan 24 09:00 afs lrwxrwxrwx. 1 root root 7 Jan 24 09:00 bin -> usr/bin dr-xr-xr-x. 5 root root 4096 May 9 13:45 boot drwxr-xr-x. 2 root root 6 May 9 13:42 dev drwxr-xr-x. 107 root root 8192 May 9 13:50 etc drwxr-xr-x. 3 root root 20 May 9 13:46 home ..... ..... |
[7] | Display the status of virtual machines. |
[root@dlp ~]# virt-top virt-top 14:41:51 - x86_64 8/8CPU 2399MHz 15985MB 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 - (fedora40) - (win2k22) ..... ..... |
Sponsored Link |
|