# 21.2.RAID0——条带

条带化（Striping）将多个磁盘驱动器合并为一个单一的卷。条带化可以通过硬件 RAID 控制器来完成。GEOM 磁盘子系统提供了软件支持的磁盘条带化，也称为 RAID0，无需 RAID 磁盘控制器。

在 RAID0 中，数据被分割成块，跨所有磁盘进行写入。如下面的图示所示，RAID0 不需要等待系统将 256k 数据写入一个磁盘，而是可以同时将 64k 数据写入阵列中的每个磁盘，从而提供更高的 I/O 性能。使用多个磁盘控制器可以进一步提升性能。

![Disk Striping Illustration](https://docs.freebsd.org/images/books/handbook/geom/striping.png)

RAID0 中的每个磁盘必须具有相同的大小，因为 I/O 请求被交错，以便并行地读取或写入多个磁盘。

> **注意**
>
> RAID0 *不提供* 冗余。这意味着如果阵列中的一个磁盘发生故障，所有磁盘上的数据将丢失。如果数据重要，请实现定期将备份保存到远程系统或设备的备份策略。

在 FreeBSD 系统上使用普通磁盘创建 GEOM 基础的 RAID0 软件阵列的过程如下。创建条带后，参考 [gstripe(8)](https://man.freebsd.org/cgi/man.cgi?query=gstripe\&sektion=8\&format=html) 获取更多关于如何控制现有条带的信息。

**过程：创建未格式化的 ATA 磁盘条带**

1. 加载 **geom\_stripe.ko** 模块：

   ```sh
   # kldload geom_stripe
   ```
2. 确保存在合适的挂载点。如果该卷将成为根分区，则暂时使用另一个挂载点，如 **/mnt**。
3. 确定将要条带化的磁盘的设备名称，并创建新的条带设备。例如，要将两个未使用且未分区的 ATA 磁盘（设备名称为 **/dev/ad2** 和 **/dev/ad3**）进行条带化：

   ```sh
   # gstripe label -v st0 /dev/ad2 /dev/ad3
   Metadata value stored on /dev/ad2.
   Metadata value stored on /dev/ad3.
   Done.
   ```
4. 在新卷上写入标准标签（也称为分区表），并安装默认的引导代码：

   ```sh
   # bsdlabel -wB /dev/stripe/st0
   ```
5. 该过程应该在 **/dev/stripe** 下创建另外两个设备，除了 **st0** 之外，分别是 **st0a** 和 **st0c**。此时，可以使用 `newfs` 在 **st0a** 上创建 UFS 文件系统：

   ```sh
   # newfs -U /dev/stripe/st0a
   ```

   一些数字会在屏幕上滚动，几秒钟后，过程完成。卷已经创建，可以挂载了。
6. 手动挂载已创建的磁盘条带：

   ```sh
   # mount /dev/stripe/st0a /mnt
   ```
7. 要在启动过程中自动挂载该条带文件系统，请将卷信息添加到 **/etc/fstab**。在此示例中，创建了一个名为 **stripe** 的永久挂载点：

   ```sh
   # mkdir /stripe
   # echo "/dev/stripe/st0a /stripe ufs rw 2 2" \
   >> /etc/fstab
   ```
8. **geom\_stripe.ko** 模块还必须在系统初始化时自动加载，通过向 **/boot/loader.conf** 添加以下行：

   ```sh
   # echo 'geom_stripe_load="YES"' >> /boot/loader.conf
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://handbook.bsdcn.org/di-21-zhang-geom-mo-kuai-hua-ci-pan-zhuan-huan-kuang-jia/21.2.-raid0-tiao-dai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
