Fedora 24
Sponsored Link

Management Tools
2016/06/26
 
Install useful tools for virtual machine management.
[1] Install required packages.
[root@dlp ~]#
dnf -y install libguestfs-tools virt-top
[2] "ls" a directory in a virtual machine.
[root@dlp ~]#
virt-ls -l -d fedora24 /root

total 28
dr-xr-x---.  2 root root  135 Jun 27 11:50 .
dr-xr-xr-x. 17 root root  224 Jun 27 11:45 ..
-rw-------.  1 root root   16 Jun 27 11:50 .bash_history
-rw-r--r--.  1 root root   18 Feb  5 04:36 .bash_logout
-rw-r--r--.  1 root root  176 Feb  5 04:36 .bash_profile
-rw-r--r--.  1 root root  176 Feb  5 04:36 .bashrc
...
[3] "cat" a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora24 /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
...
[4] Edit a file in a virtual machine.
[root@dlp ~]#
virt-edit -d fedora24 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Mon Jun 27 11:39:31 2016
#
# 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
#
/dev/mapper/fedora-root /                       xfs     defaults        0 0
UUID=0f127a22-ff3a-4047-b0d8-3a6fb8796fa8 /boot ext4    defaults        1 2
/dev/mapper/fedora-swap swap                    swap    defaults        0 0
[5] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora24

Filesystem                           1K-blocks       Used  Available  Use%
fedora24:/dev/sda1                      487652     101612     356344   21%
fedora24:/dev/fedora/root             15718400     956520   14761880    7%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora24 -i /media

[root@dlp ~]#
ll /media

total 18
lrwxrwxrwx.  1 root root    7 Feb  4 07:10 bin -> usr/bin
dr-xr-xr-x.  4 root root 1024 Jun 27 20:44 boot
drwxr-xr-x.  2 root root    6 Jun 27 20:39 dev
drwxr-xr-x. 91 root root 8192 Jun 27 20:47 etc
...
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 21:58:22 - x86_64 6/6CPU 2801MHz 12124MB
3 domains, 0 active, 0 running, 0 sleeping, 0 paused, 3 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
    -                                           (Windows10)
    -                                           (fedora24)
    -                                           (template)
Matched Content