Fedora 26
Sponsored Link

Management Tools2017/07/18

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

total 28
dr-xr-x---.  4 root root  161 Jul 20 02:42 .
dr-xr-xr-x. 17 root root  224 Jul 20 01:15 ..
-rw-------.  1 root root  105 Jul 20 02:42 .bash_history
-rw-r--r--.  1 root root   18 Feb 11 22:28 .bash_logout
-rw-r--r--.  1 root root  176 Feb 11 22:28 .bash_profile
-rw-r--r--.  1 root root  176 Feb 11 22:28 .bashrc
...
[3] [cat] a file in a virtual machine.
[root@dlp ~]#
virt-cat -d fedora26 /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
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
...
[4] Edit a file in a virtual machine.
[root@dlp ~]#
virt-edit -d fedora26 /etc/fstab


#
# /etc/fstab
# Created by anaconda on Thu Jul 20 01:14:46 2017
#
# 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=668263cf-6a60-4bc3-8dc5-08e1e7fcd95d /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 fedora26

Filesystem                           1K-blocks       Used  Available  Use%
fedora26:/dev/sda1                      999320     155752     774756   16%
fedora26:/dev/fedora/root             15718400    6156132    9562268   40%
[6] Mount a disk for a virtual machine.
[root@dlp ~]#
guestmount -d fedora26 -i /media

[root@dlp ~]#
ll /media

total 20
lrwxrwxrwx.  1 root root    7 Feb  4  2016 bin -> usr/bin
dr-xr-xr-x.  4 root root 4096 Dec  9 10:10 boot
drwxr-xr-x.  2 root root    6 Dec  9 10:01 dev
drwxr-xr-x. 90 root root 8192 Dec  9 10:15 etc
drwxr-xr-x.  3 root root   20 Dec  9 10:13 home
...
[7] Display the status of virtual machines.
[root@dlp ~]#
virt-top

virt-top 10:24:32 - x86_64 6/6CPU 2593MHz 7983MB
2 domains, 1 active, 1 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 500 MB (500 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    -                                           (Windows10)
    -                                           (fedora26)
    -                                           (template)
Matched Content