PVE 挂载硬盘

本文最后更新于 2025年9月10日 凌晨

环境

PVE 9.0
内核版本 6.14.8-2-pve

列出所有盘

1
lsblk

分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
root@pve:/mnt# fdisk /dev/nvme1n1
Welcome to fdisk(util-linux 2.41)Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command(m for help): n
Partition type
p primary(0 primary,0 extended,4 free)
e extended(container for logical partitions)
Select(default p):p
Partition number(1-4,default 1):1
First sector(2048-3907029167,default 248):
Last sector,+/-sectors or +/-sizefK,M,G,T,P}(2848-3907029167, default 3907029167):

Created a new partition 1 of type 'Linux' and of size 1.8 TiB.

Command(m for help):w
The partition table has been altered.
Calling ioctl()to re-read partition table.
Syncing disks.

格式化

1
2
3
4
5
6
7
8
9
10
11
12
13
root@pve:/mnt#t mkfs.ext4 /dev/nvme1n1p1
mke2fs 1.47.2(1-Jan-2025)Discarding device blocks: done
Creating filesystem with 488378398 4k blocks and 122101760 inodes
Filesustem uulD: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Superblock backups stored on blocks:
32768,98384,163848,229376,294912,819288,884736, 1685632. 2654208
4896888,7962624,11239424,28480888, 23887872, 71663616, 78675968,
102408008,214990848

Allocating group tables: done
Writing inode tables: done
Creating journal(262144 blocks): done
Writing superblocks and filesystem accounting information: done

挂载

1
2
root@pve:/mnt# mkdir /mnt/vmdata
root@pve:/mnt# mount /dev/nvme1n1p1 /mnt/vmdata

设置开机自动挂载

1
root@pve:/mnt# nano /etc/fstab

在文件末尾添加

1
2
3
4
/dev/nvme1n1p1 /mnt/vmdata ext4 defaults 0 2
# 最后两个参数:
# dump 备份标志,0 表示不使用 dump 备份工具(很少用)
# fsck 检查顺序,0 表示不开机检查,1 表示先检查(通常给根分区),2 表示比根分区晚检查

/dev/nvme1n1p1 这种命名在系统重启后可能会变化(尤其是有多块 NVMe 硬盘时,顺序变动就会导致识别错乱)。更推荐用 UUID= 或 PARTUUID= 来指定分区。

查看 UUID

1
blkid

1
2
# etc/fstab 示例
UUID=xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/vmdata ext4 defaults 0 2

修改后重启可能需要一段初始化时间


PVE 挂载硬盘
https://term-inator.github.io/2025/08/09/pve-mount-disk/
作者
Sicong Chen
发布于
2025年8月9日
更新于
2025年9月10日
许可协议