Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-04-27 12:39:46 +08:00
commit 382baf8fb3
8 changed files with 210 additions and 209 deletions

View File

@ -1,16 +1,16 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10778-1.html)
[#]: subject: (How to Zip Files and Folders in Linux [Beginner Tip])
[#]: via: (https://itsfoss.com/linux-zip-folder/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何在 Linux 中 zip 压缩文件和文件夹(初学者提示)
初级:如何在 Linux 中 zip 压缩文件和文件夹
======
_ **简介:本文向你展示了如何在 Ubuntu 和其他 Linux 发行版中创建一个 zip 文件夹。终端和 GUI 方法都有。** _
> 本文向你展示了如何在 Ubuntu 和其他 Linux 发行版中创建一个 zip 文件夹。终端和 GUI 方法都有。
zip 是最流行的归档文件格式之一。使用 zip你可以将多个文件压缩到一个文件中。这不仅节省了磁盘空间还节省了网络带宽。这就是为什么你几乎一直会看到 zip 文件的原因。
@ -18,7 +18,7 @@ zip 是最流行的归档文件格式之一。使用 zip你可以将多个文
**先决条件:验证是否安装了 zip**
通常 [zip][1] 已经安装,但验证下也没坏处。你可以运行以下命令来安装 zip 和 unzip。如果它尚未安装它将立即安装。
通常 [zip][1] 已经安装,但验证下也没坏处。你可以运行以下命令来安装 `zip``unzip`。如果它尚未安装,它将立即安装。
```
sudo apt install zip unzip
@ -30,7 +30,7 @@ sudo apt install zip unzip
### 在 Linux 命令行中压缩文件夹
zip 命令的语法非常简单。
`zip` 命令的语法非常简单。
```
zip [option] output_file_name input1 input2
@ -42,7 +42,7 @@ zip [option] output_file_name input1 input2
zip -r output_file.zip file1 folder1
```
-r 选项将递归目录并压缩其内容。输出文件中的 .zip 扩展名是可选的,因为默认情况下会添加 .zip。
`-r` 选项将递归目录并压缩其内容。输出文件中的 .zip 扩展名是可选的,因为默认情况下会添加 .zip。
你应该会在 zip 操作期间看到要添加到压缩文件夹中的文件。
@ -55,13 +55,13 @@ zip -r myzip abhi-1.txt abhi-2.txt sample_directory
adding: sample_directory/agatha.txt (deflated 41%)
```
你可以使用 -e 选项[在 Linux 中创建密码保护的 zip 文件夹][3]。
你可以使用 `-e` 选项[在 Linux 中创建密码保护的 zip 文件夹][3]。
你并不是只能通过终端创建 zip 归档文件。你也可以用图形方式做到这一点。下面是如何做的!
### 在 Ubuntu Linux 中使用 GUI 压缩文件夹
_虽然我在这里使用 Ubuntu但在使用 GNOME 或其他桌面环境的其他发行版中,方法应该基本相同。_
*虽然我在这里使用 Ubuntu但在使用 GNOME 或其他桌面环境的其他发行版中,方法应该基本相同。*
如果要在 Linux 桌面中压缩文件或文件夹,只需点击几下即可。
@ -73,7 +73,7 @@ _虽然我在这里使用 Ubuntu但在使用 GNOME 或其他桌面环境的
现在,你可以使用 zip、tar xz 或 7z 格式创建压缩归档文件。如果你好奇,这三个都是各种压缩算法,你可以使用它们来压缩文件。
输入一个你想要的名字,并点击“创建”
输入一个你想要的名字,并点击“创建”
![Create archive file][5]
@ -92,7 +92,7 @@ via: https://itsfoss.com/linux-zip-folder/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,32 +1,31 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10780-1.html)
[#]: subject: (Getting started with Mercurial for version control)
[#]: via: (https://opensource.com/article/19/4/getting-started-mercurial)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
开始使用 Mercurial 进行版本控制
Mercurial 版本控制入门
======
了解 Mercurial 的基础知识,它是一个用 Python 写的分布式版本控制系统。
> 了解 Mercurial 的基础知识,它是一个用 Python 写的分布式版本控制系统。
![][1]
[Mercurial][2] 是一个用 Python 编写的分布式版本控制系统。因为它是用高级语言编写的,所以你可以用 Python 函数编写一个 Mercurial 扩展。
在[官方文档中][3]说明了几种安装 Mercurial 的方法。我最喜欢的一种方法不在里面:使用 **pip**。这是开发本地扩展的最合适方式!
在[官方文档中][3]说明了几种安装 Mercurial 的方法。我最喜欢的一种方法不在里面:使用 `pip`。这是开发本地扩展的最合适方式!
目前Mercurial 仅支持 Python 2.7,因此你需要创建一个 Python 2.7 虚拟环境:
```
python2 -m virtualenv mercurial-env
./mercurial-env/bin/pip install mercurial
```
为了有一个简短的命令,以及满足人们对化学幽默的无法满足的需求,命令称之为 **hg**
为了让命令简短一些,以及满足人们对化学幽默的渴望,该命令称之为 `hg`
```
$ source mercurial-env/bin/activate
@ -39,7 +38,6 @@ $ source mercurial-env/bin/activate
由于还没有任何文件,因此状态为空。添加几个文件:
```
(mercurial-env)$ echo 1 > one
(mercurial-env)$ echo 2 > two
@ -58,13 +56,12 @@ date: Fri Mar 29 12:42:43 2019 -0700
summary: Adding stuff
```
**addremove** 命令很有用:它将任何未被忽略的新文件添加到托管文件列表中,并移除任何已删除的文件。
`addremove` 命令很有用:它将任何未被忽略的新文件添加到托管文件列表中,并移除任何已删除的文件。
如我所说Mercurial 扩展用 Python 写成,它们只是常规的 Python 模块。
这是一个简短的 Mercurial 扩展示例:
```
from mercurial import registrar
from mercurial.i18n import _
@ -74,19 +71,17 @@ command = registrar.command(cmdtable)
@command('say-hello',
[('w', 'whom', '', _('Whom to greet'))])
def say_hello(ui, repo, **opts):
def say_hello(ui, repo, `opts):
ui.write("hello ", opts['whom'], "\n")
```
一个简单的测试方法是将它手动加入虚拟环境中的文件中:
简单的测试方法是将它手动加入虚拟环境中的文件中:
```
`$ vi ../mercurial-env/lib/python2.7/site-packages/hello_ext.py`
```
然后你需要_启用_扩展。你可以仅在当前仓库中启用它开始
然后你需要*启用*扩展。你可以仅在当前仓库中启用它:
```
$ cat >> .hg/hgrc
@ -96,13 +91,12 @@ hello_ext =
现在,问候有了:
```
(mercurial-env)$ hg say-hello --whom world
hello world
```
大多数扩展会做更多有用的东西,甚至可能与 Mercurial 有关。 **repo** 对象是 **mercurial.hg.repository** 的对象。
大多数扩展会做更多有用的东西,甚至可能与 Mercurial 有关。 `repo` 对象是 `mercurial.hg.repository` 的对象。
有关 Mercurial API 的更多信息,请参阅[官方文档][5]。并访问[官方仓库][6]获取更多示例和灵感。
@ -110,10 +104,10 @@ hello world
via: https://opensource.com/article/19/4/getting-started-mercurial
作者:[Moshe Zadka (Community Moderator)][a]
作者:[Moshe Zadka][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,74 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (3 Emacs modes for taking notes)
[#]: via: (https://opensource.com/article/18/7/emacs-modes-note-taking)
[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt)
3 Emacs modes for taking notes
======
Keep track of information easily with these Emacs modes.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/notebook-writing-pen.jpg?itok=uA3dCfu_)
No matter what line of work you're in, it's inevitable you have to take a few notes. Often, more than a few. If you're like many people in this day and age, you take your notes digitally.
Open source enthusiasts have a variety of options for jotting down their ideas, thoughts, and research in electronic format. You might use a [web-based tool][1]. You might go for a [desktop application][2]. Or, you might [turn to the command line][3].
If you use [Emacs][4], that wonderful operating system disguised as a text editor, there are modes that can help you take notes more efficiently. Let's look at three of them.
### Deft
![](https://opensource.com/sites/default/files/uploads/deft.png)
On those rare occasions I'm forced to use a Mac, there's one tool I can't do without: the [nvALT][5] note-taking application. [Deft mode][6] brings the nvALT experience to Emacs.
Deft stores your notes as text files in a single folder on your computer. When you enter Deft mode, it displays a list of your notes along with a short summary. The summary is taken from the first line of the text file. If you add, say, Markdown, LaTeX, or even Emacs Org mode formatting to the first line, Deft ignores the formatting and displays only the text.
To open a note, just scroll down to it and press Enter. Deft does a bit more, though. According to Deft's developer, Jason Blevins, its _primary operation is searching and filtering_. Deft does that simply but efficiently. Type a keyword and Deft displays only the notes that have that keyword in their title. That's useful if you have a lot of notes and want to find one quickly.
### Org mode
![](https://opensource.com/sites/default/files/uploads/orgmode.png)
There would be a couple or three people who would have jumped all over me if I didn't include [Org mode][7] in this article. Why? It's arguably the most flexible and the most widely used Emacs mode for taking notes. Used in the right way, Org mode can supercharge your note-taking.
Org mode's main strength is how it organizes your notes. In Org mode, a note file is set up as a large outline. Each section is a node in the outline, which you can expand and collapse. Those sections can have subsections, which also expand and collapse. That not only lets you focus on one section at a time, but it also gives you an at-a-glance overview of the information you have.
You can [link][8] between sections of your notes, quickly move sections without cutting and pasting, and [attach files][9] to your notes. Org mode supports character formatting and tables. If you need to convert your notes to something else, Org mode has a number of [export options][10].
### Howm
![](https://opensource.com/sites/default/files/uploads/howm.png)
When I started using Emacs regularly, [howm][11] quickly became one of the modes I leaned heavily on. And even though I'm deep into using Org mode, I still have a soft spot for howm.
Howm acts like a small wiki. You can create notes and task lists and link between them. By typing or clicking a link, you can jump between notes. If you need to, you can also tag your notes with a keyword. On top of that, you can search, sort, and concatenate your notes.
Howm isn't the prettiest Emacs mode, and it doesn't have the best UX. It takes a bit of getting used to. Once you do, taking and maneuvering around notes is a breeze.
Do you have a favorite Emacs mode for taking notes? Feel free to share it by leaving a comment.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/7/emacs-modes-note-taking
作者:[Scott Nesbitt][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/scottnesbitt
[b]: https://github.com/lujun9972
[1]: https://opensource.com/alternatives/evernote
[2]: https://opensource.com/life/16/9/4-desktop-note-taking-applications
[3]: https://opensource.com/article/18/3/command-line-note-taking-applications
[4]: https://www.gnu.org/software/emacs/
[5]: http://brettterpstra.com/projects/nvalt/
[6]: https://jblevins.org/projects/deft/
[7]: https://orgmode.org/
[8]: https://orgmode.org/org.html#Hyperlinks
[9]: https://orgmode.org/org.html#Attachments
[10]: https://orgmode.org/org.html#Exporting
[11]: https://howm.osdn.jp/

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,99 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Managing RAID arrays with mdadm)
[#]: via: (https://fedoramagazine.org/managing-raid-arrays-with-mdadm/)
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
Managing RAID arrays with mdadm
======
![][1]
Mdadm stands for Multiple Disk and Device Administration. It is a command line tool that can be used to manage software [RAID][2] arrays on your Linux PC. This article outlines the basics you need to get started with it.
The following five commands allow you to make use of mdadms most basic features:
1. **Create a RAID array** :
### mdadm --create /dev/md/test --homehost=any --metadata=1.0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
2. **Assemble (and start) a RAID array** :
### mdadm --assemble /dev/md/test /dev/sda1 /dev/sdb1
3. **Stop a RAID array** :
### mdadm --stop /dev/md/test
4. **Delete a RAID array** :
### mdadm --zero-superblock /dev/sda1 /dev/sdb1
5. **Check the status of all assembled RAID arrays** :
### cat /proc/mdstat
#### Notes on features
##### `mdadm --create`
The _create_ command shown above includes the following four parameters in addition to the create parameter itself and the device names:
1. **homehost** :
By default, mdadm stores your computers name as an attribute of the RAID array. If your computer name does not match the stored name, the array will not automatically assemble. This feature is useful in server clusters that share hard drives because file system corruption usually occurs if multiple servers attempt to access the same drive at the same time. The name _any_ is reserved and disables the _homehost_ restriction.
2. **metadata** :
_mdadm_ reserves a small portion of each RAID device to store information about the RAID array itself. The _metadata_ parameter specifies the format and location of the information. The value _1.0_ indicates to use version-1 formatting and store the metadata at the end of the device.
3. **level** :
The _level_ parameter specifies how the data should be distributed among the underlying devices. Level _1_ indicates each device should contain a complete copy of all the data. This level is also known as [disk mirroring][3].
4. **raid-devices** :
The _raid-devices_ parameter specifies the number of devices that will be used to create the RAID array.
By using _level=1_ (mirroring) in combination with _metadata=1.0_ (store the metadata at the end of the device), you create a RAID1 array whose underlying devices appear normal if accessed without the aid of the mdadm driver. This is useful in the case of disaster recovery, because you can access the device even if the new system doesnt support mdadm arrays. Its also useful in case a program needs _read-only_ access to the underlying device before mdadm is available. For example, the [UEFI][4] firmware in a computer may need to read the bootloader from the [ESP][5] before mdadm is started.
##### `mdadm --assemble`
The _assemble_ command above fails if a member device is missing or corrupt. To force the RAID array to assemble and start when one of its members is missing, use the following command:
```
# mdadm --assemble --run /dev/md/test /dev/sda1
```
#### Other important notes
Avoid writing directly to any devices that underlay a mdadm RAID1 array. That causes the devices to become out-of-sync and mdadm wont know that they are out-of-sync. If you access a RAID1 array with a device thats been modified out-of-band, you can cause file system corruption. If you modify a RAID1 device out-of-band and need to force the array to re-synchronize, delete the mdadm metadata from the device to be overwritten and then re-add it to the array as demonstrated below:
```
# mdadm --zero-superblock /dev/sdb1
# mdadm --assemble --run /dev/md/test /dev/sda1
# mdadm /dev/md/test --add /dev/sdb1
```
These commands completely overwrite the contents of sdb1 with the contents of sda1.
To specify any RAID arrays to automatically activate when your computer starts, create an _/etc/mdadm.conf_ configuration file.
For the most up-to-date and detailed information, check the man pages:
```
$ man mdadm
$ man mdadm.conf
```
The next article of this series will show a step-by-step guide on how to convert an existing single-disk Linux installation to a mirrored-disk installation, that will continue running even if one of its hard drives suddenly stops working!
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-raid-arrays-with-mdadm/
作者:[Gregory Bartholomew][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://fedoramagazine.org/author/glb/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/mdadm-816x345.jpg
[2]: https://en.wikipedia.org/wiki/RAID
[3]: https://en.wikipedia.org/wiki/Disk_mirroring
[4]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
[5]: https://en.wikipedia.org/wiki/EFI_system_partition

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,75 @@
[#]: collector: (lujun9972)
[#]: translator: (lujun9972)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (3 Emacs modes for taking notes)
[#]: via: (https://opensource.com/article/18/7/emacs-modes-note-taking)
[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt)
用来记笔记的三个 Emacs modes
======
借助这些 Emacs mode 轻松记录信息。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/notebook-writing-pen.jpg?itok=uA3dCfu_)
不管你从事哪种工作,你都无可避免地需要记笔记。而且可能还不是一点点。现在这年头,大家都开始以数字的形式来记笔记了。
开源软件爱好者有多种途径来以电子的方式记下他们的创意,想法和研究过程。你可以使用 [网页工具 ][[1]]。你可以使用 [桌面应用 ][2]。或者,你也可以 [使用命令行工具 ][3]。
如果你使用 [Emacs][4]( 伪装成文本编辑器的强力操作系统),有多个 mode 可以帮你有效地记录笔记。我们这里列举三个例子。
### Deft
![](https://opensource.com/sites/default/files/uploads/deft.png)
在少数情况下,我被迫需要使用 Mac有一个工具是我不能缺少的[nvALT][5] 笔记应用。[Deft mode][6] 为 Emacs 带来了 nvALT 式的体验。
Deft 将你的笔记以文本文件的形式存储在电脑中的某个文件夹中。当你进入 Deft mode你会看到一系列的笔记及其摘要。这些摘要其实就是文本文件的第一行。若第一行是 MarkdownLaTeX甚至 Emacs Org mode 格式的话Deft 会忽略掉这些格式而只显示文本内容。
要打开笔记,只需要向下滚动到该笔记的位置然后按下回车即可。然而 Deft 不仅仅只是这样。根据 Deft 开发者 Jason Blevins 的说法,它的 /主要操作时搜索和过滤/。
Deft 的实现方式简单而有效。输入关键字然后 Deft 会只显示标题中包含关键字的笔记。这在你要从大量笔记中找到某条笔记时非常有用。
### Org mode
![](https://opensource.com/sites/default/files/uploads/orgmode.png)
如果本文没有包含 [Org mode][7] 的话,那么我可能会被人所诟病。为什么?它可以说是 Emacs 中最灵活、使用最广泛的记录笔记的方式了。以正确的方式使用它Org mode 可以极大地增强记笔记的能力。
Org mode 的主要优势在于它组织笔记的方式。在 Org mode 中,一个笔记文件被组织成一个巨大的大纲。每个章节就是大纲里的一个节点,你可以对它进行展开和折叠。这些章节又可以有子章节,这些子章节也可以暂开和折叠。这不仅使你一次只关注于某个章节,而且可以让你浏览整个大纲。
你可以在多个章节之间 [进行互联 ][8],无需通过剪切和复制就能快速移动章节,以及 [附加文件 ][9] 到笔记中。Org mode 支持带格式的字符和表格。如果你需要转换笔记到其他格式Org mode 也有大量的[导出选项 ][10]。
### Howm
![](https://opensource.com/sites/default/files/uploads/howm.png)
当我使用 Emacs 已经成为一种习惯时,[howm][11] 马上就成为我严重依赖的 mode 之一了。虽然我特别喜欢使用 Org mode但 howm 依然占有一席之地。
Howm 就好像时一个小维基似得。你可以创建笔记和任务列表,还能在他们之间创建链接。通过输入或点击某个链接,你可以在笔记之间跳转。如果你需要,还可以使用关键字为笔记添加标签。不仅如此,你可以对笔记进行搜索、排序和合并。
Howm 不是最漂亮的 Emacs mode它也没有最好的用户体验。它需要你花一点时间来适应它。而一旦你适应了它记录和查找笔记就是轻而易举的事情了。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/7/emacs-modes-note-taking
作者:[Scott Nesbitt][a]
选题:[lujun9972][b]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/scottnesbitt
[b]: https://github.com/lujun9972
[1]: https://opensource.com/alternatives/evernote
[2]: https://opensource.com/life/16/9/4-desktop-note-taking-applications
[3]: https://opensource.com/article/18/3/command-line-note-taking-applications
[4]: https://www.gnu.org/software/emacs/
[5]: http://brettterpstra.com/projects/nvalt/
[6]: https://jblevins.org/projects/deft/
[7]: https://orgmode.org/
[8]: https://orgmode.org/org.html#Hyperlinks
[9]: https://orgmode.org/org.html#Attachments
[10]: https://orgmode.org/org.html#Exporting
[11]: https://howm.osdn.jp/

View File

@ -0,0 +1,105 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Managing RAID arrays with mdadm)
[#]: via: (https://fedoramagazine.org/managing-raid-arrays-with-mdadm/)
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
使用 mdadm 管理 RAID 阵列
======
![][1]
mdadm 代表多磁盘和设备管理 Multiple Disk and Device Administration。它是一个命令行工具可用于管理 Linux 上的软件 [RAID][2] 阵列。本文概述了使用它的基础知识。
以下 5 个命令是你使用 mdadm 的基础功能:
1. **创建 RAID 阵列**
### mdadm --create /dev/md/test --homehost=any --metadata=1.0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
2. **组合并启动RAID 阵列**
### mdadm --assemble /dev/md/test /dev/sda1 /dev/sdb1
3. **停止 RAID 阵列**
### mdadm --stop /dev/md/test
4. **删除 RAID 阵列**
### mdadm --zero-superblock /dev/sda1 /dev/sdb1
5. **检查所有已组合的 RAID 阵列的状态**
### cat /proc/mdstat
#### 功能说明
##### `mdadm --create`
上面的 _create_ 命令除了 create 参数自身和设备名之外,还包括了四个参数:
1. **homehost** :
默认情况下mdadm 将你的计算机名保存为 RAID 阵列的属性。如果你的计算机名与存储的名称不匹配,则阵列将不会自动组合。此功能在共享硬盘的服务器群集中很有用,因为如果多个服务器同时尝试访问同一驱动器,通常会发生文件系统损坏。名称 _any_ 是保留字段并禁用 _homehost_ 限制。
2. **metadata** :
_mdadm_ 保存每个 RAID 设备的一小部分,以存储有关 RAID 阵列本身的信息。 _metadata_ 参数指定信息的格式和位置。_1.0_ 表示使用版本 1 格式并将元数据存储在设备的末尾。
3. **level** :
_level_ 参数指定数据应如何在底层设备之间分布。级别 _1_ 表示每个设备应包含所有数据的完整副本。此级别也称为[磁盘镜像] [3]。
4. **raid-devices** :
_raid-devices_ 参数指定将用于创建 RAID 阵列的设备数。
通过将 _level=1_ (镜像)与 _metadata=1.0_ (将元数据存储在设备末尾)结合使用,可以创建一个 RAID1 阵列,如果不通过 mdadm 驱动访问,那么它的底层设备会正常显示。这在灾难恢复的情况下很有用,因为即使新系统不支持 mdadm 阵列,你也可以访问该设备。如果程序需要在 mdadm 可用之前以_只读_访问底层设备时也很有用。例如计算机中的 [UEFI][4] 固件可能需要在启动 mdadm 之前从 [ESP][5] 读取引导加载程序。
##### `mdadm --assemble`
如果成员设备丢失或损坏,上面的 _assemble_ 命令将失败。要强制 RAID 阵列在其中一个成员丢失时进行组合并启动,请使用以下命令:
```
# mdadm --assemble --run /dev/md/test /dev/sda1
```
#### 其他重要说明
避免直接写入底层是 RAID1 的设备。这导致设备不同步,并且 mdadm 不会知道它们不同步。如果你访问了某个在其他地方被修改的设备的 RAID1 阵列,则可能导致文件系统损坏。如果你在其他地方修改 RAID1 设备并需要强制阵列重新同步,请从要覆盖的设备中删除 mdadm 元数据,然后将其重新添加到阵列,如下所示:
```
# mdadm --zero-superblock /dev/sdb1
# mdadm --assemble --run /dev/md/test /dev/sda1
# mdadm /dev/md/test --add /dev/sdb1
```
以上用 sda1 的内容完全覆盖 sdb1 的内容。
要指定在计算机启动时自动激活的 RAID 阵列,请创建 _/etc/mdadm.conf_ 配置。
有关最新和详细信息,请查看手册页:
```
$ man mdadm
$ man mdadm.conf
```
本系列的下一篇文章将展示如何将现有的单磁盘 Linux 安装变为镜像磁盘安装,这意味着即使其中一个硬盘突然停止工作,系统仍将继续运行!
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-raid-arrays-with-mdadm/
作者:[Gregory Bartholomew][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://fedoramagazine.org/author/glb/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/mdadm-816x345.jpg
[2]: https://en.wikipedia.org/wiki/RAID
[3]: https://en.wikipedia.org/wiki/Disk_mirroring
[4]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
[5]: https://en.wikipedia.org/wiki/EFI_system_partition