mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
parent
2e234aebe0
commit
c8078622ca
186
published/20230818 What is a Virtual Machine.md
Normal file
186
published/20230818 What is a Virtual Machine.md
Normal file
@ -0,0 +1,186 @@
|
||||
[#]: subject: "What is a Virtual Machine?"
|
||||
[#]: via: "https://itsfoss.com/virtual-machine/"
|
||||
[#]: author: "Ankush Das https://itsfoss.com/author/ankush/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "ChatGPT"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-16153-1.html"
|
||||
|
||||
什么是虚拟机?
|
||||
======
|
||||
|
||||
![][0]
|
||||
|
||||
> 这是终端用户需要知道的所有关于虚拟机的信息,包括它的工作方式及其必要性。
|
||||
|
||||
**虚拟机(VM)是一个模拟版的物理计算机,它在虚拟环境中模拟各种功能并分配资源。**
|
||||
|
||||
简言之,你可以在你当前的操作系统中运行另一个操作系统,就像运行媒体播放器或网络浏览器一样。
|
||||
|
||||
![在 Manjaro Linux 里 VirtualBox 中运行 Windows 10][1]
|
||||
|
||||
你可以在 VM 中执行与裸机(例如你的笔记本电脑或个人电脑)相同的操作,例如连接到网络、下载软件、更新操作系统等等。
|
||||
|
||||
当然,根据使用场景,VM 的体验可能会与实体计算机有所不同。
|
||||
|
||||
让我们来探索虚拟机,它们的应用场景,以及它们的工作原理。
|
||||
|
||||
### 虚拟机:起源
|
||||
|
||||
![][2]
|
||||
|
||||
虚拟机是最重要的基于软件的创新之一。它的起源可以追溯到 **1966 年的 IBM CP-40 和 CP-67** 虚拟机操作系统,那时候人们在研究和测试虚拟内存和资源的概念。
|
||||
|
||||
快进到我们发表此文的 2023 年,虚拟机已经无处不在,涵盖从个人电脑,到大型企业,再到小型企业。每个人以某种或其他方式都在使用虚拟机。
|
||||
|
||||
考虑到所有这些,显然,虚拟机非常有用。但是,它是如何工作的,我们具体用它来做什么?
|
||||
|
||||
> 💡
|
||||
> - 裸机 = 实体的物理电脑,例如你的 PC 或笔记本电脑
|
||||
> - 宿主操作系统 = 安装在你实体电脑上的操作系统
|
||||
> - 客户操作系统 = 在虚拟机内运行的操作系统
|
||||
> - 虚拟机(VM)= 是虚拟化应用的通用术语
|
||||
|
||||
### 虚拟机如何运作
|
||||
|
||||
![][3]
|
||||
|
||||
理解虚拟化的概念会有助于你弄清楚虚拟机是如何运作的。
|
||||
|
||||
回顾我们在一篇文章中的描述:
|
||||
|
||||
> “虚拟化为你提供了计算机硬件的抽象概念,以便你创建虚拟机(VM)、网络、存储等。”
|
||||
|
||||
**虚拟化**允许用户在虚拟环境中利用物理系统的资源。这使得一个进程可以单独地使用资源,而不会影响物理计算机。
|
||||
|
||||
而**虚拟机就是运用这一能力的过程**,在此你会得到以虚拟磁盘、内存,及其他配置文件形式的虚拟资源,让你能在其上运行操作系统。
|
||||
|
||||
你或许已经熟悉一些能帮助你创建这些虚拟机的 [专为 Linux 的虚拟化软件][4]。
|
||||
|
||||
为了详细展示虚拟机和物理计算机之间的技术差异,这里提供一张图帮助你理解:
|
||||
|
||||
![][6]
|
||||
|
||||
### 我们为什么需要使用虚拟机?
|
||||
|
||||
虚拟机已经成为一种多功能的概念,对于几乎每一个小任务都十分实用,这也是你应该 [在虚拟机中运行 Linux][7] 的其中一个理由。
|
||||
|
||||
不仅对个人用户有帮助,虚拟机在云计算的领域中也起着重要的作用,而云计算是构成互联网必不可少的一部分。
|
||||
|
||||
![][8]
|
||||
|
||||
下面是虚拟机能够帮助你完成的一些任务:
|
||||
|
||||
* 软件测试
|
||||
* 操作系统测试
|
||||
* 为临时的网络浏览会话增强你的在线隐私
|
||||
* 在不影响物理计算机的情况下进行网络安全研究
|
||||
* 利用虚拟机作为服务器,使同一硬件上可以托管更多的虚拟机,(从而让硬件资源使用更加高效)
|
||||
* 各种开发活动,拥有了更强大的迁移、复制等功能
|
||||
* 利用虚拟机在云中复制系统
|
||||
|
||||
因此,虚拟机的隔离能力使我们能采用它进行测试和开发,也使其成为服务器可扩展性和灵活性的核心。
|
||||
|
||||
**建议阅读 📖**
|
||||
|
||||
> [在虚拟机中运行 Linux 的十大原因][8A]
|
||||
|
||||
无论你是学生、专业人员,还是企业,你都会发现虚拟机在某个时间点会发挥出重要的作用。
|
||||
|
||||
### 虚拟机消耗系统资源吗?
|
||||
|
||||
当你创建一个虚拟机在其中运行另一个操作系统时,你会为它分配一些系统资源,主要包括:
|
||||
|
||||
* 处理器:只有当在虚拟机中运行操作系统时才消耗
|
||||
* 内存:只有当在虚拟机中运行操作系统时才消耗
|
||||
* 磁盘空间:创建虚拟机时预留,无论虚拟机是否运行,都会占据一定的空间。
|
||||
|
||||
有些人认为处理器和内存会一直被虚拟机占用,这并不正确。它们只在虚拟机运行操作系统时才会被使用。
|
||||
|
||||
然而,无论虚拟机是否在运行,磁盘空间始终会被占用。
|
||||
|
||||
### 使一切成为可能的虚拟化类型
|
||||
|
||||
如果你对能够帮助创建虚拟机的虚拟化概念感兴趣,那么我将列举并简要解释所有的不同类型。
|
||||
|
||||
<ruby>管理程序<rt>Hypervisor</rt></ruby> 管理着硬件,并将系统资源从虚拟环境中隔离出来。它在技术上被标记为 “<ruby>虚拟机监视器<rt>Virtual Machine Monitor</rt></ruby>(VMM)”。
|
||||
|
||||
而管理程序就是那个**能让我们创建和运行虚拟机的软件**。
|
||||
|
||||
管理程序有两种类型:
|
||||
|
||||
* **一级管理程序** :它直接连接到物理机,用于管理虚拟机的资源。一个很好的例子就是 [KVM][9],它直接集成在 Linux 系统里。
|
||||
* **二级管理程序** :它存在于操作系统上,在操作系统上运行,让你能够管理虚拟机资源等等。例如 [VirtualBox][10]。
|
||||
|
||||
虽然管理程序使虚拟化成为可能,但是各种虚拟化类型则能使你在使用虚拟机时带来更多便利和功能。
|
||||
|
||||
一些相关的类型包括:
|
||||
|
||||
* **存储虚拟化** :这能通过将可用的磁盘空间划分为小块,以被虚拟机使用,从而创建虚拟磁盘。
|
||||
* **网络虚拟化** :允许物理网络连接通过虚拟网络(或者适配器)路由到虚拟机。
|
||||
* **桌面虚拟化** :通过该方式,你可以同时向多台物理设备部署多个虚拟桌面环境。可以从一个中心点配置和管理所有虚拟桌面。
|
||||
|
||||
为了深入了解所有的技术细节,我建议你查阅 [AWS 关于虚拟化的文档][11]。
|
||||
|
||||
### 虚拟机的优势
|
||||
|
||||
![][12]
|
||||
|
||||
虽然你已经通过其使用案例了解到了一些虚拟机带给你的好处,但是我还是想再补充一些你需要知道的要点:
|
||||
|
||||
* 虚拟机能够让你充分地利用硬件资源,而不影响宿主机
|
||||
* 有了虚拟机,你可以自由地进行测试或者做任何你想做的事情。无论是一个极老的应用,或是一个有风险的软件,你都可以完全依赖虚拟机来完成一切,并且不会对你宿主机产生影响
|
||||
* 你可以在一个地方运行多个操作系统,而不需要面对双启动或增加额外的物理驱动器来使用其它操作系统的麻烦。这样可以帮你节省成本,时间,同时避免管理的困扰
|
||||
* 有了虚拟机,你可以在不需增加任何硬件的情况下快速地克隆你的配置。
|
||||
|
||||
### 虚拟机的劣势
|
||||
|
||||
![][13]
|
||||
|
||||
虽然虚拟机在许多场景中都非常有帮助,但是它也有可能带来什么不利影响吗?
|
||||
|
||||
嗯,实际上,使用虚拟机并没有直接的缺点,但是你仍然需要对一些虚拟机可能带来的影响持谨慎态度:
|
||||
|
||||
* 尽管虚拟机被认为能够有效地利用资源,但是如果你不监控它们或者粗心大意地运行多个虚拟机,它们还是有可能会耗尽系统的资源
|
||||
* 虚拟机永远无法替代裸机的体验和性能。无论宿主机有多么强大,虚拟机的运行速度总是比你在物理计算机上预期的要慢
|
||||
* 虚拟机虽然与宿主机隔离,但你必须要注意文件共享可能会将恶意软件暴露给你的宿主机系统
|
||||
|
||||
### 虚拟机的利用广泛
|
||||
|
||||
虚拟机的概念让许多事情变得可能。
|
||||
|
||||
如果没有虚拟机,你认为云计算行业会如何发展?如果每次尝试不同的操作系统都需要重新安装,这将带来多大的不方便?
|
||||
|
||||
💬 无论是哪种形式,每个电脑用户或服务器用户都需要虚拟机。你对虚拟机有什么看法呢?你会如何定义它?
|
||||
|
||||
*(题图:MJ/be913487-080e-4869-98d9-ccd996f68a7f)*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/virtual-machine/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:ChatGPT
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/content/images/2023/08/windows-without-menu.png
|
||||
[2]: https://itsfoss.com/content/images/2023/06/origin.png
|
||||
[3]: https://itsfoss.com/content/images/2023/06/vm.png
|
||||
[4]: https://itsfoss.com/virtualization-software-linux/
|
||||
[5]: https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png
|
||||
[6]: https://itsfoss.com/content/images/2023/06/vm-vs-physical-computer.png
|
||||
[7]: https://itsfoss.com/why-linux-virtual-machine/
|
||||
[8]: https://itsfoss.com/content/images/2023/06/why-we-use-vm.png
|
||||
[8A]: https://itsfoss.com/why-linux-virtual-machine/
|
||||
[9]: https://www.linux-kvm.org/page/Main_Page?ref=itsfoss.com
|
||||
[10]: https://www.virtualbox.org/?ref=itsfoss.com
|
||||
[11]: https://aws.amazon.com/what-is/virtualization/?ref=itsfoss.com
|
||||
[12]: https://itsfoss.com/content/images/2023/08/advantage.png
|
||||
[13]: https://itsfoss.com/content/images/2023/08/disadvantage.png
|
||||
[0]: https://img.linux.net.cn/data/attachment/album/202309/02/221631eu7kz2vqk2kvwtzv.jpg
|
@ -1,195 +0,0 @@
|
||||
[#]: subject: "What is a Virtual Machine?"
|
||||
[#]: via: "https://itsfoss.com/virtual-machine/"
|
||||
[#]: author: "Ankush Das https://itsfoss.com/author/ankush/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
What is a Virtual Machine?
|
||||
======
|
||||
|
||||
**A virtual machine (VM) is an emulated version of a physical computer that mimics the functions and allocates the resources in a virtual environment.**
|
||||
|
||||
Simply put, you have another operating system running as a regular application like a media player or web browser in your current operating system.
|
||||
|
||||
![Windows 10 running in VirtualBox inside Manjaro Linux][1]
|
||||
|
||||
You can do the same things in a VM compared to a bare metal machine (a real computer like your laptop or PC). For instance, connecting to a network, downloading software, updating the operating system, and more.
|
||||
|
||||
Of course, depending on the use case, the experience will be different from a physical computer.
|
||||
|
||||
Let us explore virtual machines, their use-cases, and how they work.
|
||||
|
||||
### Virtual Machines: The Origins
|
||||
|
||||
![][2]
|
||||
|
||||
Virtual Machine is one of the most significant software-based innovation. It has its roots as early as **1966** with **IBM CP-40 and CP-67** virtual machine operating systems, where the concept of virtual memory and resources was researched/tested.
|
||||
|
||||
Fast forward to 2023, when we publish this article, VMs are everywhere, from personal computers to enterprises and small businesses. Everyone uses a VM in one form or the other.
|
||||
|
||||
Considering all of that, it is evident that Virtual Machines (VMs) are immensely useful. But how does it work, and what exactly do we use it for?
|
||||
|
||||
💡
|
||||
|
||||
Bare Metal = The actual physical computer like your PC or laptop
|
||||
Host OS = The operating system on your actual computer
|
||||
Guest OS = The operating system running inside VM
|
||||
VM = Virtual Machine, the generic term for the virtualization application
|
||||
|
||||
### Here's How Virtual Machines Work
|
||||
|
||||
![][3]
|
||||
|
||||
The concept of virtualization should help you clarify how virtual machines work.
|
||||
|
||||
To give you a quick reminder from one of our articles:
|
||||
|
||||
" _Virtualization provides an abstract concept of computer hardware to help you create virtual machines (VMs), networks, storage, and more._ "
|
||||
|
||||
**Virtualization** lets a user utilize physical system resources in a virtual environment. This enables a process to use the resources separately without tampering with the physical computer.
|
||||
|
||||
And **Virtual Machine is the process** that uses this ability, where you get virtual resources in the form of a virtual disk, RAM, and other configuration files to allow you to run an operating system on top of it.
|
||||
|
||||
You might already know some [virtualization software for Linux][4] that help you create these virtual machines.
|
||||
|
||||
**Suggested Read 📖**
|
||||
|
||||
![][5]
|
||||
|
||||
To give you a technical difference between a virtual machine and a physical computer, here's a diagram to help you learn:
|
||||
|
||||
![][6]
|
||||
|
||||
### Why Do We Use Virtual Machines?
|
||||
|
||||
Virtual Machines have become a versatile concept that comes in handy for almost every little thing—one of the reasons why you should [run Linux in virtual machines][7].
|
||||
|
||||
Not just for individual users, but it is also a key highlight in cloud computing, which is a massive part of the internet.
|
||||
|
||||
![][8]
|
||||
|
||||
Some of the tasks that VMs help achieve include:
|
||||
|
||||
* Software testing
|
||||
* Operating system testing
|
||||
* Enhancing your online privacy for temporary web browsing sessions
|
||||
* Cybersecurity research without tampering physical computer
|
||||
* Using VMs as servers to host more VMs (thereby making efficient use of hardware resources) on the same hardware
|
||||
* All kinds of development activity with great flexibility of migration, cloning, etc.
|
||||
* Replicating systems in the cloud using VMs
|
||||
|
||||
|
||||
|
||||
So, the virtual machine's isolation capability helps us use it for testing and development and use it as the core for server scalability and flexibility.
|
||||
|
||||
**Suggested Read 📖**
|
||||
|
||||
![][5]
|
||||
|
||||
No matter whether you are a student, professional, or an enterprise, you will find the use of a virtual machine handy at one point of time.
|
||||
|
||||
### Do Virtual Machines Consume System Resources?
|
||||
|
||||
When you create a virtual machine to run another operating system in it, you allocate some system resources to it. They are primarily:
|
||||
|
||||
* CPU: Consumed only when the operating system is running in the VM
|
||||
* RAM: Consumed only when the operating system is running in the VM
|
||||
* Disk space: Reserved when you create the VM. Occupied irrespective of whether the VM is running or not.
|
||||
|
||||
|
||||
|
||||
A few people think the CPU and RAM will be utilized all the time. That's not true. RAM and CPUs are consumed only when the VM is running an operating system.
|
||||
|
||||
However, disk space is always reserved even when the VMs are not running.
|
||||
|
||||
### Types of Virtualization That Make it All Possible
|
||||
|
||||
If you are curious about the virtualization concept responsible for helping create a virtual machine, let me highlight all the different types of it and briefly explain it.
|
||||
|
||||
A hypervisor manages the hardware while separating the system resources from the virtual environment. It is technically labeled as a " **Virtual Machine Monitor (VMM)** "
|
||||
|
||||
And the hypervisor is the **software responsible for letting** An excellent **you create and run virtual machines.**
|
||||
|
||||
There are two types of hypervisors including:
|
||||
|
||||
* **Type 1 hypervisor** : This is directly connected to the physical machine for managing resources for the VM. An excellent example for it is [KVM][9], which comes baked with Linux.
|
||||
* **Type 2 hypervisor:** This exists on top of an operating system as an application that lets you manage VM resources and more—for instance, [VirtualBox][10].
|
||||
|
||||
|
||||
|
||||
While the hypervisor makes virtualization possible, the types of virtualization available make your experience hassle-free facilitating the features you get with a VM.
|
||||
|
||||
Some of the relevant types include:
|
||||
|
||||
* **Storage virtualization** : This helps creating a virtual disk by splitting the available disk space to small chunks reserved to be used by a virtual machine.
|
||||
* **Network virtualization** allows the physical network connection to be routed through virtual networks (or adapters) to the virtual machines.
|
||||
* **Desktop virtualization** : **** With this, you can deploy multiple virtual desktop environments to multiple physical machines at the same time. Configuration and management of all the virtual desktops is possible from a central point.
|
||||
|
||||
|
||||
|
||||
To explore all the technical details, I recommend checking out [AWS's documentation on virtualization][11].
|
||||
|
||||
### Advantages of Virtual Machines
|
||||
|
||||
![][12]
|
||||
|
||||
While their use cases already give you an idea of the benefits they give you, let me add some pointers for you to know better:
|
||||
|
||||
* Virtual Machines let you use the hardware resources fully without tampering with the host.
|
||||
* With VMs, you get the freedom to test or break whatever you want. Whether it is a super old application or a risky software, you can rely on the VM to do it all without affecting your host.
|
||||
* You can run multiple operating systems from a single place without needing the hassle of dual-boot or adding extra physical drives to use other operating systems. Thereby saving you cost, time, and management trouble.
|
||||
* With VMs, you can clone your configurations quickly without needing additional hardware.
|
||||
|
||||
|
||||
|
||||
### Disadvantages of Virtual Machines
|
||||
|
||||
![][13]
|
||||
|
||||
Considering VMs are helpful in many scenarios, how can they be harmful?
|
||||
|
||||
Well, not precisely drawbacks to using them, but you need to be cautious about some of the things they can do:
|
||||
|
||||
* Even though virtual machines are known to use resources efficiently, they can still overwhelm the system resources if you do not monitor them or run multiple VMs without thinking about it.
|
||||
* Virtual Machines can never replace bare metal experience and performance. No matter how mighty the host is, VMs run slower than you would expect with a physical computer.
|
||||
* Virtual Machines are isolated from the host, but you must be careful about file sharing that might expose malware to your host system.
|
||||
|
||||
|
||||
|
||||
### Virtual Machines Are Super Useful
|
||||
|
||||
The concept of VMs made a lot of things happen.
|
||||
|
||||
What do you think would have happened to the cloud computing industry? How inconvenient would it be to always re-install operating systems to try a different one?
|
||||
|
||||
💬 _In one form or the other, every computer user or server user does need it. What are your thoughts on a virtual machine? How would you define it?_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/virtual-machine/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/content/images/2023/08/windows-without-menu.png
|
||||
[2]: https://itsfoss.com/content/images/2023/06/origin.png
|
||||
[3]: https://itsfoss.com/content/images/2023/06/vm.png
|
||||
[4]: https://itsfoss.com/virtualization-software-linux/
|
||||
[5]: https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png
|
||||
[6]: https://itsfoss.com/content/images/2023/06/vm-vs-physical-computer.png
|
||||
[7]: https://itsfoss.com/why-linux-virtual-machine/
|
||||
[8]: https://itsfoss.com/content/images/2023/06/why-we-use-vm.png
|
||||
[9]: https://www.linux-kvm.org/page/Main_Page?ref=itsfoss.com
|
||||
[10]: https://www.virtualbox.org/?ref=itsfoss.com
|
||||
[11]: https://aws.amazon.com/what-is/virtualization/?ref=itsfoss.com
|
||||
[12]: https://itsfoss.com/content/images/2023/08/advantage.png
|
||||
[13]: https://itsfoss.com/content/images/2023/08/disadvantage.png
|
Loading…
Reference in New Issue
Block a user