Windows:
在CMD里输入:Systeminfo | findstr /i "System Model"
如果System Model:后面含有Virutal就是虚拟机,其他都是物理机
或者用powershell命令:get-wmiobject win32_computersystem | fl model
Linux:
在bash里输入:dmidecode -s system-product-name
或者lshw -class system
或者dmesg | grep -i virtual
虚拟机(下边有VMWar):
[root@test ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
物理机:
[root@localhost 2019]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 02 Id: 00 Lun: 00
Vendor: LSI Model: MR9240-8i Rev: 2.13
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi0 Channel: 02 Id: 01 Lun: 00
Vendor: LSI Model: MR9240-8i Rev: 2.13
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi7 Channel: 00 Id: 00 Lun: 00
Vendor: WD Model: Elements 25A2 Rev: 1004
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi6 Channel: 00 Id: 00 Lun: 00
Vendor: WD Model: Elements 25A2 Rev: 1004
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi8 Channel: 00 Id: 00 Lun: 00
Vendor: WD Model: Elements 25A2 Rev: 1004
Type: Direct-Access ANSI SCSI revision: 02