KVM : 仮想管理ツール インストール2025/04/25 |
仮想マシンを管理できるツール群をインストールしておくと、仮想管理がより容易になります。 |
|
[1] | 仮想管理ツールをインストールします。 |
[root@dlp ~]# dnf -y install guestfs-tools virt-top
|
[2] | 仮想マシン内のあるディレクトリを [ls] する。 |
# 仮想マシン [fedora42] の [/root] を [ls -l] する [root@dlp ~]# virt-ls -l -d fedora42 /root total 28 dr-xr-x---. 4 root root 161 Apr 25 02:07 . dr-xr-xr-x. 18 root root 235 Apr 25 01:26 .. -rw-------. 1 root root 132 Apr 25 03:43 .bash_history -rw-r--r--. 1 root root 18 Jan 18 00:00 .bash_logout -rw-r--r--. 1 root root 141 Jan 18 00:00 .bash_profile -rw-r--r--. 1 root root 429 Jan 18 00:00 .bashrc drwx------. 2 root root 6 Apr 25 02:07 .cache -rw-r--r--. 1 root root 100 Jan 18 00:00 .cshrc drwx------. 2 root root 6 Apr 25 01:26 .ssh -rw-r--r--. 1 root root 129 Jan 18 00:00 .tcshrc -rw-------. 1 root root 838 Apr 25 01:30 anaconda-ks.cfg |
[3] | 仮想マシン内のあるファイルを [cat] する。 |
# 仮想マシン [fedora42] の [/etc/passwd] を表示する [root@dlp ~]# virt-cat -d fedora42 /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] | 仮想マシン内のあるファイルを編集する。 |
# 仮想マシン [fedora42] の [/etc/fstab] を編集する [root@dlp ~]# virt-edit -d fedora42 /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=522f6224-edad-4c56-be6b-6a4b78869ef2 / xfs defaults 0 0 UUID=b9622347-ac1a-4220-89f3-27931876fd91 /boot xfs defaults 0 0 |
[5] | 仮想マシン内のディスク使用量を表示する。 |
# 仮想マシン [fedora42] のディスク使用量を表示する [root@dlp ~]# virt-df -d fedora42 Filesystem 1K-blocks Used Available Use% fedora42:/dev/sda2 983040 227304 755736 24% fedora42:/dev/fedora/root 15663104 7050436 8612668 46% |
[6] | 仮想マシンのディスクをマウントする。 |
# 仮想マシン [fedora42] のディスクを [/media] にマウントする [root@dlp ~]# guestmount -d fedora42 -i /media [root@dlp ~]# ll /media total 20 dr-xr-xr-x. 2 root root 6 Jan 16 09:00 afs lrwxrwxrwx. 1 root root 7 Jan 16 09:00 bin -> usr/bin dr-xr-xr-x. 5 root root 4096 Apr 25 10:30 boot drwxr-xr-x. 2 root root 6 Apr 25 10:26 dev drwxr-xr-x. 155 root root 8192 Apr 25 12:31 etc drwxr-xr-x. 3 root root 20 Apr 25 10:30 home ..... ..... |
[7] | 仮想マシンの状態を表示する。 |
[root@dlp ~]# virt-top virt-top 12:51:44 - x86_64 8/8CPU 2399MHz 15979MB 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 - (fedora42) - (win2k25) ..... ..... |
Sponsored Link |
|