判断我们的服务器是物理机还是虚拟机

方法一:dmesg

举例如下:

###这是阿里云的云主机
[root@xxx ~]# dmesg |grep -i virtual
[    0.000000] Booting paravirtualized kernel on KVM
[    0.707486] KVM setup paravirtual spinlock
[    1.811087] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input2
[    1.811257] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input3
[    1.824106] systemd[1]: Detected virtualization kvm.
[    1.853583] systemd[1]: Starting Setup Virtual Console...
###这是一台物理机
[root@xxx]# dmesg |grep -i virtual
Booting paravirtualized kernel on bare hardware
input: Macintosh mouse button emulation as /devices/virtual/input/input1

 

方法二:dmidecode 

举例如下:

###这是阿里云的云主机
[root@xxx~]# dmidecode -s system-product-name
Alibaba Cloud ECS
###这是一台物理机
[root@xxx]# dmidecode -s system-product-name
PowerEdge R720
posted @ 2019-11-07 09:58  --smile  阅读(1170)  评论(0编辑  收藏  举报