Merge pull request #27 from LCTT/master

update 0927
This commit is contained in:
SamMa 2021-09-27 08:53:55 +08:00 committed by GitHub
commit 97b899a7f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 241 additions and 184 deletions

View File

@ -3,68 +3,67 @@
[#]: author: "Don Watkins https://opensource.com/users/don-watkins"
[#]: collector: "lujun9972"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "turbokernel"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-13822-1.html"
使用这个 Linux 命令行工具来了解你的 NVMe 驱动器的更多信息
使用 Linux 命令行工具来了解你的 NVMe 驱动器
======
nvme-cli 命令有很多有用的选项,且它是一个很好的方式来控制你如何管理你的数据。
![Command line prompt][1]
NVMe 是指 _Non-Volatile Memory_(非易失性内存主机控制器接口规范),它指的是软件和存储如何通过 PCIe 和其他协议(包括 TCP进行通信。它是一个由非营利组织领导的[开放规范][2],并定义了几种形式的固态存储
> nvme-cli 命令拥有诸多实用的选项,且它是控制和管理数据一种很好的方式。
我的笔记本电脑有一个 NVMe 驱动器,我的台式机也有。而且它们的速度很快。我喜欢我的电脑启动的速度,以及它们读写数据的速度。没有可察觉的延迟。
![](https://img.linux.net.cn/data/attachment/album/202109/26/102441ux8cy36gy1vggykz.jpg)
没过多久我就对驱动这种超高速存储的技术产生了好奇所以我做了一些调查。我了解到NVMe 驱动器消耗的电力更少,而提供的数据访问速度甚至比 SATA 的 SSD 驱动器快得多。这很有趣,但我想知道更多关于我的特定 NVMe 驱动器的信息,我想知道它们与其他驱动器相比如何。我可以安全地擦除驱动器吗?我怎样才能检查它的完整性?
NVMe 是指<ruby>非易失性内存规范<rt>Non-Volatile Memory Express</rt></ruby>,它规范了软件和存储通过 PCIe 和其他协议(包括 TCP进行通信的方式。它是由非营利组织领导的 [开放规范][2],并定义了几种形式的固态存储。
这些问题让我在互联网上搜索,发现了一个开源项目,其中有一系列管理 NVMe 驱动器的工具。它被称为 [nvme-cli][3]。
我的笔记本电脑有一个 NVMe 驱动器,我的台式机也有。而且它们的速度很快。我喜欢我的电脑启动的速度,以及它们读写数据的速度。几乎没有延迟。
没过多久我就对驱动这种超高速存储的技术产生了好奇所以我做了一些调查。我了解到NVMe 驱动器消耗的电力更少,而提供的数据访问速度甚至比 SATA 的 SSD 驱动器快得多。这很有趣,但我想知道更多关于我的特定 NVMe 驱动器的信息,我想知道它们与其他驱动器有何区别。我可以安全地擦除驱动器吗?我怎样才能检查它的完整性?
带着这些问题我在互联网上搜索,发现了一个开源项目,其中有一系列管理 NVMe 驱动器的工具。它被称为 [nvme-cli][3]。
### 安装 nvme-cli
你可以从你的发行版的包管理器中安装 `nvme-cli`。例如,在 Fedora、CentOS 或类似系统上:
```
`$ sudo dnf install nvme-cli`
$ sudo dnf install nvme-cli
```
在 Debian、Mint、Elementary 和类似系统上:
```
`$ sudo apt install nvme-cli`
$ sudo apt install nvme-cli
```
### 探索 NVMe 驱动器
在为我的发行版安装 `nvme-cli` 后,我想探索我的驱动器。`nvme-cli` 没有手册页,但你可以通过输入 `nvme help` 获得很多帮助:
在安装 `nvme-cli` 后,我想探索我的驱动器。`nvme-cli` 没有手册页,但你可以通过输入 `nvme help` 获得很多帮助:
```
$ nvme help
nvme-1.14
usage: nvme &lt;command&gt; [&lt;device&gt;] [&lt;args&gt;]
usage: nvme <command> [<device>] [<args>]
The '&lt;device&gt;' may be either an NVMe character device (ex: /dev/nvme0) or an
The '<device>' may be either an NVMe character device (ex: /dev/nvme0) or an
nvme block device (ex: /dev/nvme0n1).
The following are all implemented sub-commands:
list List all NVMe devices and namespaces on machine
list-subsys List nvme subsystems
id-ctrl Send NVMe Identify Controller
id-ns Send NVMe Identify Namespace, display structure
id-ns-granularity Send NVMe Identify Namespace Granularity List, display structure
list-ns Send NVMe Identify List, display structure
list-ctrl Send NVMe Identify Controller List, display structure
nvm-id-ctrl Send NVMe Identify Controller NVM Command Set, display structure
primary-ctrl-caps Send NVMe Identify Primary Controller Capabilities
list List all NVMe devices and namespaces on machine
list-subsys List nvme subsystems
id-ctrl Send NVMe Identify Controller
id-ns Send NVMe Identify Namespace, display structure
id-ns-granularity Send NVMe Identify Namespace Granularity List, display structure
list-ns Send NVMe Identify List, display structure
list-ctrl Send NVMe Identify Controller List, display structure
nvm-id-ctrl Send NVMe Identify Controller NVM Command Set, display structure
primary-ctrl-caps Send NVMe Identify Primary Controller Capabilities
[...]
```
### 列出所有的 NVMe 驱动器
`sudo nvme list` 命令列出你机器上所有的 NVMe 设备和命名空间。我用它在 `/dev/nvme0n1` 找到了一个 NVMe 驱动器。下面是输出结果:
`sudo nvme list` 命令列出你机器上所有的 NVMe 设备和命名空间。我用它在 `/dev/nvme0n1` 找到了一个 NVMe 驱动器。下面是命令输出结果:
```
@ -72,18 +71,17 @@ $ sudo nvme list
Node SN Model Namespace Usage Format FW Rev
\--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 S42GMY9M141281 SAMSUNG MZVLB256HAHQ-000L7 1
/dev/nvme0n1 S42GMY9M141281 SAMSUNG MZVLB256HAHQ-000L7 1
214.68 GB / 256.06 GB 512 B + 0 B 0L2QEXD7
214.68 GB / 256.06 GB 512 B + 0 B 0L2QEXD7
```
我有一个名为 `nvme0n1` 的驱动器。它列出了序列号、品牌、尺寸、固件版本等等。
我有一个名为 `nvme0n1` 的驱动器。它列出了序列号、品牌、容量、固件版本等等。
通过使用 `id-ctrl` 子命令,你可以得到更多关于该硬盘和它所支持的特性的信息:
```
$ sudo nvme id-ctrl /dev/nvme0n1
NVME Identify Controller:
@ -107,7 +105,6 @@ rtd3e : 0x7a1200
你可以通过 `smart-log` 子命令来了解硬盘的整体健康状况:
```
$ sudo nvme smart-log /dev/nvme0n1
Smart Log for NVME device:nvme0n1 namespace-id:ffffffff
@ -143,25 +140,23 @@ Thermal Management T2 Total Time : 0
你可以用 `nvme-cli` 格式化一个 NVMe 驱动器,但要注意。这将删除驱动器上的所有数据!如果你的硬盘上有重要的数据,你必须在这样做之前将其备份,否则你**将会**丢失数据。子命令是 `format`
```
`$ sudo nvme format /dev/nvme0nX`
$ sudo nvme format /dev/nvme0nX
```
(为了安全起见,我用 **X** 替换了驱动器的实际位置,以防止复制粘贴的错误。将 **X** 改为 **1**`nvme list` 结果中列出的适当位置)。
(为了安全起见,我用 `X` 替换了驱动器的实际位置,以防止复制粘贴的错误。将 `X` 改为 `1``nvme list` 结果中列出的实际位置。)
### 安全地擦除 NVMe 驱动器
当你准备出售或处理你的 NVMe 电脑时,你可能想安全地擦除驱动器。这里的警告与格式化过程中的警告相同。首先要备份重要的数据,因为这个命令会删除这些数据!
```
`$ sudo nvme sanitize /dev/nvme0nX`
$ sudo nvme sanitize /dev/nvme0nX
```
### 尝试 nvme-cli
`nvme-cli` 命令是在 [GPLv2][4] 许可下发布的。它是一个强大的命令,有很多有用的选项,它是控制你如何管理数据的好方法
`nvme-cli` 命令是在 [GPLv2][4] 许可下发布的。它是一个强大的命令,有很多有用的选项,用来有效地控制和管理数据
--------------------------------------------------------------------------------
@ -170,7 +165,7 @@ via: https://opensource.com/article/21/9/nvme-cli
作者:[Don Watkins][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[turbokernel](https://github.com/turbokernel)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,142 +0,0 @@
[#]: subject: "Use Vagrant to test your scripts on different operating systems"
[#]: via: "https://opensource.com/article/21/9/test-vagrant"
[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma"
[#]: collector: "lujun9972"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Use Vagrant to test your scripts on different operating systems
======
Vagrant helps you run other operating systems on your computer—meaning
you can build things, test things, and do wacky stuff without blowing up
your own system.
![Business woman on laptop sitting in front of window][1]
I've been happy using Vagrant for quite a while now. I work with several DevOps tools, and installing them all on one system can get complicated. Vagrant lets you do cool things without breaking your system because you don't have to experiment on your production system at all.
If you're familiar with [VirtualBox][2] or [GNOME Boxes][3], then learning Vagrant is easy. Vagrant is a simple and clean interface for working with virtual machines. A single config file, called `Vagrantfile`, allows you to customize your virtual machines (called _Vagrant boxes_). A simple command-line interface lets you start, stop, suspend, or destroy your boxes.
Consider this simple example.
Let's say you want to write Ansible or shell scripts to install Nginx on a new server. You can't do it on your own system because you might not be running the operating system you want to test, or you may not have all of the dependencies for what you want to do. Launching new cloud servers for testing can be time-consuming and expensive. This is where Vagrant comes in. You can use it to bring up a virtual machine, provision it using your scripts, and prove that everything works as expected. You can then delete the box, re-provision it, and re-run your scripts to verify it. You can repeat this process as many times as you want until you're confident your scripts work under all conditions. And you can commit your Vagrantfile to Git to ensure your team is testing the exact same environment (because they'll be using the exact same test box). No more "…but it works fine on my machine!"
### Getting started
First, [install Vagrant on your system][4] and then create a new folder to experiment in. In this new folder, create a new file named `Vagrantfile` with these contents:
```
Vagrant.configure("2") do |config|
 
  config.vm.box = "ubuntu/hirsute64"
 
end
```
You can also run `vagrant init ubuntu/hirsute64`, and it will generate a new Vagrantfile for you. Now run `vagrant up`. This command will download the `ubuntu/hirsuite64` image from the Vagrant registry.
```
Bringing machine 'default' up with 'virtualbox' provider...
==&gt; default: Importing base box 'ubuntu/hirsute64'...
==&gt; default: Matching MAC address for NAT networking...
==&gt; default: Checking if box 'ubuntu/hirsute64' version '20210820.0.0' is up to date...
==&gt; default: Setting the name of the VM: a_default_1630204214778_76885
==&gt; default: Clearing any previously set network interfaces...
==&gt; default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==&gt; default: Forwarding ports...
    default: 22 (guest) =&gt; 2222 (host) (adapter 1)
==&gt; default: Running 'pre-boot' VM customizations...
==&gt; default: Booting VM...
==&gt; default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==&gt; default: Machine booted and ready!
```
At this point, if you open your Vagrant backend (such as VirtualBox or virt-manager), you'll see your box there. Next, run `vagrant ssh` to log in to the box. If you can see the Vagrant prompt, then youre in!
```
~ vagrant ssh
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-31-generic x86_64)
 * Documentation:  <https://help.ubuntu.com>
 * Management:     <https://landscape.canonical.com>
 * Support:        <https://ubuntu.com/advantage>
  System information as of Sun Aug 29 02:33:51 UTC 2021
  System load:  0.01              Processes:               110
  Usage of /:   4.1% of 38.71GB   Users logged in:         0
  Memory usage: 17%               IPv4 address for enp0s3: 10.0.2.15
  Swap usage:   0%                IPv4 address for enp0s8: 192.168.1.20
0 updates can be applied immediately.
vagrant@ubuntu-hirsute:~$
```
Vagrant uses "base boxes" to bring up your local machines. In our case, Vagrant downloads the `ubuntu/hirsuite64` image from [Hashicorps Vagrant catalogue][5] and plugs into VirtualBox to create the actual box.
### Shared folders
Vagrant maps your current folder as `/vagrant` within the Vagrant box. This allows you to keep your files in sync on your system and within the box. This is great for testing a Nginx website by pointing your document root to `/vagrant`. You can use an IDE to make changes and Nginx within the box will serve them.
### Vagrant commands
There are several Vagrant commands which you can use to control your box.
Some of the important ones are:
* `vagrant up`: Bring a box online.
* `vagrant status`: Show current box status.
* `vagrant suspend`: Pause the current box.
* `vagrant resume`: Resume the current box.
* `vagrant halt`: Shutdown the current box.
* `vagrant destroy`: Destroy the current box. By running this command, you will lose any data stored on the box.
* `vagrant snapshot`: Take a snapshot of the current box.
### Try Vagrant
Vagrant is a time-tested tool for virtual machine management using DevOps principles. Configure your test machines, share the configs with your team, and test your projects in a predictable and reproducible environment. If you're developing software, then you'll do your users a great service by using Vagrant for testing. If you're not developing software but you love to try out new versions of an OS, then there's no easier way. Try Vagrant today!
* * *
_This article was originally published on the [author's personal blog][6] and has been adapted with permission._
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/9/test-vagrant
作者:[Ayush Sharma][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://opensource.com/users/ayushsharma
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating)
[2]: https://opensource.com/article/21/6/try-linux-virtualbox
[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization
[4]: https://www.vagrantup.com/docs/installation
[5]: https://app.vagrantup.com/boxes/search
[6]: https://notes.ayushsharma.in/2021/08/introduction-to-vagrant

View File

@ -2,7 +2,7 @@
[#]: via: "https://itsfoss.com/install-anydesk-ubuntu/"
[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/"
[#]: collector: "lujun9972"
[#]: translator: " "
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "

View File

@ -0,0 +1,63 @@
[#]: subject: "6 open source tools for orchestral composers"
[#]: via: "https://opensource.com/article/21/9/open-source-orchestral-composers"
[#]: author: "Pete Savage https://opensource.com/users/psav"
[#]: collector: "lujun9972"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
6 open source tools for orchestral composers
======
Think it's impossible to compose orchestral tracks with just open source
software? Think again.
![Sheet music with geometry graphic][1]
As an avid amateur musician, I've worked with many different software programs to create both simple and complex pieces. As my projects have grown in scope, I've used composition software ranging from basic engraving to MIDI-compatible notation to playback of multi-instrument works. Composers have their choice of proprietary software, but I wanted to prove that, regardless of the need, there is an open source tool that will more than satisfy them.
### Music engraving programs
When my needs were simple and my projects few, I used the excellent resource [Lilypond][2], part of the GNU project, for engraving my music score. Lilypond is a markup language used to create sheet music. What looks like a mass of letters and numbers on the screen becomes a beautiful music score that can be exported as a PDF to share with all your musical acquaintances. For creating small snippets of a score, Lilypond performs excellently.
Using a text markup language might be a tolerable experience for a software engineer, but waiting to save and run the renderer before seeing the result of your edit can be frustrating. [Frescobaldi][3] is an effective solution to this problem, allowing you to work in a text editor on the left and see a live preview updating on the right. For small scores, this works well. For larger scores, however, the render time can make for a painful experience. Though Frescobaldi has a built-in MIDI-style player, hooking it up to play something requires both knowledge of [JACK][4] (an audio connection API) and a user interface such as [qSynth][5]. For me, Frescobaldi is best for projects when I already know what the score looks like. It's not a composing tool; it's an engraving tool.
### Music notation programs
A few months ago, I started creating a songbook for my former band. For this project, I needed to add chord diagrams, guitar tablature, and multiple staves, so I moved over to [Denemo.][6] Denemo is a fabulously configurable tool that uses LilyPond as its rendering backend. The key benefit to Denemo is the ability to enter notes on a stave. The stave you enter notes on might not look exactly like the score will appear on rendering—in fact, it almost certainly won't. However, in most cases, it's far easier to enter the notes directly on a stave than to write them in a text markup language.
Denemo served me well when creating my songbook, but I had greater ambitions. When I started composing a few piano and small ensemble pieces, I could have handled these in Denemo, but I decided to try [MuseScore][7] to compare the programs. Though MuseScore doesn't use a text-based markup language like Lilypond, it has many other benefits over the LilyPond-based offerings, such as single-note dynamics and rendering out to WAV or MP3.
In my latest project, I took a piano concept I wrote for a fictional role-playing game (RPG) and turned it into a full orchestral version. MuseScore was fantastic for this. The program definitely became part of my composing process, and it would have been much more difficult for me to arrange 18 instruments in LilyPond than in MuseScore. I was also able to hear single-note dynamics, such as a single violin note moving from silence to loud and back. I do not know of any editors for Lilypond that allow for this.
#### Piano Concept
#### Orchestral Concept
### Going beyond the score
My next task will be to take the MIDI from this project and code it into a Digital Audio Workstation (DAW), such as [Ardour][8]. The difference between the audio output from MuseScore and something created with a DAW is that a DAW allows much more than single-note dynamics. Expression, volume, and other parameters can be adjusted in time, allowing for a more realistic sound, assuming the instrument can handle it. I'm currently working on packaging up [sFizz][9] for Fedora. sFizz is an SFZ instrument VST plugin that can be used in an open source DAW and has fantastic support for the different expressions I'd like to use in my piece.
The ultimate aim of this project is to show that open source tooling can be used to create an orchestral track that sounds authentic. Think it's impossible to make realistic-sounding orchestral tracks just with open source software? That's for next time.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/9/open-source-orchestral-composers
作者:[Pete Savage][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://opensource.com/users/psav
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sheet_music_graphic.jpg?itok=t-uXNbzE (Sheet music with geometry graphic)
[2]: https://lilypond.org/
[3]: https://frescobaldi.org/
[4]: https://jackaudio.org/
[5]: https://qsynth.sourceforge.io/
[6]: http://www.denemo.org/
[7]: https://musescore.org/en
[8]: https://ardour.org/
[9]: https://sfz.tools/sfizz/

View File

@ -0,0 +1,141 @@
[#]: subject: "Use Vagrant to test your scripts on different operating systems"
[#]: via: "https://opensource.com/article/21/9/test-vagrant"
[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma"
[#]: collector: "lujun9972"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
使用 Vagrant 在不同的操作系统上测试你的脚本
======
Vagrant 可以帮助你在你的电脑上运行其他操作系统,这意味着你可以构建、测试、做古怪的事情而不毁坏你的系统。
![Business woman on laptop sitting in front of window][1]
我使用 Vagrant 已经很长时间了。我使用几种 DevOps 工具在一个系统上安装它们可能会变得很复杂。Vagrant 让你在不破坏系统的情况下做一些很酷的事情,因为你根本不需要在生产系统上做实验。
如果你熟悉 [VirtualBox][2] 或 [GNOME Boxes][3],那么学习 Vagrant 很容易。Vagrant 有一个简单而干净的界面用于处理虚拟机。一个名为 `Vagrantfile` 的配置文件,允许你定制你的虚拟机(称为 _Vagrant boxes_)。一个简单的命令行界面让你启动、停止、暂停或销毁你的 box。
考虑一下这个简单的例子。
假设你想写 Ansible 或 shell 脚本,在一个新的服务器上安装 Nginx。你不能在自己的系统上这样做因为你可能没有运行想测试的操作系统或者可能没有你想做的所有依赖项。启动新的云服务器进行测试可能会很费时和昂贵。这就是 Vagrant 派上用处的地方。你可以用它来启动一个虚拟机,用你的脚本来配置它,并证明一切按预期工作。然后,你可以删除这个 box重新配置它并重新运行你的脚本来验证它。你可以多次重复这个过程直到你确信你的脚本在所有条件下都能工作。你可以将你的 Vagrant 文件提交给 Git以确保你的团队正在测试完全相同的环境因为他们将使用完全相同的测试机。不再有“但它在我的机器上运行良好”这事了。
### 开始使用
First,[install Vagrant on your system][4]and then create a new folder to experiment in. In this new folder, create a new file namedwith these contents:
首先,[在你的系统上安装 Vagrant][4],然后创建一个新的文件夹进行实验。在这个新文件夹中,创建一个名为 `Vagrantfile` 的新文件,内容如下:
```
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/hirsute64"
end
```
你也可以运行 `vagrant init ubuntu/hirsute64`,它将为你生成一个新的 Vagrant 文件。现在运行 `vagrant up`。这个命令将从 Vagrant 仓库中下载 `ubuntu/hirsuite64` 镜像。
```
Bringing machine 'default' up with 'virtualbox' provider...
==&gt; default: Importing base box 'ubuntu/hirsute64'...
==&gt; default: Matching MAC address for NAT networking...
==&gt; default: Checking if box 'ubuntu/hirsute64' version '20210820.0.0' is up to date...
==&gt; default: Setting the name of the VM: a_default_1630204214778_76885
==&gt; default: Clearing any previously set network interfaces...
==&gt; default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==&gt; default: Forwarding ports...
default: 22 (guest) =&gt; 2222 (host) (adapter 1)
==&gt; default: Running 'pre-boot' VM customizations...
==&gt; default: Booting VM...
==&gt; default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection reset. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==&gt; default: Machine booted and ready!
```
此时,如果你打开你的 Vagrant 后端(如 VirtualBox 或 virt-manager你会看到你的 box 在那里。接下来,运行 `vagrant ssh` 登录到 box。如果你能看到 Vagrant 的提示,那么你就进入了!
```
~ vagrant ssh
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-31-generic x86_64)
* Documentation: <https://help.ubuntu.com>
* Management: <https://landscape.canonical.com>
* Support: <https://ubuntu.com/advantage>
System information as of Sun Aug 29 02:33:51 UTC 2021
System load: 0.01 Processes: 110
Usage of /: 4.1% of 38.71GB Users logged in: 0
Memory usage: 17% IPv4 address for enp0s3: 10.0.2.15
Swap usage: 0% IPv4 address for enp0s8: 192.168.1.20
0 updates can be applied immediately.
vagrant@ubuntu-hirsute:~$
```
Vagrant 使用“基础 box” 来启动你的本地机器。在我们的例子中Vagrant 从 [Hashicorp 的 Vagrant 目录][5]下载 `ubuntu/hirsuite64` 镜像,并插入 VirtualBox 来创建实际的 box。
### 共享文件夹
Vagrant 将你的当前文件夹映射到 Vagrant box 中的 `/vagrant`。这允许你在你的系统和 box 里保持文件同步。这对于测试 Nginx 网站是很好的,通过将你的文件根目录指向 `/vagrant`。你可以使用 IDE 进行修改box 里的 Nginx 会提供这些修改。
### Vagrant 命令
有几个 Vagrant 命令,你可以用它们来控制你的 box。
其中一些重要的命令是:
* `vagrant up`:启动一个 box。
* `vagrant status`:显示当前 box 的状态。
* `vagrant suspend`:暂停当前的 box。
* `vagrant resume`:恢复当前的 box。
* `vagrant halt`:关闭当前的 box。
* `vagrant destroy`:销毁当前的 box。通过运行此命令你将失去存储在 box 上的任何数据。
* `vagrant snapshot`:对当前的 box 进行快照。
### 试试 Vagrant
Vagrant 是一个使用 DevOps 原则进行虚拟机管理的经过时间考验的工具。配置你的测试机,与你的团队分享配置,并在一个可预测和可重复的环境中测试你的项目。如果你正在开发软件,那么通过使用 Vagrant 进行测试,你将为你的用户提供良好的服务。如果你不开发软件,但你喜欢尝试新版本的操作系统,那么没有比这更简单的方法了。今天就试试 Vagrant 吧!
* * *
_这篇文章最初发表在[作者的个人博客][6]上经许可后被改编。_
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/9/test-vagrant
作者:[Ayush Sharma][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ayushsharma
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating)
[2]: https://opensource.com/article/21/6/try-linux-virtualbox
[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization
[4]: https://www.vagrantup.com/docs/installation
[5]: https://app.vagrantup.com/boxes/search
[6]: https://notes.ayushsharma.in/2021/08/introduction-to-vagrant