> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/run-the-platform/zh/xu-ni-ji/sharing-disks-between-vms.md).

# 在虚拟机之间共享磁盘

## 概述

VergeOS 目前不会同时将单个块设备挂载到多个正在运行的 VM 上。如今当我们需要在 VM 之间共享数据时，有两种受支持的方法： **复制磁盘** （克隆磁盘），这样每个 VM 都会获得自己独立的副本，或者 **通过网络共享文件系统** 通过从每个来宾中挂载 NAS 共享。本页说明每种方法的作用、何时选择以及具体步骤在哪儿可以找到。

### 你将学到什么

* 克隆磁盘与基于 NAS 的文件共享之间的区别
* 根据你的使用场景选择各方法的时机

### 所需条件

* 一个正在运行的 VergeOS 环境，至少包含两台虚拟机
* 对 VergeOS UI 的管理员访问权限
* 对于 NAS 共享：一个已配置的 [NAS 服务](/run-the-platform/zh/nas/overview.md)

## 对比

| 方法                  | 共享内容                        | 读/写语义                                      | 最适合                                         | 限制                                                                    |
| ------------------- | --------------------------- | ------------------------------------------ | ------------------------------------------- | --------------------------------------------------------------------- |
| **克隆磁盘**            | 现有 `.raw` 磁盘的独立副本，在创建驱动器时生成 | 每个 VM 拥有一个私有的读/写副本。更改会 **并不** 同步回源磁盘或其他克隆。 | 从已知良好的磁盘镜像初始化新 VM，或将某一时点的数据集移交给另一台 VM       | 仅限一次性复制——不是实时共享机制。克隆在创建时就会与源磁盘分离。权限从源磁盘继承。                            |
| **NAS 共享（SMB/NFS）** | 由 NAS 卷提供并作为网络共享公开，供多个来宾挂载  | 文件 **级别** 的并发读/写，由 NAS 服务和共享协议协调           | 共享的应用数据、文件存储库、内容库，以及任何需要多个 VM 读取或写入同一文件的工作流 | 仅限文件级，不是块级。与本地磁盘 I/O 相比会有网络开销。并发、锁定和性能取决于协议和来宾操作系统。提供细粒度的共享级和文件系统级权限。 |

## 方法 1 —— 克隆磁盘

一个 **克隆磁盘** 是现有 `.raw` 驱动器（VergeOS VM 磁盘的默认格式）在同一 VergeOS 云中的某一时点副本。它是在我们为 VM 添加驱动器并选择 **克隆磁盘** 作为介质类型时创建的。创建后，克隆完全独立于源：克隆 VM 的写入仅保留在克隆中，对源的写入对克隆不可见。由于克隆是完整副本，如果源驱动器之后被修改或删除，它也不受影响。这是 *初始化* 基于现有磁盘创建 VM 的正确选择，而不是用于在 VM 之间保持数据同步。

逐步操作请参见 [**虚拟机驱动器**](/run-the-platform/zh/xu-ni-ji/vm-drives.md#add-a-drive-to-a-vm) 并在 **克隆磁盘** 中选择 *介质* 步骤。

## 方法 2 —— NAS 共享

一个 **NAS 共享** 是由 VergeOS NAS 服务托管并通过 SMB 或 NFS 暴露的一个卷。每个 VM 都像挂载其他网络文件系统一样挂载该共享，NAS 会协调所有已连接来宾之间的并发访问。这是让多个 VM 同时对同一数据具有读/写访问权限的受支持方式。

设置请参见 [**NAS 概览**](/run-the-platform/zh/nas/overview.md) 和 [**NAS 共享**](/run-the-platform/zh/nas/nas-shares.md).

## 如何在它们之间选择

* **使用克隆磁盘** 当我们需要一台新 VM *启动* 时带有现有磁盘的副本，然后独立演进——例如，从同一个已准备好的操作系统或数据磁盘部署多台 VM。
* **使用克隆磁盘** 用于一次性数据移交，接收 VM 应拥有其副本。
* **使用 NAS 共享** 当两台或多台 VM 需要读写 *相同的* 文件时。
* **使用 NAS 共享** 用于共享应用内容、团队文件存储、构建产物、媒体库，或任何需要 VM 之间保持一致性的工作流。
* **不要** 使用克隆磁盘来保持 VM 之间的数据同步——克隆会立即分叉，且无法合并回写。

{% hint style="info" %}
**路线图**

单个驱动器同时挂载到多个 VM——支持只读和读/写——计划在未来的 VergeOS 版本中提供。该功能可用时，本页将更新。
{% endhint %}

## 摘要

简而言之： **用于播种用克隆磁盘，用于共享则用 NAS。** 我们介绍了在 VergeOS 中在虚拟机之间共享数据的两种受支持方法：

* **克隆磁盘** 用于创建现有驱动器的独立某一时点副本——本地块级 I/O、没有网络开销，但没有同步
* **NAS 共享** 用于通过 SMB 或 NFS 从多个 VM 并发访问文件级数据——具备细粒度访问控制和实时协作，但会产生网络开销

### 下一步

* [虚拟机驱动器](/run-the-platform/zh/xu-ni-ji/vm-drives.md#add-a-drive-to-a-vm) — 创建克隆磁盘
* [NAS 概览](/run-the-platform/zh/nas/overview.md) — 设置 NAS 服务
* [NAS 共享](/run-the-platform/zh/nas/nas-shares.md) — 创建和管理文件共享


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.verge.io/run-the-platform/zh/xu-ni-ji/sharing-disks-between-vms.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
