!/bin/bash
SYSTEM_INFO=dmidecode | grep -A 1 "System Information" | grep Manufacturer | cut -d: -f2 | tr -d " "
MOTHERBOARD_MANUFACTURER=dmidecode | grep -A 1 "Base Board" | grep Manufacturer | cut -d: -f2 | tr -d " "
if [[ $MOTHERBOARD_MANUFACTURER == VMware ]] || [[ $SYSTEM_INFO == VMware ]] ; then echo "virtualized=vmware" fi
control test for my laptop
if [[ $MOTHERBOARD_MANUFACTURER == LENOVO ]] || [[ $SYSTEM_INFO == LENOVO ]] ; then echo "lenovo" fi
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 xen
Xen virtual console successfully installed as tty1 Virtuozzo
ls -al /proc/vz
veinfo veinfo_redir veredir vestat vzaquota vzdata On longer-running systems, you may need to grep /var/log/dmesg instead.
# 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.
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
http://redis-py.readthedocs.org/en/latest/index.html#redis.StrictRedis.info