最近自己装了台N5105的小主机,用的蜗牛星际6盘位的nas机箱,准备折腾一下aio主机。这篇blog主要是折腾pve虚拟环境相关的。

安装PVE

基础操作

PVE官网下载镜像,用rufus写到U盘,开始安装。

磁盘这里,我贴一下这几个选项的释义。

hdsize
定义目标硬盘的容量大小,通过设置这个参数,你可以配置硬盘预留部分空间作他用(例如在同一块硬盘上配置其他物理卷PV和卷组VG,以创建LVM类型存储服务)。不建议预留空间,不要在系统盘上再建立其他卷组,直接使用整个磁盘空间。

swapsize
定义swap逻辑卷的容量大小,默认和服务器物理内存容量大小一致,最小值为4GB,最大值为8GB,最大值不能大过hdsize/8。注意,如设置为0,将不会创建swap逻辑卷。

maxroot
定义root逻辑卷的容量大小,最大值限制为hdsize/4。root逻辑卷主要用于保存ISO操作系统镜像。

minfree
定义pve卷组容量中除了swap、root以及data逻辑卷容量之外剩余的可用容量大小,也就是说minfree大小可以按照下面方式来计算 minfree = pve - swapsize - rootsize - datasize

maxvz
定义data逻辑卷的容量大小,data逻辑卷主要用于保存虚拟机文件,虚拟机文件容量大小不能超过maxvz。maxvz实际大小可以这样计算:datasize = hdsize - rootsize - swapsize - minfree

对于以上选项,我推荐如下设置

1
2
3
4
5
hdsize:整个磁盘
swapsize:8G
maxroot:32G
minfree:0
maxvz:剩余所有

并且根据我的找回PVE的LVM-Thin,优化data分区这篇blog对maxvz的存储空间进行优化。

root里就不用放什么东西了,直接全用data存文件。

设置国家,密码这些都不说了,邮箱真的假的无所谓随便填

设置网络

图是别的地方截的,具体输入内容看我说明。

  1. 首先我们是需要设置一个管理网口的,这个很重要,我们之后管理后台以及各种操作都需要通过此网口进行。我N5105是有4个i226的网卡的,我直接设置第一个(主板从左到右数)为管理网口,稍后这个口要接到另一台电脑上。
  2. 域名可以随便填,反正管理ip在内网
  3. ip地址我填的是192.168.2.2,网关和DNS都是192.168.2.1,子网掩码默认24不需要动。这里说明一下,我稍后打算在PVE里安装OpenWrt作为主路由使用,我准备给它分配的地址是.2.1,pve也要以它为路由,我就依次往后排给了个.2.2,DNS也直接交给OpenWrt去处理。如果你有物理路由设备,请自行修改。

等待安装

读完条后重启,拔U盘。

访问管理页面

把电脑连到刚才设置好的管理网口上,电脑ip手动设置一下,网关和DNS指向.2.1,ip随便给一个2.x的就行。然后电脑访问192.168.2.2:8006,就可以登上后台了。后台登录账户root,密码是之前设置的。

PVE更换国内源并删除无企业订阅弹窗

注意!

此小段内容为使用一段时间后的更新内容,无代理用户可忽略。

PVE界面可以直接添加删除官方源,没必要手动编辑源文件,我后期一律改为使用官方源。网络使用wrt路由代理即可。

删弹窗

注意!删除无企业订阅弹窗后,同样无法打开添加官方无企业订阅源的弹窗,请谨慎

1
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

然后控制台会自动断开一下链接,刷新一下网页就可以了

如需恢复弹窗,请执行

1
cp /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.bak /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

Debian换源

我目前使用的PVE8.0.2版本是基于Debian 12的,所以要使用12的镜像源。我选择了清华源,这个可以根据自己喜好,中科大,阿里之类的都可以。

首先上清华镜像站官网Debian软件源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

# deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# # deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

然后备份一下源文件,之后换源

1
2
cp /etc/apt/sources.list /etc/apt/sources.list.bak  #备份源文件
nano /etc/apt/sources.list #编辑源文件,全部删掉,把上面的清华源复制进去,Ctrl+X,Y,回车

然后apt update apt upgrade

更换PVE软件源

清华镜像站官网PVE软件源

1
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bullseye pve-no-subscription

这里清华的源还是Debian11的,没法用,我用的中科大的源

中科大PVE软件源

1
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription

同样是先备份再换源

1
2
cp /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak 
nano /etc/apt/sources.list.d/pve-enterprise.list

apt update apt upgrade

更换Ceph源

同样这里我用的中科大源

中科大Ceph源

1
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy/ bookworm main

先备份再换源

1
2
cp /etc/apt/sources.list.d/ceph.list /etc/apt/sources.list.d/ceph.list.bak 
nano /etc/apt/sources.list.d/ceph.list

APLinfo

我个人没弄这个,不知道这玩意是干嘛的,只不过别的地方教程有写,记一下

1
2
3
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back #备份
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm #更换
systemctl restart pvedaemon.service #重启服务

硬件直通

说明

在后续建立软路由虚拟机、nas虚拟机时,需要直通网卡、硬盘、显卡等设备,此处必须先把直通环境做好。

启用IOMMU功能

需要cpu支持VT-d技术,可去IntelAMD官网去查询,并在主板里开启此功能。

使用nano /etc/default/grub编辑grub文件,找到GRUB_CMDLINE_LINUX_DEFAULT="quiet"
Intel用户替换为GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"
AMD用户替换为GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"
随后使用update-grub更新一下grub

加载相应的内核模块

在pve的shell里输入

1
2
3
4
echo vfio >> /etc/modules
echo vfio_iommu_type1 >> /etc/modules
echo vfio_pci >> /etc/modules
echo vfio_virqfd >> /etc/modules

或者直接修改nano /etc/modules,直接把这些加进去

1
2
3
4
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

然后更新一下内核参数

1
update-initramfs -k all -u

最后重启pve

输入dmesg | grep iommu,如果出现一堆前缀为pci:的回显,说明开启成功。

显卡直通

Windows端的教程很多,自己去找,我打算直通给TrueNAS,暂时没搞,待更新。

附带一些其他硬件直通帖子
在 PVE 7 中启用硬件直通功能
N5105 12代核显直通 PVE UEFI Windows虚拟机HDMI输出
PVE开启硬件直通功能

更新:PVE直通Nvidia显卡给Windows10