RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

Инструменты пользователя

Инструменты сайта


virtualization:virt_what

Как определить систему виртуализации на хосте

systemd

Команда для проверки (baremetal, scaleway, azure, rootwelt)

# systemd-detect-virt
none
kvm
microsoft
xen

virt-what

Есть отдельная утилита virt-what

Определяемые типы виртуализации

Определяемые типы виртуализации

virt-what is a shell script which can be used to detect if the program
is running in a virtual machine.
The program prints out a list of "facts" about the virtual machine,
derived from heuristics.  One fact is printed per line.
If nothing is printed and the script exits with code 0 (no error),
then it can mean either that the program is running on bare-metal or
the program is running inside a type of virtual machine which we don't
know about or can't detect.
Current types of virtualization detected:
- aws          Amazon Web Services cloud guest
- bhyve        FreeBSD hypervisor
- docker       Docker container
- hyperv       Microsoft Hyper-V
- ibm_power-kvm
IBM POWER KVM
- ibm_power-lpar_shared
- ibm_power-lpar_dedicated
IBM POWER LPAR (hardware partition)
- ibm_systemz-*
IBM SystemZ Direct / LPAR / z/VM / KVM
- ldoms        Oracle VM Server for SPARC Logical Domains
- linux_vserver
Linux VServer container
- lxc          Linux LXC container
- kvm          Linux Kernel Virtual Machine (KVM)
- lkvm         LKVM / kvmtool
- openvz       OpenVZ or Virtuozzo
- ovirt        oVirt node
- parallels    Parallels Virtual Platform
- powervm_lx86 IBM PowerVM Lx86 Linux/x86 emulator
- qemu         QEMU (unaccelerated)
- rhev         Red Hat Enterprise Virtualization
- uml          User-Mode Linux (UML)
- virtage      Hitachi Virtualization Manager (HVM) Virtage LPAR
- virtualbox   VirtualBox
- virtualpc    Microsoft VirtualPC
- vmm          vmm OpenBSD hypervisor
- vmware       VMware
- xen          Xen
- xen-dom0     Xen dom0 (privileged domain)
- xen-domU     Xen domU (paravirtualized guest domain)
- xen-hvm      Xen guest fully virtualized (HVM)


# yum install vert-what
# apt-get install virt-what

Проверка (baremetal, scaleway, azure, rootwelt)

# systemd-detect-virt
пустой вывод
kvm
hyperv
xen/xen-domU

dmesg

Copy/paste, источник: https://www.dmo.ca/blog/detecting-virtualization-on-linux/
Актуальность под большим сомнением

  • VMWare
# dmesg | grep -i virtual
 VMware vmxnet virtual NIC driver
   Vendor: VMware    Model: Virtual disk      Rev: 1.0 
 hda: VMware Virtual IDE CDROM Drive, ATAPI CD/DVD-ROM drive
  • QEmu or KVM

If the "-cpu host" option has not been used, QEmu and KVM will identify themselves as:

# dmesg | grep -i virtual
 CPU: AMD QEMU Virtual CPU version 0.9.1 stepping 03

otherwise, the host's CPU information will be used both in dmesg, or in /proc/cpuinfo.

However, you should see something like:

 $ dmesg | grep -i virtual
 [    0.000000] Booting paravirtualized kernel on KVM

on newer kernels that understand that they're running under paravirtualization.

  • Microsoft VirtualPC
# dmesg | grep -i virtual
 hda: Virtual HD, ATA DISK drive
 hdc: Virtual CD, ATAPI CD/DVD-ROM drive
  • Xen
# dmesg | grep -i xen
Xen virtual console successfully installed as tty1
  • Virtuozzo
# dmesg
(returns no output)

# cat /var/log/dmesg
(returns no output)

# ls -al /proc/vz
veinfo  veinfo_redir  veredir  vestat  vzaquota  vzdata

On longer-running systems, you may need to grep /var/log/dmesg instead.

If that doesn't produce anything useful, try using dmidecode to look at the BIOS information. Frequently, there will be at least one component identifying itself as virtualized:

  • VMWare
 # dmidecode | egrep -i 'manufacturer|product'
 Manufacturer: VMware, Inc.
 Product Name: VMware Virtual Platform
  • Microsoft VirtualPC
 # dmidecode | egrep -i 'manufacturer|product'
 Manufacturer: Microsoft Corporation
 Product Name: Virtual Machine
  • QEMU or KVM
 # dmidecode | egrep -i 'vendor'
 Vendor: QEMU
  • Virtuozzo
 # dmidecode
 /dev/mem: Permission denied
  • Xen
 # dmidecode | grep -i domU
       Product Name: HVM domU

You should just examine the output of dmidecode directly rather than trying to grep as above, in case the output changes. QEMU, for example, doesn't report the vendor in all versions.

Next, check disk devices for identification as virtualized:

  • VMWare
# cat /proc/ide/hd*/model
VMware Virtual IDE CDROM Drive
# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0 
  Type:   Direct-Access                    ANSI SCSI revision: 02
  • Microsoft VirtualPC
# cat /proc/ide/hd*/model
Virtual HD
Virtual CD
  • QEMU, KVM, or Xen
# cat /proc/ide/hd*/model
QEMU HARDDISK
QEMU DVD-ROM
  • Virtuozzo
# ls -al /dev/vzfs
b-----x--- 1 root root 0, 19 2009-04-06 15:04 /dev/vzfs
Сайт rtfm.wiki использует cookies и трекинг посещений. Продолжая использовать этот сайт, вы соглашаетесь с сохранением файлов cookie на вашем компьютере. Если вы не согласны покиньте сайт или включите Adblock 😎 Что такое cookies? 🍪

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
 
virtualization/virt_what.txt · Последнее изменение: 2020/04/09 22:07 — 127.0.0.1