Debian 9 Stretch
Sponsored Link

Management tools2017/06/22

 
Install useful tools for virtual machine management.
[1] Install management tools.
root@dlp:~#
apt -y install libguestfs-tools virt-top
[2] "ls" a directory in a virtual machine.
root@dlp:~#
virt-ls -l -d debian /root

total 20
drwx------  2 0 0 4096 Jun 23 00:22 .
drwxr-xr-x 22 0 0 4096 Jun 22 12:40 ..
-rw-------  1 0 0   16 Jun 23 00:22 .bash_history
-rw-r--r--  1 0 0  570 Jan 31  2010 .bashrc
-rw-r--r--  1 0 0  148 Aug 17  2015 .profile
[3] "cat" a file in a virtual machine.
root@dlp:~#
virt-cat -d debian /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
...
...
[4] Edit a file in a virtual machine.
root@dlp:~#
virt-edit -d debian /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>
/dev/mapper/debian--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/vda1 during installation
UUID=dc739636-cfd3-40d5-8f9e-69b7d1bc3d67 /boot           ext2    defaults
  0       2
/dev/mapper/debian--vg-swap_1 none            swap    sw              0       0
[5] Display disk usage in a virtual machine.
root@dlp:~#
virt-df -d debian

Filesystem                           1K-blocks       Used  Available  Use%
template:/dev/sda1                      240972      37022     191509   16%
template:/dev/debian-vg/root          26453796     925232   24161732    4%
[6] Mount a disk of a virtual machine
root@dlp:~#
guestmount -d debian -i /mnt

root@dlp:~#
ll /mnt

total 89
drwxr-xr-x  2 root root  4096 Jun 22 22:58 bin
drwxr-xr-x  4 root root  1024 Jun 22 22:59 boot
drwxr-xr-x  4 root root  4096 Jun 22 21:35 dev
drwxr-xr-x 76 root root  4096 Jun 23 09:22 etc
drwxr-xr-x  3 root root  4096 Jun 22 22:59 home
.....
.....
[7] Display the status of virtual machines.
root@dlp:~#
virt-top

virt-top 21:58:43 - x86_64 4/4CPU 2801MHz 12158MB
3 domains, 1 active, 1 running, 0 sleeping, 0 paused, 2 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 4096 MB (4096 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    6 R                      0.0  0.0   0:04.92 debian
    -                                           (template)
    -                                           (win2k12R2)
Matched Content