KVM : Management tools for VM2026/04/29 |
|
Install useful tools for virtual machine management. |
|
| [1] | Install required packages. |
|
root@dlp:~# apt -y install libguestfs-tools virt-top
|
| [2] | [ls] a directory in a virtual machine. |
|
root@dlp:~# virt-ls -l -d ubuntu2604 /root total 20 drwx------ 3 0 0 4096 Apr 20 18:08 . drwxr-xr-x 20 0 0 4096 Apr 28 09:44 .. -rw-r--r-- 1 0 0 3106 Apr 20 08:46 .bashrc -rw-r--r-- 1 0 0 132 Apr 20 08:46 .profile drwx------ 2 0 0 4096 Apr 28 09:48 .ssh |
| [3] | [cat] a file in a virtual machine. |
|
root@dlp:~# virt-cat -d ubuntu2604 /etc/passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin ..... ..... |
| [4] | Edit a file in a virtual machine. |
|
root@dlp:~# virt-edit -d ubuntu2604 /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation /dev/disk/by-id/dm-uuid-LVM-Bhyx9KRrxaul7YcYvev2V0hWCjGeYF21GMNjwI25PhxaTpfp6J2usSsaw1CMqfnx / ext4 defaults 0 1 # /boot was on /dev/vda2 during curtin installation /dev/disk/by-uuid/98ad9249-a83e-4d76-8d56-4c9aa7bb2979 /boot ext4 defaults 0 1 |
| [5] | Display disk usage in a virtual machine. |
|
root@dlp:~# virt-df -d ubuntu2604 Filesystem 1K-blocks Used Available Use% ubuntu2604:/dev/sda2 1790136 100184 1580692 6% ubuntu2604:/dev/ubuntu-vg/ubuntu-lv 10218772 2926336 6751764 29% |
| [6] | Mount disk image of a virtual machine. |
|
root@dlp:~# guestmount -d ubuntu2604 -i /mnt root@dlp:~# ll /mnt total 92 drwxr-xr-x 20 root root 4096 Apr 28 09:44 ./ drwxr-xr-x 20 root root 4096 Apr 25 05:21 ../ lrwxrwxrwx 1 root root 7 Apr 20 08:46 bin@ -> usr/bin drwxr-xr-x 4 root root 4096 Apr 28 09:47 boot/ dr-xr-xr-x 2 root root 4096 Apr 20 18:23 cdrom/ drwxr-xr-x 5 root root 4096 Apr 20 18:07 dev/ drwxr-xr-x 110 root root 4096 Apr 28 09:48 etc/ drwxr-xr-x 3 root root 4096 Apr 28 09:46 home/ ..... ..... |
| [7] | Display the status of virtual machines. |
|
root@dlp:~# virt-top
virt-top 10:26:58 - x86_64 8/8CPU 2399MHz 15473MB
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
- (ubuntu2604)
- (win2k25)
|
| Sponsored Link |
|
|