> For the complete documentation index, see [llms.txt](https://docs.chjina.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chjina.com/it-zhi-shi-ku/xi-tong-pei-zhi-he-you-hua/linux/centos/vmware-xu-ni-ji-kuo-rong-ying-pan.md).

# VMware虚拟机扩容硬盘

![image-20260318152352040](https://content.gitbook.com/content/-MjP04gjZIrqcvMvKFHA/blobs/Ubxd4LdaQDRgDI1vQX7Y/5d3f1ba9a1873c4453e42b43e2c5ce08.png)

### 方案一：为虚拟机添加一块新硬盘（最安全、最推荐）

这是最简单的办法，不需要挪动现有的任何数据。你只需在虚拟机管理软件（如 VMware、VirtualBox、PVE 等）里给这台虚拟机增加一块虚拟硬盘。

{% stepper %}
{% step %}

#### 在虚拟机设置中添加硬盘

关闭虚拟机或在线新增一块硬盘（例如 1T）。
{% endstep %}

{% step %}

#### 让系统识别新硬盘

重启虚拟机，或者在终端输入 `lsblk` 查看新硬盘名称（这里假设新硬盘识别为 `/dev/sdb`）。

![image-20260318152638511](https://content.gitbook.com/content/-MjP04gjZIrqcvMvKFHA/blobs/BLuKMNqWnsLCml1ef9Oq/0676345787aeff0ece37d6cfe47ea48d.png)
{% endstep %}

{% step %}

#### 创建物理卷 (PV)

```bash
pvcreate /dev/sdb
```

{% endstep %}

{% step %}

#### 将新硬盘加入到现有的卷组 (VG)

```bash
vgextend openeuler /dev/sdb
```

{% endstep %}

{% step %}

#### 扩容根目录逻辑卷 (LV)

```bash
lvextend -l +100%FREE /dev/mapper/openeuler-root
```

{% endstep %}

{% step %}

#### 刷新文件系统容量

需先确认文件系统类型，可用 `df -Th` 查看：

* 如果是 **xfs** 文件系统：

  ```bash
  xfs_growfs /
  ```
* 如果是 **ext4** 文件系统：

  ```bash
  resize2fs /dev/mapper/openeuler-root
  ```

{% endstep %}
{% endstepper %}

![image-20260318152157747](https://content.gitbook.com/content/-MjP04gjZIrqcvMvKFHA/blobs/GdvceCBDwx444Uvbtptm/c0c0e4bbac56f0b6b8886ce3e274f027.png)
