安装PVE过程以及设置,在PVE下安装OpenWrt以及设置。
最近自己装了台N5105的小主机,用的蜗牛星际6盘位的nas机箱,准备折腾一下aio主机。这篇blog主要是折腾pve虚拟环境以及OpenWrt软路由相关的。
安装PVE
基础操作
磁盘这里我默认了,没进行任何设置
![磁盘](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/1.png)
设置国家,密码这些都不说了,邮箱真的假的无所谓随便填
设置网络
图是别的地方截的,具体输入内容看我说明。
![网络](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/2.png)
- 首先我们是需要设置一个管理网口的,这个很重要,我们之后管理后台以及各种操作都需要通过此网口进行。我N5105是有4个i226的网卡的,我直接设置第一个(主板从左到右数)为管理网口,稍后这个口要接到另一台电脑上。
- 域名可以随便填,反正管理ip在内网
- ip地址我填的是192.168.2.2,网关和DNS都是192.168.2.1,子网掩码默认24不需要动。这里说明一下,首先光猫的管理地址是.1.1,所以.1.x的地址不能用了。稍后我们安装的OpenWrt我打算作为主路由使用,我准备给它分配的地址是.2.1,pve也要以它为路由,我就依次往后排给了个.2.2,DNS也直接交给OpenWrt去处理。
等待安装
读完条后重启,拔U盘。
访问管理页面
把电脑连到刚才设置好的管理网口上,电脑ip手动设置一下,网关和DNS指向.2.1,ip我给了一个.2.4,因为之后我还要搞旁路由,打算把.2.3给旁路由,电脑的ip往后错了一个。然后电脑访问192.168.2.2:8006,就可以登上后台了。后台登录账户root,密码是之前设置的。
PVE(8.0.2版本)更换国内源
Debian换源
我目前使用的PVE8.0.2版本是基于Debian 12的,所以要使用12的镜像源。我选择了清华源,这个可以根据自己喜好,中科大,阿里之类的都可以。
首先上清华镜像站官网Debian软件源。
# 默认注释了源码镜像以提高 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
然后备份一下源文件,之后换源
cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份源文件
nano /etc/apt/sources.list #编辑源文件,全部删掉,把上面的清华源复制进去,Ctrl+X,Y,回车
然后apt update
apt upgrade
更换PVE软件源
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bullseye pve-no-subscription
这里清华的源还是Debian11的,没法用,我用的中科大的源
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
同样是先备份再换源
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源
同样这里我用的中科大源
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy/ bookworm main
先备份再换源
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
我个人没弄这个,不知道这玩意是干嘛的,只不过别的地方教程有写,记一下
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 #重启服务
硬件直通
启用IOMMU功能
需要cpu支持“VT-d”技术,可去Intel或AMD官网去查询,并在主板里开启此功能。
使用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里输入
echo vfio >> /etc/modules
echo vfio_iommu_type1 >> /etc/modules
echo vfio_pci >> /etc/modules
echo vfio_virqfd >> /etc/modules
或者直接修改nano /etc/modules
,直接把这些加进去
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
然后更新一下内核参数
update-initramfs -k all -u
最后重启pve
输入dmesg | grep iommu
,如果出现一堆前缀为pci:的回显,说明开启成功。
显卡直通
Windows端的教程很多,自己去找,我打算直通给TrueNAS,暂时没搞,待更新。
附带一些其他硬件直通帖子
在 PVE 7 中启用硬件直通功能
N5105 12代核显直通 PVE UEFI Windows虚拟机HDMI输出
PVE开启硬件直通功能
PVE下安装OpenWrt
创建虚拟机
![常规](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/3.png)
![介质](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/4.png)
![系统](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/5.png)
![磁盘](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/6.png)
![cpu](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/7.png)
![内存](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/8.png)
![网络](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/9.png)
![分离磁盘](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/10.png)
![移除磁盘](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/11.png)
挂载镜像并修改引导
![镜像](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/12.png)
OpenWrt的镜像我使用的是eSir大佬的高大全固件,这是大佬的Google盘,文件自取
有传统和UEFI两种,因为咱们之前创建虚拟机时,系统那里选的是SeaBIOS,所以要下载combined的那个固件。下载好后解压,把得到的img镜像传到pve上去
上传好后,会弹出一个窗口,我们复制这里的路径,一会儿要用
![路径](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/13.png)
然后回到pve的shell里,输入
qm importdisk 101 (上传文件路径) local-lvm
这里的101是创建虚拟机时候的那个虚拟机ID,路径是你刚才复制的,不要丢空格,然后回车,等待一会儿出现如下图所示内容即可。
![OK](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/14.png)
回到创建好的虚拟机硬件部分,会出现一个未使用的磁盘,点击编辑。
![编辑](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/15.png)
![SATA](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/16.png)
然后点击右下角“添加”
自启动看个人,我反正连pve都不打算关,无所谓了。
![自启](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/17.png)
然后把引导修改一下,使用刚才添加好的镜像盘做启动盘。
![引导](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/18.png)
将网卡直通给OpenWrt
我是4个网卡,第一个给pve做管理口,这个口在OpenWrt会作为lan口,剩下的3个口我要直通给OpenWrt,并且在之后的设置里,将会把最后一个作为wan口使用(方便记忆)。
![pci](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/19.png)
第一个管理口不要动,剩下三个依次直通,主GPU选项千万不要勾选。
![网口](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/20.png)
不放心的可以自己去pve的shell里用lspci
和lspci -n
看一下自己的网卡是哪个
完成以后,开机!
OpenWrt的各种设置
IP、NTP
开机之后,按提示按一下回车,有终端了以后,使用nano /etc/config/network
修改OpenWrt的ip地址
![ip](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/21.png)
保存退出,reboot
一下,然后就可以回电脑的web端访问192.168.2.1去管理OpenWrt了,我这的情况是默认安装好是没有密码的,登录时密码留空就可以上去,进去以后要及时修改密码。
![密码](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/22.png)
开启一下NTP
![ip](/2023/08/14/Install%20OpenWrt%20and%20various%20settings%20of%20OpenWrt%20in%20PVE/23.png)
配置PPPoE拨号上网并开启ipv6
- 创建一个wan口(默认是有的),基本设置里,选择PPPoE协议,填写宽带账号密码。高级设置里,把
使用内置的ipv6管理
取消勾选(非必要,但建议),获取ipv6地址
选择自动
。物理设置里,跟上面说的一样,我选择了最后一个作为wan口。(我这里是会有eth0~3四个口,eth0是管理口虚拟出来的网口,剩下三个是直通过去的,我就直接选择eth3做wan) - 创建一个lan口,基本设置里,协议选择
静态地址
,ipv4地址填写OpenWrt本身的192.168.2.1,子网255.255.255.0,DNS也交给192.168.2.1,ipv6分配长度默认64即可,其他不用动。高级设置里,同样是把使用内置的ipv6管理
取消勾选。物理设置里,我选择了桥接接口,把这三个直通的口桥接起来了,这样这三个口都可以作为管理接口访问到pve。我不确定是否存在安全问题,反正暂时这么用着吧。 - 在lan口设置的
DHCP服务器
中,基本设置里取消勾选忽略此接口
,高级设置里我把强制
勾上了,ipv6设置中,将路由通告服务
和DHCPv6服务
都选择为服务器模式
,并且勾选总是通告默认路由
,保存。 - 最后在OpenWrt,网络,DHCP/DNS,高级设置,把
禁止解析IPV6 DNS记录
取消勾选,然后就可以愉快的v6冲浪力~