当前位置: 首页 > news >正文

Easy Ways to Determine Virtualization Technology

1. Overview

Usually, when we work with a virtual Linux system, it doesn’t feel much different from a conventional system. However, sometimes, we still want to know if a system is a virtual system.

Moreover, we’ll probably want to know which virtualization technology the virtual system is using, such as VMware, VirtualBox, Linux KVM, and so on.

In this tutorial, we’ll discuss how to determine virtualization technology using Linux commands.

2. Using thedmidecodeCommand

The dmidecode command can report the information about our system BIOS according to the SMBIOS/DMI standard.

Since thedmidecodecommand attempts to read hardware and firmware information, we needrootaccess to execute the command.

When we are working with a non-virtualized system, we will get the motherboard information by querying the keysystem-product-name:

$ sudo dmidecode -s system-product-name H87-D3HCopy

The output above shows that the system is running on a machine with a (Gigabyte)H87-D3Hmotherboard.

However, if a system is running in a virtual machine, the same command will print the name of the virtualization product.

Let’s test this command with some common virtualization technologies and see what it reports.

Firstly, let’s execute the command on a virtual system in VirtualBox:

$ sudo dmidecode -s system-product-name VirtualBoxCopy

It reports the correct virtualization environment.

Next, let’s try the command on KVM and VMware virtual machines:

$ sudo dmidecode -s system-product-name KVMCopy
$ sudo dmidecode -s system-product-name VMware Virtual PlatformCopy

If we haverootaccess, using thedmidecodecommand is a pretty straightforward way to get the virtualization information.

3. Using thelshwCommand

The lshw command is a convenient tool for listing detailed information on hardware configurations.

We can use this tool and query thesystemclassto get information about the virtualization.

We should notice thatrootaccess is required to get the virtualization technology data.

Let’s start by executing the command on a non-virtualized system and see what it prints:

$ sudo lshw -class system yk-arch description: Desktop Computer product: H87-D3H (To be filled by O.E.M.) vendor: Gigabyte Technology Co., Ltd. version: To be filled by O.E.M. serial: To be filled by O.E.M. width: 64 bits capabilities: smbios-2.7 dmi-2.7 smp vsyscall32 configuration: administrator_password=disabled boot=normal ...Copy

Similar todmidecode, thelshwcommand prints the motherboard information in the “product” field.

Next, let’s see what it will report on various virtual systems.

Firstly, let’s run it in a virtual machine of VirtualBox:

$ sudo lshw -class system myVbox.test description: Computer product: VirtualBox vendor: Oracle version: 1.2 serial: 0 width: 64 bits capabilities: smbios-2.5 dmi-2.5 smp vsyscall32 configuration: family=Virtual Machine uuid=......Copy

Theproductfield is now filled by the expected virtualization technology information.

Let’s try the same command with systems on KVM and VMware:

$ sudo lshw -class system myKvm.test description: Computer product: KVM vendor: Red Hat version: 1.2 serial: 0 width: 64 bits capabilities: smbios-2.4 dmi-2.4 smp vsyscall32 configuration: family=Virtual Machine uuid=......Copy
$ sudo lshw -class system myVmware.test description: Computer product: VMware Virtual Platform vendor: VMware, Inc. version: 1.2 serial: 0 width: 64 bits capabilities: smbios-2.4 dmi-2.4 smp vsyscall32 configuration: family=Virtual Machine uuid=......Copy

Thelshwcommand is a convenient option for us to solve the problem if we haverootaccess.

4. Using thesystemd-detect-virtCommand

Most modern Linux systems usesystemdas the system and service manager. Thesystemdpackage ships with the systemd-detect-virt utility, which we can use to detect a virtualization technology.

It’s worth mentioning thatwe don’t needrootaccess to execute this command.

As usual, let’s see what it reports if we execute the command on a non-virtualized system:

$ systemd-detect-virt noneCopy

As the output shows,if the system isn’t running in a virtual machine, we’ll get “none” as the result.

Next, let’s check the output we get when we run it on a virtual machine in VirtualBox:

$ systemd-detect-virt oracleCopy

It lists “oracle” instead of something like “VirtualBox”. This is because thesystemd-detect-virtcommand shows only theIDof virtualization technology.

In the man page, there is a table listing the detailedIDand product information. For example, the product information ofIDoracle” is:

oracle Oracle VM VirtualBox (historically marketed by innotek and Sun Microsystems), for legacy and KVM hypervisorCopy

Now, let’s run the command on virtual machines of KVM and VMware:

$ systemd-detect-virt kvmCopy
$ systemd-detect-virt vmwareCopy

As we’ve seen above, thesystemd-detect-virtcommand is pretty handy to get the information of the virtualization technology.

We can get the full list of detectable containers and VM environments using the–listoption:

$ systemd-detect-virt --list none kvm qemu bochs xen uml vmware oracle microsoft ...Copy

5. Using thehostnamectlCommand

In addition to the handysystemd-detect-virtcommand, thesystemdpackage provides the hostnamectl command. This utility allows us to query and change the system hostname and related settings.

We can use thehostnamectlcommand to detect virtualization technology as well.

Same as thesystemd-detect-virtcommand,rootaccess is not required if we want to query information using thehostnamectlcommand.

Firstly, let’s have a look at whathostnamectltells us if we execute it on a non-virtualized system:

$ hostnamectl Static hostname: YK-Arch Icon name: computer-desktop Chassis: desktop Machine ID: d0fdfacb84184cee9507e0e1ac518e73 Boot ID: 9f88561ec0864abfa51575e8ec74732f Operating System: Arch Linux Kernel: Linux 5.7.9-arch1-1 Architecture: x86-64Copy

The output above shows the detailed distribution name, operating system, and kernel information.

Further, we’ll execute the same command on a VirtualBox guest system again. Let’s check if it reports different information:

$ hostnamectl Static hostname: myVbox.test Icon name: computer-vm Chassis: vm Machine ID: b4998efc50ae499881b024c258934223 Boot ID: f885614223a240b3b3b04cef3a934f18 Virtualization: oracle Operating System: CentOS Linux 7 (Core) Kernel: Linux 3.10.0-514.10.2.el7.x86_64 Architecture: x86-64Copy

In the output above, theIcon nameand theChassisare telling us it is a “vm” (virtual machine).

Moreover, we can see a new field —Virtualization. This field tells us which virtualization technology our system is running in. In this case, it’soracle(VirtualBox).

Let’s see what the command will report on KVM and VMware virtual machines:

$ hostnamectl Static hostname: myKvm.test Icon name: computer-vm Chassis: vm Machine ID: 55296cb0566a4aaca10b8e3a4b28b432 Boot ID: 1bb259b0eb064d9eb8a22d112211b334 Virtualization: kvm Operating System: Ubuntu 19.10 Kernel: Linux 5.3.0-59-generic Architecture: x86-64Copy
$ hostnamectl Static hostname: myVmware.test Icon name: computer-vm Chassis: vm Machine ID: 18a0752e1ccbeef09da51ad17fab1f1b Boot ID: beefdc99969e4a4a8525ff842b383c62 Virtualization: vmware Operating System: Ubuntu 19.10 Kernel: Linux 5.3.0-59-generic Architecture: x86-64Copy

6. Conclusion

In this article, we addressed different Linux command utilities to detect various virtualization technologies.

All those utilities are pretty straightforward to use. However, some of them requirerootaccess, and some don’t. We can choose the tool that’s most suitable for our needs.

http://www.jsqmd.com/news/1173420/

相关文章:

  • STM32与PAM8904实现可编程多级警报系统设计
  • 过敏调理赛道消费需求攀升 牛初乳改善常年复发性鼻炎功效成关注焦点
  • 高精度ADC与MCU的硬件设计及SPI通信优化
  • 空洞骑士模组管理器Scarab:新手快速上手指南
  • 时间序列建模入门:从听懂数据节奏开始
  • 3个核心功能彻底改变你的GTA5线上体验:完全免费的游戏增强工具
  • A3910与PIC18F96J94在嵌入式电机控制中的实战应用
  • 终极免费抽奖神器:Magpie-LuckyDraw全平台部署与使用完全指南
  • L9958与PIC18F86J11的直流电机控制方案解析
  • 2026凤台县中考200-300分如何填志愿!淮南这所公办中专免学费火热招生中! - 小张zc
  • 2026年AI API中转网关选型指南:星链4SAPI与五大平台如何应对401、429错误
  • Quartus II 18.1 管脚分配自动化:Tcl脚本批量处理100+管脚实战
  • 蓝牙5.4 LE Audio与STM32F429ZI的高保真低延迟音频传输方案
  • 遗传算法工程化实战:从原理到稳定收敛的四大跃迁
  • 劳力士官方直营售后维修网点|官方网站权威公告(2026年7月最新) - 劳力士中国服务中心
  • 如何构建99.8%成功率的实时抖音弹幕采集系统:WebSocket与签名验证实战
  • AI智能体手机技术解析:端侧大模型与工具调用的工程实践
  • 大屏可视化平台3大性能陷阱:数据源连接、实时刷新与多屏适配实战避坑
  • 未来展望:openeuler/sra_tensorflow_adapter路线图与鲲鹏AI生态发展趋势
  • STM32驱动压电蜂鸣器:硬件设计与音效优化
  • 工业级遗传算法实战:从编码策略到动态约束处理
  • 第 11 篇:优雅升级探针——先问“能停吗“,再动手升级
  • 跨平台输入法词库同步:深蓝词库转换器完全指南
  • 阿里云 DSW 免费 GPU 实例部署:V100/A10 3个月试用避坑 3 要点
  • Unity Slider交互进阶:精准监听拖拽、点击与悬停的三种实现方案
  • 2026万博科技职业学院报考全流程:志愿填报、咨询渠道 - 最新资讯
  • NBM7100A与STM32协同优化不可充电电池寿命方案
  • XXMI Launcher:终极跨平台游戏模组管理平台,一站式管理六款热门游戏
  • MCP3551与PIC18LF46K42高精度ADC系统设计与优化
  • 开题报告可以免费生成的AI论文网站有哪些