PVE教程

Proxmox VE (PVE) All-in-One 搭建教程

最近整了一个N100的小主机,准备搞个PVE试试

Proxmox VE (PVE)的安装

第一部分:硬件与系统准备

1. 硬件要求

  • CPU: 支持虚拟化技术的64位处理器(Intel VT-x / AMD-V)
  • 内存: 至少8GB(建议16GB以上)
  • 存储: 至少120GB SSD(推荐使用SSD+HDD组合)
  • 网络: 至少1个千兆网口(多网口更佳)

2. 下载Proxmox VE ISO镜像

访问 Proxmox VE 官网 下载最新版ISO镜像(如Proxmox VE 8.3)。

3. 制作启动U盘

使用工具如 RufusBalenaEtcher 将ISO写入U盘。

第二部分:安装Proxmox VE

1. 启动安装程序

启动设备并进入 BIOS 设置(开机时狂按DELETE键),方向键选择 Boot 设置,设置 USB 启动为第一优先级,设置完成后,保存并重启!
插入U盘,从U盘启动,进入Proxmox安装界面:

  1. 同意许可协议。
  2. 选择安装目标磁盘(建议使用SSD)。
  3. 设置国家、时区、键盘布局。

2. 配置网络

  • 主机名: 如 pve.lab(按需自定义)
  • IP地址: 静态IP(如 192.168.1.100/24
  • 网关: 路由器的IP(如 192.168.1.1
  • DNS: 填写本地DNS或公共DNS(如 8.8.8.8

3. 完成安装

设置root密码并确认安装。安装完成后重启服务器。


第三部分:初始配置

1. 访问Web管理界面

安装后登陆地址(登录电脑需要在同网段)浏览器输入 https://<IP>:8006(如 https://192.168.1.100:8006),使用root账号登录。

2. 更新系统与仓库

1
2
3
4
5
6
# 替换企业源为免费社区源
sed -i 's/^deb/#deb/' /etc/apt/sources.list.d/pve-enterprise.list
echo "deb http://download.proxmox.com/debian/pve $(lsb_release -cs) pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

# 更新系统
apt update && apt dist-upgrade -y

3. 给PVE的扩容(可选项)

  • 注意:移除local-lvm可能会影响PVE的部分快照功能
  • 在shell里边输入(或者用SSH工具链接PVE):
    1
    lvremove pve/data
  • 点击y后,再输入:
    1
    lvextend -l +100%FREE -r pve/root
  • 再点击数据中心存储local-lvm移除,再双击local,把内容里的所有选项都选中。

4. 去除PVE无有效订阅提示(可选项)

  • PVE6.3版本到PVE7.X版本可以执行:
    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
  • PVE8.X版本可以执行:
    1
    sed -i.backup -z "s/res === null || res === undefined || \!res || res\n\t\t\t.data.status.toLowerCase() \!== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

5. 开启PVE直通功能(可选项)

  • 在shell里边输入(或者用SSH工具链接PVE):
    1
    2
    3
    4
    #若你的CPU为Intel:
    sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT/c\GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream"' /etc/default/grub
    #若你的CPU为AMD修改为
    sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT/c\GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt pcie_acs_override=downstream"' /etc/default/grub
  • 增加所需模块,修改文件/etc/modules,输入如下命令:
    1
    echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd" | tee -a /etc/modules
  • 更新上述配置信息并重启PVE:
    1
    2
    3
    update-grub
    update-initramfs -u -k all
    reboot
  • 验证是否已开启iommu
    1
    dmesg | grep iommu
  • 查看可直通设备列表::
    1
    lspci

二、虚拟机安装

1、安装iKuai(可做主路由)

  • 下载iKuai官方镜像:点此下载

  • 添加要直通的网卡,对应好网口,设置wanlan

  • 网关设为192.168.XXX.1(主路由IP)

  • DNS可用阿里223.5.5.5和腾讯119.29.29.29

  • 默认用户名:admin,默认密码:admin

  • 进入Shell ping下试试网络是否正常

    1
    ping baidu.com

2、安装iStoreOSOpenWrt(可做旁路由)

  • 下载iStoreOS镜像:点此下载
  • 下载OpenWrt镜像:点此下载
  • .img文件挂载
    1
    2
    3
    4
    5
    6
    7
    8
    # PVE虚拟机id和img文件路径替换为自己的
    qm importdisk pve虚拟机id img文件路径 local

    # 如果你没有扩容的话,你可能需要在下面命令的后边加上-lvm
    qm importdisk pve虚拟机id img文件路径 local-lvm

    # 如果你用SSH链接工具,在root目录下上传img文件的话,可以用下面的命令
    qm importdisk pve虚拟机id img文件名称 local-lvm
  • 修改IP,输入以下命令快速设置:
    1
    quickstart
  • 旁路有网关设为192.168.XXX.1(主路由IP)
  • 默认用户名:admin,默认密码:password
  • iStoreOS插件下载:地址

三、PVE 换源(建议)

  • 目前使用DG1直通硬解的不要进行换源,更新PVE配置后DG1直通后无法驱动!
  • 注意:这里需要PVE联网正常才可以操作

1、PVE美化(可选项)

  • 显示cpu、nvme、主板温度,来自恩山大佬
    1
    (curl -Lf -o /tmp/temp.sh https://raw.githubusercontent.com/a904055262/PVE-manager-status/main/showtempcpufreq.sh || curl -Lf -o /tmp/temp.sh https://mirror.ghproxy.com/https://raw.githubusercontent.com/a904055262/PVE-manager-status/main/showtempcpufreq.sh) && chmod +x /tmp/temp.sh && /tmp/temp.sh remod

2、PVE 换源(正文)

  • 国内清华源中科大较快,可根据地理位置就近选一个即可

  • 将自带的源文件sources.list备份

    1
    cp /etc/apt/sources.list /etc/apt/sources.list_bak
  • 编辑sources.list文件,注释掉自带的源,添加国内源:

    1
    nano /etc/apt/sources.list
  • PVE版本为6.x清华源

    1
    2
    3
    4
    5
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian buster pve-no-subscription
  • PVE版本为7.x国内源

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #清华源:
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bullseye pve-no-subscription

    #中科大源:
    deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
    deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
    deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
    deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib
    deb https://mirrors.ustc.edu.cn/proxmox/debian bullseye pve-no-subscription
  • PVE版本为8.x国内源

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #清华源:
    deb 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 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 https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
    deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
    deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
    deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
  • 编辑PVE企业源,原句前加#注释掉自带源

    1
    nano /etc/apt/sources.list.d/pve-enterprise.list
  • 添加清华源中科大源(二选一)

    1
    2
    3
    4
    5
    #清华源
    deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bookworm pve-no-subscription

    #中科大源
    deb https://mirrors.ustc.edu.cn/proxmox/debian bookworm pve-no-subscription
  • Ctrl+XY回车退出

  • 修复源401错误,原句前加#注释掉(若无401错误可忽略)

    1
    nano /etc/apt/sources.list.d/ceph.list
  • 添加中科大ceph源

    1
    deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
  • Ctrl+XY回车退出

  • 更新生效

    1
    apt update && apt dist-upgrade -y
    • 更新LXC源(若不需要可跳过)
    • 备份APLInfo.pm
      1
      cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
    • 换源清华源与中科大源二选一
      1
      2
      3
      4
      #清华源
      sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
      #中科大源
      sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
  • 重启服务:

    1
    systemctl restart pvedaemon.service
  • 重启PVE

    1
    reboot

三、开启核显SR-IOV(若需要)

开启SR-IOV项目地址:Github地址

1.1、开启核显SR-IOV

  • 请逐条运行:

    1
    2
    3
    apt install build-* dkms git sysfsutils -y
    apt install proxmox-headers-$(uname -r) proxmox-kernel-$(uname -r)
    cd ~
  • clone代码库(此处需要pve连接github,可试试修改DNS,比如8.8.8.8,8.8.4.4等)

    1
    git clone https://github.com/strongtz/i915-sriov-dkms.git
  • 也可以使用国内镜像代码库(查询是否可用)

    1
    git clone https://gitee.com/ifwwww/i915-sriov-dkms
  • 安装sriov模块,请逐条运行:

    1
    2
    cd ~/i915-sriov-dkms
    dkms add .
  • 文字版教程如下:

    • 这里记录出现的i915-sriov-dkms版本号,比如示范的版本号为“2025.02.03(该版本号会变,请以你的实际版本为准),将下面这行代码中的汉字替换为你的版本号再运行代码:
      1
      dkms install -m i915-sriov-dkms -v 把这里换成版本号 --force
  • 这个运行需要一点时间,请耐心等待

  • 编辑 grub 配置文件

    1
    nano /etc/default/grub
    • quiet 后添加 i915.enable_guc=3 i915.max_vfs=7 的“7”表示可以添加7个虚拟核显(最多7个):
      1
      i915.enable_guc=3 i915.max_vfs=7
    • 键盘按Ctrl+XY回车退出
  • 更新grubinitramfs

    1
    2
    update-grub 
    update-initramfs -u
  • 查看当前核显ID,并记录

    1
    lspci | grep VGA
    • 将上面记录的核显ID替换下面代码中的0000:00:02.0(有可能没有显示0000:,下面的代码中补全即可),sriov_numvfs = 3 中的 3是需要虚拟的核显数量,不能大于7(前边设置的7),添加数量越多同时使用时核显性能越弱,按需选择
      1
      2
      echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 3" > /etc/sysfs.conf
      reboot
  • 重启后,在PVE的Shell中输入以下命令查看SR-IOV核显直通是否成功

    1
    lspci | grep VGA
  • 输出以下数据,表示成功

    1
    2
    3
    4
    0000:00:02.0 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
    0000:00:02.1 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
    0000:00:02.2 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
    0000:00:02.3 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)

1.2、卸载i915-sriov-dkms

  • 使用dpkg卸载package
    1
    dpkg -P i915-sriov-dkms
  • 使用pacman卸载package
    1
    pacman -R i915-sriov-dkms
  • 使用manual卸载dkms模块(下面代码改为自己的版本号,这里以2025.02.03为例)
    1
    dkms remove i915-sriov-dkms/2025.02.03
  • 重启PVE
    1
    reboot

参考博客文章

1、 波仔分享
2、 番茄科技

感谢大佬们的分享!