Fedora 23
Sponsored Link

Management Tools2015/11/10

 
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 fedora23 /root

total 28
dr-xr-x---.  2 root root  135 Nov  9 14:05 .
dr-xr-xr-x. 17 root root  224 Nov  9 13:59 ..
-rw-------.  1 root root   16 Nov  9 14:05 .bash_history
-rw-r--r--.  1 root root   18 Jun 18 22:37 .bash_logout
-rw-r--r--.  1 root root  176 Jun 18 22:37 .bash_profile
-rw-r--r--.  1 root root  176 Jun 18 22:37 .bashrc
...
[3] "cat" a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora23 /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 fedora23 /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 fedora23

Filesystem                   1K-blocks       Used  Available  Use%
fedora23:/dev/sda1              487652      98064     359892   21%
fedora23:/dev/fedora/root     27781884    1158528   26623356    5%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora23 -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
    -                                           (fedora23)
    -                                           (template)
Matched Content