SLES 12
Sponsored Link

Management Tools2015/11/22

 
Install useful tools for virtual machine management.
[1] Install required packages.
dlp:~ #
zypper -n install guestfs-tools libguestfs0 virt-top
[2] "ls" a directory in a virtual machine.
dlp:~ #
virt-ls -l -d sles12 /root

total 32
drwx------ 1 root root    96 Nov 22 14:18 .
drwxr-xr-x 1 root root   156 Nov 22 14:09 ..
-rw------- 1 root root    28 Nov 22 14:20 .bash_history
drwx------ 1 root root    90 Nov 22 14:14 .gnupg
drwxr-xr-x 1 root root    10 Nov 22 14:18 .local
-rw-r--r-- 1 root root 28098 Nov 22 14:16 autoinst.xml
drwxr-xr-x 1 root root     0 Sep 21  2014 bin
drwxr-xr-x 1 root root    36 Nov 22 14:04 inst-sys
...
[3] "cat" a file in a virtual machine.
dlp:~ #
virt-cat -d sles12 /etc/passwd

at:x:25:25:Batch jobs daemon:/var/spool/atjobs:/bin/bash
bin:x:1:1:bin:/bin:/bin/bash
daemon:x:2:2:Daemon:/sbin:/bin/bash
ftp:x:40:49:FTP account:/srv/ftp:/bin/bash
ftpsecure:x:489:65534:Secure FTP User:/var/lib/empty:/bin/false
...
[4] Edit a file in a virtual machine.
dlp:~ #
virt-edit -d sles12 /etc/fstab


UUID=57347ebf-bc40-4490-85be-f91ca6cce3a4 swap swap defaults 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 / btrfs defaults 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 /boot/grub2/i386-pc btrfs subvol=@/boot/grub2/i386-pc 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 /boot/grub2/x86_64-efi btrfs subvol=@/boot/grub2/x86_64-efi 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 /opt btrfs subvol=@/opt 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 /srv btrfs subvol=@/srv 0 0
UUID=e9c233a4-50f7-498d-a996-1ff05a2e3512 /tmp btrfs subvol=@/tmp 0 0
.....
.....
[5] Display disk usage in a virtual machine.
dlp:~ #
virt-df -d sles12

Filesystem                           1K-blocks       Used  Available  Use%
sles12:btrfsvol:/dev/sda2/@/boot/grub2/i386-pc
                                      12587008    3158536    7782872   26%
sles12:btrfsvol:/dev/sda2/@/boot/grub2/x86_64-efi
                                      12587008    3158536    7782872   26%
sles12:btrfsvol:/dev/sda2/@/opt       12587008    3158536    7782872   26%
sles12:btrfsvol:/dev/sda2/@/srv       12587008    3158536    7782872   26%
.....
.....
[6] Mount a disk for a virtual machine.
dlp:~ #
guestmount -d sles12 -i /mnt

dlp:~ #
ll /mnt

total 0
drwxr-x--- 1 root root   34 Nov 22 23:17 .snapshots
drwxr-xr-x 1 root root 1810 Nov 22 23:14 bin
drwxr-xr-x 1 root root  584 Nov 22 23:18 boot
drwxr-xr-x 1 root root    0 Nov 22 23:09 dev
drwxr-xr-x 1 root root 5204 Nov 22 23:20 etc
drwxr-xr-x 3 root root   18 Nov 22 23:17 home
.....
.....
[7] Display the status of virtual machines.
dlp:~ #
virt-top

virt-top 01:33:58 - x86_64 4/4CPU 2801MHz 12038MB
2 domains, 0 active, 0 running, 0 sleeping, 0 paused, 2 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
    -                                           (sles12)
    -                                           (template)
Matched Content