Fedora 21
Sponsored Link

Virt-Tools
2014/12/25
 
Install useful tools for virt management.
[1] Install some tools.
[root@dlp ~]#
yum -y install libguestfs-tools virt-top
[2] "ls" a directory in a virtual machine.
[root@dlp ~]#
virt-ls -l -d fedora21 /root

total 40
dr-xr-x---.  3 root root 4096 Dec 25 11:46 .
dr-xr-xr-x. 18 root root 4096 Dec 25 11:55 ..
-rw-------.  1 root root  126 Dec 25 11:46 .bash_history
-rw-r--r--.  1 root root   18 Jun  8  2014 .bash_logout
-rw-r--r--.  1 root root  176 Jun  8  2014 .bash_profile
-rw-r--r--.  1 root root  176 Jun  8  2014 .bashrc
-rw-r--r--.  1 root root  100 Jun  8  2014 .cshrc
...
[3] "cat" a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora21 /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 fedora21 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Thu Dec 25 11:30:32 2014
#
# 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--server-root /                       ext4    defaults        1 1
UUID=fb39d12e-e1f0-4114-a2fd-76eadc99ccdb /boot         ext4    defaults        1 2
/dev/mapper/fedora--server-swap swap                    swap    defaults        0 0
[5] Display disk usage in a virtual machine.
[root@dlp ~]#
virt-df -d fedora21

Filesystem                           1K-blocks       Used  Available  Use%
fedora21:/dev/sda1                      487652      91879     366077   19%
fedora21:/dev/fedora-server/root      27187420    1268684   24514628    5%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora21 -i /media

[root@dlp ~]#
ll /media

total 82
lrwxrwxrwx.   1 root root     7 Aug 16 22:24 bin -> usr/bin
dr-xr-xr-x.   4 root root  1024 Dec 25 20:40 boot
drwxr-xr-x.   2 root root  4096 Dec 25 20:30 dev
drwxr-xr-x. 103 root root 12288 Dec 25 20:55 etc
...
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 22:12:33 - x86_64 4/4CPU 2801MHz 12135MB
3 domains, 1 active, 1 running, 0 sleeping, 0 paused, 2 inactive D:0 O:0 X:0
CPU: 42.2%  Mem: 4096 MB (4096 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    9 R   92  220    0    0 42.2 33.0   6:59.26 win2k12
    -                                           (fedora21)
    -                                           (template)
Matched Content