Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an OS command I can run to determine if running inside a Xen based virtual machine

Tags:

linux

unix

xen

Is there an OS command I can run from within a Xen based virtual machine to tell me that it is a virtual box rather than a physical box - I heard that the kernel had some self awareness smarts about it. e.g. like an extra column in "ps" output or something? [I know vmstat provides the "st" column but I have seen this on physical host boxes running Linux Kernel 2.6.11 and greater as well].

Many Thanks,

Paul

like image 744
pjp Avatar asked Aug 16 '10 06:08

pjp


People also ask

Is Xen an operating system?

Xen (pronounced /ˈzɛn/) is a type-1 hypervisor, providing services that allow multiple computer operating systems to execute on the same computer hardware concurrently.

What runs on Xen hypervisor?

The Xen Project hypervisor runs directly on the hardware and is responsible for handling CPU, Memory, timers and interrupts. It is the first program running after exiting the bootloader. On top of the hypervisor run a number of virtual machines. A running instance of a virtual machine is called a domain or guest.

Does Xen run on Linux?

Xen is the open source hypervisor included in the Linux kernel and, as such, it is available in all Linux distributions. The Xen Project is one of the many open source projects managed by the Linux Foundation.


2 Answers

Try file /sys/hypervisor/uuid.

  1. It does not exist -> Not related to XEN.
  2. It does exist, and is full of 0-s -> It is a XEN Dom0
  3. It does exist, and has a not-0 values -> It is a DomU

This requires of course, that /sys is mounted and populated...

like image 81
Matya Avatar answered Oct 01 '22 12:10

Matya


Dmesg may give some hints from the kernel message buffer, here is output on a virtualized Ubuntu instance from Slicehost:

bvm@qdbp:~$ sudo dmesg | grep Xen
[    0.000000]  Xen: 0000000000000000 - 00000000000a0000 (usable)
[    0.000000]  Xen: 00000000000a0000 - 0000000000100000 (reserved)
[    0.000000]  Xen: 0000000000100000 - 0000000010000000 (usable)
[    0.000000] Booting paravirtualized kernel on Xen
[    0.000000] Xen version: 3.1.2-rc1
[    0.000000] Xen: using vcpu_info placement
[    0.000000] Xen: using vcpuop timer interface
[    0.000000] installing Xen timer for CPU 0
[    0.021223] installing Xen timer for CPU 1
[    0.046157] installing Xen timer for CPU 2
[    0.046157] installing Xen timer for CPU 3
[    0.265880] Initialising Xen virtual ethernet driver.
like image 37
unmounted Avatar answered Oct 01 '22 11:10

unmounted