How to detect virtualization 虚拟机检测
来源:互联网 发布:10月经济数据点评 编辑:程序博客网 时间:2024/05/18 03:40
除了下面的方法外,mac地址也可以检测虚拟机。
Update: You may be interested in [[the perl module|perl-module-for-virtualization-detection]] implementing these tricks.
Frequently, our customers want to install our software in a virtual machine. This can be OK, but frequently they hit a CPU, memory, or IO limit caused by running in a constrained virtual environment. When this happens, we really like to know if they’re running under virtualization when we try to support them. Here’s some tricks to detect, from a shell, if the system is virtualized.
The first thing to check is dmesg. On a recently-booted system, checking the ‘dmesg’ command output may be sufficient. Otherwise, try “cat /var/log/dmesg” instead of “dmesg”
- 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. (Thanks to René Pfeiffer for pointing this out)
- Microsoft VirtualPC:
# dmesg | grep -i virtual hda: Virtual HD, ATA DISK drive hdc: Virtual CD, ATAPI CD/DVD-ROM drive
- Xen (thanks, wardi and others)
# dmesg | grep -i xenXen virtual console successfully installed as tty1
- Virtuozzo
# dmesg(returns no output)# cat /var/log/dmesg(returns no output)# ls -al /proc/vzveinfo 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*/modelVMware Virtual IDE CDROM Drive# cat /proc/scsi/scsiAttached 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*/modelVirtual HDVirtual CD
- QEMU, KVM, or Xen:
# cat /proc/ide/hd*/modelQEMU HARDDISKQEMU DVD-ROM
- Virtuozzo:
# ls -al /dev/vzfsb-----x--- 1 root root 0, 19 2009-04-06 15:04 /dev/vzfs
- How to detect virtualization 虚拟机检测
- ystem Call Interposition: how to implement virtualization
- How to Detect a Dialup Connection?
- How to detect the explorer in js
- How to detect HTTP connection break
- How to detect "edit mode" in excel
- How to Detect HTTP Parameter Pollution Attacks
- Keyloggers: How they work and how to detect them
- How to check if your hardware supports virtualization
- How to use windbg to detect memory leak
- How to Detect and Respond to Malware-Free Intrusions
- 视频目标检测跟踪--Detect to Track and Track to Detect
- 视频目标检测跟踪--Detect to Track and Track to Detect
- How To Detect If an Application Has Stopped Responding
- How To Detect If an Application Has Stopped Responding
- how to detect VMM using (almost) one CPU instruction
- How To Detect If an Application Has Stopped Responding
- JavaScript: How to detect that the Internet Connection is foffline
- 虚拟主机中,不修改IIS设置,在IIS6下运行MVC架构的网站
- 读CopyOnWriteArrayList有感
- c陷阱和缺陷的一点笔记
- Ubuntu Linux 下文件名乱码(无效的编码)的快速解决办法
- 批处理学习笔记1
- How to detect virtualization 虚拟机检测
- delphi字符串函数大全
- smarty3.0.7官网下载的demo运行报错 /*%%SmartyNocache:221334da460b2356f10-15165135%%*//*/% 解决方法(转)
- 引入Adobe Flex 4.5 SDK
- Gentoo Linux以太网Bonding
- PHP设计模式之Singleton模式
- C/C++从入门到高手所有必备PDF书籍
- ubuntu tftp服务配置
- 这些情况使用StringBuilder代替String(抄袭加翻译)