逸之

V1

2022/01/07阅读:53主题:红绯

VM

Virtual Machine 虚拟机

A virtual machine is what the name suggests: a machine running virtually inside another machine. With virtual machines, there are two operating systems involved: the host operating system (OS) and the guest OS. The host is your own native OS (maybe Windows). The guest is the OS that runs inside the host.

虚拟机正如其名字所暗示的那样: 虚拟机在另一台机器中运行。对于虚拟机,涉及两个操作系统: 主机操作系统(OS)和客户操作系统(guest OS)。主机是你自己的本地操作系统(也许是 Windows)。来宾操作系统是在主机内部运行的操作系统。

The virtual machine (VM) we provide here has OCaml pre-installed in an Ubuntu guest OS. Ubuntu is a free Linux OS, and is an ancient African word meaning "humanity to others". The process we use to create the VM is documented here.

我们在这里提供的虚拟机(VM)已经在 Ubuntu guest OS 中预安装了 OCaml。Ubuntu 是一个免费的 Linux 操作系统,是一个古老的非洲词汇,意思是“人性对他人”。我们用来创建 VM 的过程在这里有文档说明。

Installing the VM 安装虚拟机

  • Download and install Oracle's free VirtualBox for your host OS. Or, if you already had it installed, make sure you update to the latest version of VirtualBox before proceeding.

    为你的主机操作系统下载并安装 Oracle 的免费 VirtualBox。或者,如果您已经安装了它,请确保在继续之前更新到最新版本的 VirtualBox。

  • Download our VM. Don’t worry about the “We’re sorry, the preview didn’t load” message you see. Just click the Download button and save the .ova file wherever you like. It’s about a 6GB file, so the download might take awhile.

    下载我们的 VM。不要担心你看到的“我们很抱歉,预览没有加载”消息。只需点击下载按钮并保存。随便你放哪儿都行。它大约有6gb 的文件,所以下载可能需要一段时间。

  • Launch VirtualBox, select File → Import Appliance, and choose the .ova file you just downloaded. Click Next, then Import.

    启动 VirtualBox,选择 File → Import Appliance,然后选择刚刚下载的.ova 文件,单击 Next,然后导入。

Starting the VM 启动虚拟机

  • Select cs3110-2021fa-ubuntu from the list of machines in VirtualBox. Click Start. At this point various errors can occur that depend on your hardware, hence are hard to predict.

    从 VirtualBox 中的机器列表中选择 cs3110-2021fa-ubuntu。点击开始。此时,可能会发生各种依赖于硬件的错误,因此很难预测。

    • If you get an error about “VT-x/AMD-V hardware acceleration”, you most likely need to access your computer’s BIOS settings and enable virtualization. The details of that will vary depending on the model and manufacturer of your computer. Try googling "enable virtualization ", substituting for the manufacturer and model of your machine. This Red Hat Linux page might also help.

      如果出现“ VT-x/AMD-V 硬件加速”错误,很可能需要访问计算机的 BIOS 设置并启用虚拟化。具体细节将根据您的计算机的型号和制造商而有所不同。尝试谷歌“启用虚拟化”,代替你的机器的制造商和模型。这个 Red Hat Linux 页面可能也会有帮助。

    • If the machine just freezes or blacks out or aborts, you might need to adjust the memory provided to it by your host OS. Select the VM in Virtual Box, click Settings, and look at the System and Display settings. You might need to adjust the Base Memory (under System → Motherboard) or the Video Memory (under Display → Screen). Those sliders have color coding underneath them to indicate what good amounts might be on your computer. Make sure nothing is in the red zone, and try some lower or higher settings to see if they help. If the sliders are greyed out and won't permit adjustment, it means the VM is still running: you can't change the amount of memory while the guest OS is active; so, shut down the VM (see below) and try again.

      如果机器只是冻结、黑屏或中止,您可能需要调整您的主机操作系统提供给它的内存。在“虚拟框”中选择虚拟机,单击“设置”,然后查看“系统和显示”设置。您可能需要调整基本内存(在系统→主板下)或视频内存(在显示→屏幕下)。这些滑块下面有颜色编码,以表明你的电脑上可能有多少钱。确保没有任何东西在红色区域,尝试一些低或高的设置,看看是否有帮助。如果滑块是灰色的,不允许调整,这意味着 VM 仍在运行: 您不能在客户操作系统处于活动状态时更改内存量; 因此,关闭 VM (见下文)并重试。

    • If you have a monitor with high pixel density (e.g., an Apple Retina display), the VM window might be incredibly tiny. In VirtualBox go to Settings → Display → Scale Factor and increase it as needed, perhaps to 200%.

      如果你有一个高像素密度的显示器(比如苹果的 Retina 显示器) ,那么 VM 窗口可能非常小。在 VirtualBox 中进入设置→显示→缩放因子,并根据需要增加它,可能增加到200% 。

  • The VM will log you in automatically. The username is camel and the password is camel. To change your password, run passwd from the terminal and follow the prompts. If you’d rather have your own username, you are welcome to go to Settings → Users to create a new account. Just be aware that OPAM and VS Code won’t be installed for that user. You'll need to follow the install instructions to add them.

    虚拟机会自动让你登录。用户名为 camel,密码为 camel。若要更改密码,请从终端运行 passwd 并按照提示操作。如果你想拥有自己的用户名,欢迎你到设置→用户创建一个新帐户。请注意,不会为该用户安装 OPAM 和 VS 代码。您需要按照安装说明添加它们。

Stopping the VM 停止虚拟机

You can use Ubuntu's own menus to safely shutdown or reboot the VM. But more often you will likely use VirtualBox to close the VM by clicking the VM window’s "X" icon in the host OS. Then you will be presented with three options that VirtualBox doesn't explain very well:

你可以使用 Ubuntu 自己的菜单来安全地关闭或者重启虚拟机。但更多情况下,您可能会使用 VirtualBox 单击主机操作系统中 VM 窗口的“ x”图标来关闭 VM。然后你会看到3个 VirtualBox 没有解释清楚的选项:

  • Save the machine state. This option is what you normally want. It’s like closing the lid on your laptop: it puts it to sleep, and it can quickly wake.

    保存计算机状态。这个选项通常是您想要的。这就像关上你笔记本电脑的盖子: 它让它进入睡眠状态,然后它可以迅速苏醒。

  • Send the shutdown signal. This option is like shutting down a machine you don’t intend to use for a long time, or before unplugging a desktop machine from the wall. When you start the machine again later, it will have to boot from scratch, which takes longer.

    发送关闭信号。这个选项类似于关闭一台长时间不打算使用的机器,或者在将台式机从墙上拔下之前关闭它。当您以后再次启动机器时,它将不得不从头开始启动,这需要更长的时间。

  • Power off the machine. This option is dangerous. It is the equivalent of pulling the power cord of a desktop machine from the wall while the machine is still running: it causes the operating system to suddenly quit without doing any cleanup. Doing this even just a handful of times could cause the file system to become corrupted, which will cause you to lose all your work and have to reinstall the VM from scratch. You will be very unhappy. So, avoid this option.

    关掉机器。这种选择是危险的。这相当于在机器仍在运行时从墙上拉下台式机的电源线: 它导致操作系统突然退出,而不做任何清理。即使只是几次这样做,也可能导致文件系统损坏,这将导致您丢失所有工作,不得不从头开始重新安装 VM。你会很不开心的。所以,避免这种选择。

Using the VM 使用虚拟机

  • There are icons provided for the terminal, VS Code, and the Firefox web browser. They are in the left-hand launcher bar.

    有图标提供的终端,VS 代码,和 Firefox 的网页浏览器。他们在左边的发射台酒吧。

  • It can be helpful to set up a shared folder between the host and guest OS, so that you can easily copy files between them. With the VM shutdown (i.e., select “send the shutdown signal”), click Settings, then click Shared Folders. Click the little icon on the right that looks like a folder with a plus sign. In the dialog box for Folder Path, select Other, then navigate to the folder on your host OS that you want to share with the guest OS. Let’s assume you created a new folder named vmshared inside your Documents folder, or wherever you like to keep files. The Folder Name in the dialog box will automatically be filled with vmshared. This is the name by which the guest OS will know the folder. You can change it if you like. Check Auto-mount; do not check Read-only. Make the Mount Point /home/camel/vmshared. Click OK, then click OK again. Start the VM again. You should now have a subdirectory named vmshared in your guest OS home directory that is shared between the host OS and the guest OS.

    在主机和客户操作系统之间设置一个共享文件夹会很有帮助,这样您就可以轻松地在它们之间复制文件。关闭 VM (即,选择“发送关闭信号”)后,单击“设置”,然后单击“共享文件夹”。点击右边的小图标,它看起来像一个带有加号的文件夹。在“文件夹路径”对话框中,选择“其他”,然后导航到要与客户操作系统共享的主机操作系统上的文件夹。让我们假设您在 Documents 文件夹中创建了一个名为 vmshared 的新文件夹,或者您希望保存文件的任何地方。对话框中的文件夹名称将自动填充 vmshared。这是客户操作系统知道文件夹的名称。如果你愿意,你可以改变它。检查自动安装,不要检查只读。设置 Mount Point/home/camel/vmshared。单击确定,然后再次单击确定。重新启动虚拟机。您现在应该在贵宾操作系统主目录中有一个名为 vmshared 的子目录,它在主机操作系统和贵宾操作系统之间共享。

  • You might be able to improve the performance of your VM by increasing the amount of memory or CPUs allocated to it, though it depends on how much your actual machine has available and what else you have running at the same time. With the VM shut down, try going in Virtual Box to Settings → System, and tinkering with the Base Memory slider on the Motherboard tab, and the Processors slider on the Processor tab. Then bring up the VM again and see how it does. You might have to play around to find a sweet spot. Later, after you are satisfied the VM is working properly hence you won't have to re-import it, you can safely delete the .ova file you downloaded to free up some space.

    您可以通过增加分配给 VM 的内存或 cpu 的数量来提高 VM 的性能,但这取决于实际机器有多少可用内存和同时运行的其他内存。当虚拟机关闭,尝试进入虚拟机到设置→系统,修补主板标签上的基本内存滑块,处理器标签上的处理器滑块。然后再次调出 VM,看看效果如何。你可能不得不四处寻找一个最佳位置。稍后,当您满意 VM 正常工作时,因此您不必重新导入它,您可以安全地删除。你下载的 ova 文件,来腾出一些空间。

分类:

后端

标签:

后端

作者介绍

逸之
V1