How to tell if I am on a XEN or KVM Server?

4

1

Is there a way to tell if I am on a XEN or KVM linux server? Reason I asked is nothing is on top yet I am seeing load averages high well after I do tasks and I am getting hangs/spikes when I do simple tasks

Rachel Nark

Posted 2012-05-18T01:53:10.943

Reputation: 649

Answers

0

If you have sudo privileges you can run the following command to get information about the "hardware" that CentOS is running on:

sudo lshw

For example, the first few lines of output on one of my computers is:

description: Desktop Computer
product: Virtual Machine
vendor: Microsoft Corporation

A virtual machine from Microsoft? I'm running on Hyper-V.

William Jackson

Posted 2012-05-18T01:53:10.943

Reputation: 7 646

I don't have anything like that so this looks like a dedicated server. – Rachel Nark – 2012-05-18T14:42:13.040

I don't know what kind of output one would get with KVM or XEN. There is always the possibility that they spoof actual hardware. Other than asking the system administrator, there may not be a way to definitively determine whether it is a virtual machine. – William Jackson – 2012-05-18T16:28:32.703

2

systemd-detect-virt

returns on this Ubuntu 18.04 KVM setup:

kvm

and on my host:

none

See also: https://unix.stackexchange.com/questions/89714/easy-way-to-determine-virtualization-technology

Tested on an Ubuntu 18.04 host.

Ciro Santilli 新疆改造中心法轮功六四事件

Posted 2012-05-18T01:53:10.943

Reputation: 5 621

1

There is code that can detect this: http://ivanlef0u.fr/repo/windoz/rootkit/invisiblethings/redpill.html

You can also check dmesg and lspci.

Xen PV guest or Xen guests with PV drivers will have something xen-related in dmesg

http://wiki.xen.org/wiki/Xen_Linux_PV_on_HVM_drivers#Verifying_Xen_Linux_PVHVM_drivers_are_using_optimizations

dmesg | egrep -i 'xen|front

Todd Deshane

Posted 2012-05-18T01:53:10.943

Reputation: 206

0

lshw is not always available on *nix servers. Yes you can install it, however I like to opt for stuff that I get for free on the box. I found that for the most part dmidecode is usually available. Use this instead:

Fun fact, lshw gets some info from DMI table entries and other sources for the info it provides. But for this purpose, just using dmidecode is sufficient.

dmidecode -t system|grep 'Manufacturer\|Product'

Output on Dell server:

Manufacturer: Dell Inc.
Product Name: PowerEdge C5220

Output on Virtualbox VM:

Manufacturer: innotek GmbH
Product Name: VirtualBox

Output on KVM/QEMU:

Manufacturer: QEMU
Product Name: Standard PC (i440FX + PIIX, 1996)

This is great for scripts that can parse these out for better identification of servers... but if you use Chef in your infrastructure, you can check the node attribute Virtualization -> system in the chef server .

OkezieE

Posted 2012-05-18T01:53:10.943

Reputation: 101

Did not work with this Ubuntu 18.04 on Ubuntu 18.04 setup: https://askubuntu.com/revisions/1046792/15 , it just output: Standard PC (i440FX + PIIX , 1996).

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2018-10-04T15:06:44.227