KVM : Management tools for VM2024/05/10 |
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 ubuntu2404 /root total 20 drwx------ 3 0 0 4096 Apr 23 09:40 . drwxr-xr-x 23 0 0 4096 May 9 08:14 .. -rw-r--r-- 1 0 0 3106 Apr 22 13:04 .bashrc -rw-r--r-- 1 0 0 161 Apr 22 13:04 .profile drwx------ 2 0 0 4096 May 9 08:15 .ssh |
[3] | [cat] a file in a virtual machine. |
root@dlp:~# virt-cat -d ubuntu2404 /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 ..... ..... |
[4] | Edit a file in a virtual machine. |
root@dlp:~# virt-edit -d ubuntu2404 /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-7Fj9ZetVJwmcbgOg03MrGWILfigbFA4ep9MvgTA98qonXLhXq8cdDCGmv1G4Aax5 / ext4 defaults 0 1 # /boot was on /dev/vda2 during curtin installation /dev/disk/by-uuid/31e23499-50dc-42f1-a847-5c27811e2c66 /boot ext4 defaults 0 1 /swap.img none swap sw 0 0 |
[5] | Display disk usage in a virtual machine. |
root@dlp:~# virt-df -d ubuntu2404 Filesystem 1K-blocks Used Available Use% ubuntu2404:/dev/sda2 1790136 96540 1584336 6% ubuntu2404:/dev/ubuntu-vg/ubuntu-lv 10218772 4314904 5363196 43% |
[6] | Mount disk image of a virtual machine. |
root@dlp:~# guestmount -d ubuntu2404 -i /mnt root@dlp:~# ll /mnt total 2020460 drwxr-xr-x 23 root root 4096 May 9 08:14 ./ drwxr-xr-x 23 root root 4096 May 3 05:38 ../ lrwxrwxrwx 1 root root 7 Apr 22 13:08 bin -> usr/bin/ drwxr-xr-x 2 root root 4096 Feb 26 12:58 bin.usr-is-merged/ drwxr-xr-x 4 root root 4096 May 9 08:14 boot/ dr-xr-xr-x 2 root root 4096 Apr 23 12:45 cdrom/ drwxr-xr-x 4 root root 4096 Apr 23 09:40 dev/ drwxr-xr-x 108 root root 4096 May 9 08:17 etc/ drwxr-xr-x 3 root root 4096 May 9 08:15 home/ ..... ..... |
[7] | Display the status of virtual machines. |
root@dlp:~# virt-top virt-top 00:06:27 - x86_64 8/8CPU 2399MHz 15991MB 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 - (ubuntu2404) - (win2k22) |
Sponsored Link |