> For the complete documentation index, see [llms.txt](https://handbook.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://handbook.bsdcn.org/di-20-zhang-cun-chu/20.2.-tian-jia-ci-pan.md).

# 20.2.添加磁盘

本节介绍了如何向当前仅有一块硬盘的计算机添加一块新的 SATA 硬盘。首先，关闭计算机并根据计算机、控制器和硬盘厂商的说明安装硬盘。重启系统并切换为 `root`。

检查 **/var/run/dmesg.boot** 文件，确保新硬盘已被识别。在这个示例中，新增的 SATA 硬盘将显示为 **ada1**。

在本示例中，将在新硬盘上创建一个单一的大分区。将优先使用 [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) 分区方案，而非较旧且灵活性较差的 MBR 方案。

> **注意**
>
> 如果要添加的磁盘非空，可使用 `gpart delete` 删除旧的分区信息。详情请参阅 [gpart(8)](https://man.freebsd.org/cgi/man.cgi?query=gpart\&sektion=8\&format=html)。

创建分区方案，然后添加一个单一的分区。为了提高在具有更大硬件块大小的较新硬盘上的性能，分区对齐到 1MB 边界：

```sh
# gpart create -s GPT ada1
# gpart add -t freebsd-ufs -a 1M ada1
```

根据用途，可能需要几个较小的分区。有关创建小于整个磁盘的分区的选项，请参阅 [gpart(8)](https://man.freebsd.org/cgi/man.cgi?query=gpart\&sektion=8\&format=html)。

可以使用 `gpart show` 查看磁盘分区信息：

```sh
% gpart show ada1
=>        34  1465146988  ada1  GPT  (699G)
          34        2014        - free -  (1.0M)
        2048  1465143296     1  freebsd-ufs  (699G)
  1465145344        1678        - free -  (839K)
```

在新硬盘的新分区上创建文件系统：

```sh
# newfs -U /dev/ada1p1
```

创建一个空目录作为 *挂载点*，即将新硬盘挂载到原硬盘文件系统中的位置：

```sh
# mkdir /newdisk
```

最后，在 **/etc/fstab** 中添加一条条目，使新硬盘在启动时自动挂载：

```sh
/dev/ada1p1	/newdisk	ufs	rw	2	2
```

新硬盘可以在不重启系统的情况下手动挂载：

```sh
# mount /newdisk
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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-20-zhang-cun-chu/20.2.-tian-jia-ci-pan.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.
