From c6c02fb6fcc8a6c91750e5616628a18233178f77 Mon Sep 17 00:00:00 2001 From: CallMeR <9463297+callmer@user.noreply.gitee.com> Date: Sun, 25 Jun 2023 15:00:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20PVE=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03.PVE系统调整.md | 144 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 5 deletions(-) diff --git a/03.PVE系统调整.md b/03.PVE系统调整.md index 30a11a8..54f0b27 100644 --- a/03.PVE系统调整.md +++ b/03.PVE系统调整.md @@ -40,7 +40,7 @@ timedatectl set-timezone Asia/Shanghai date -R ## 参考输出 -Wed, 20 Jul 2022 16:21:28 +0800 +Sun, 25 Jun 2023 12:12:12 +0800 ``` Debian 系统常用 `systemd-timesyncd.service` 来同步时间,而 PVE 系统使用 `chrony.service` 来同步时间。 @@ -287,11 +287,13 @@ APT::Periodic::CleanInterval "1"; 进一步调整 apt 的 `50unattended-upgrades` 配置文件,其中被修改的参数解释如下。 -- 启用了 Debian bullseye-updates 相关更新。 +- 启用了 Debian `bookworm-updates` 相关更新。 -- 增加并启用 PVE 自有仓库的更新,确保不会遗漏自有仓库的更新内容。 +- 增加并启用 PVE 自有仓库的更新。 -- 自动修复被打断的Dpkg安装。 +- 增加并启用 PVE Ceph 仓库的更新,请按需启用。 + +- 自动修复被打断的 Dpkg 安装。 - 自动移除无用的的内核包。 @@ -301,7 +303,7 @@ APT::Periodic::CleanInterval "1"; - 自动重启:开启。 -- 自动重启时间:05:00。 +- 自动重启时间:05:00 。 因为该配置文件很长,完整的配置文件可查看 [pve_50unattended_upgrades.conf](./src/pve_50unattended_upgrades.conf) 以便对比。 @@ -372,4 +374,136 @@ Jun 25 14:35:06 node01 systemd[1]: Stopping apt-daily-upgrade.timer - Daily apt Jun 25 14:35:06 node01 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities. ``` +## 5.硬件直通 + +### 5.1.修改 Grub + +参考官方文档 [qm_pci_passthrough](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_pci_passthrough) 和 [Pci passthrough](https://pve.proxmox.com/wiki/Pci_passthrough) 开启 PVE 硬件直通功能。 + +使用 SSH 工具登录到 PVE 服务器,编辑系统 `Grub` 的配置文件 `/etc/default/grub` 。 + +```bash +## 编辑 Grub 配置文件 +nano /etc/default/grub +``` + +在 `nano` 编辑器对话框中修改 `GRUB_CMDLINE_LINUX_DEFAULT` 参数,注意命令中间的空格。 + +```bash +## Intel 处理器添加参数 +GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt" +``` + +根据官方文档的说明,AMD 处理器下硬件直通功能将会自动打开,否则需要手动修改 `Grub` 配置文件。 + +```bash +## AMD 处理器添加参数 +GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt" +``` + +修改并保存后,需要更新系统 `Grub` 。 + +```bash +## 更新系统 Grub +update-grub +``` + +### 5.2.添加内核模块 + +修改系统 `/etc/modules` 配置文件,增加必要的系统模块。 + +```bash +## 编辑系统配置文件 +nano /etc/modules +``` + +在配置文件末尾输入以下内容。 + +```txt +vfio +vfio_iommu_type1 +vfio_pci +vfio_virqfd +``` + +将配置文件保存,并重启 PVE 服务器。 + +### 5.3.检查硬件直通 + +PVE 服务器重启完成后,再次使用 SSH 工具登录,并使用以下命令检查硬件直通状态。 + +```bash +## 检查系统硬件直通状态 +dmesg | grep -e DMAR -e IOMMU -e AMD-Vi +``` + +检查 `IOMMU` 、 `Directed I/O` 或 `Interrupt Remapping` 的启用状态。 + +N5105 处理器示例输出如下: + +```txt +[ 0.016437] ACPI: DMAR 0x00000000787BF000 000088 (v02 INTEL EDK2 00000002 01000013) +[ 0.016472] ACPI: Reserving DMAR table memory at [mem 0x787bf000-0x787bf087] +[ 0.052437] DMAR: IOMMU enabled +[ 0.144431] DMAR: Host address width 39 +[ 0.144432] DMAR: DRHD base: 0x000000fed90000 flags: 0x0 +[ 0.144439] DMAR: dmar0: reg_base_addr fed90000 ver 4:0 cap 1c0000c40660462 ecap 49e2ff0505e +[ 0.144441] DMAR: DRHD base: 0x000000fed91000 flags: 0x1 +[ 0.144446] DMAR: dmar1: reg_base_addr fed91000 ver 1:0 cap d2008c40660462 ecap f050da +[ 0.144449] DMAR: RMRR base: 0x0000007b800000 end: 0x0000007fbfffff +[ 0.144452] DMAR-IR: IOAPIC id 2 under DRHD base 0xfed91000 IOMMU 1 +[ 0.144453] DMAR-IR: HPET id 0 under DRHD base 0xfed91000 +[ 0.144454] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping. +[ 0.146335] DMAR-IR: Enabled IRQ remapping in x2apic mode +[ 0.333509] pci 0000:00:02.0: DMAR: Skip IOMMU disabling for graphics +[ 0.410824] DMAR: No ATSR found +[ 0.410824] DMAR: No SATC found +[ 0.410826] DMAR: IOMMU feature fl1gp_support inconsistent +[ 0.410827] DMAR: IOMMU feature pgsel_inv inconsistent +[ 0.410829] DMAR: IOMMU feature nwfs inconsistent +[ 0.410829] DMAR: IOMMU feature pds inconsistent +[ 0.410830] DMAR: IOMMU feature eafs inconsistent +[ 0.410831] DMAR: IOMMU feature prs inconsistent +[ 0.410831] DMAR: IOMMU feature nest inconsistent +[ 0.410832] DMAR: IOMMU feature mts inconsistent +[ 0.410832] DMAR: IOMMU feature sc_support inconsistent +[ 0.410833] DMAR: IOMMU feature dev_iotlb_support inconsistent +[ 0.410835] DMAR: dmar0: Using Queued invalidation +[ 0.410838] DMAR: dmar1: Using Queued invalidation +[ 0.412755] DMAR: Intel(R) Virtualization Technology for Directed I/O +``` + +检查系统 `IOMMU` 分组。 + +```bash +## 检查 IOMMU group +find /sys/kernel/iommu_groups/ -type l +``` + +示例输出如下。 + +```txt +/sys/kernel/iommu_groups/7/devices/0000:00:1c.4 +/sys/kernel/iommu_groups/15/devices/0000:04:00.0 +/sys/kernel/iommu_groups/5/devices/0000:00:17.0 +/sys/kernel/iommu_groups/13/devices/0000:02:00.0 +/sys/kernel/iommu_groups/3/devices/0000:00:14.2 +/sys/kernel/iommu_groups/3/devices/0000:00:14.0 +/sys/kernel/iommu_groups/11/devices/0000:00:1f.0 +/sys/kernel/iommu_groups/11/devices/0000:00:1f.5 +/sys/kernel/iommu_groups/11/devices/0000:00:1f.3 +/sys/kernel/iommu_groups/11/devices/0000:00:1f.4 +/sys/kernel/iommu_groups/1/devices/0000:00:02.0 +/sys/kernel/iommu_groups/8/devices/0000:00:1c.5 +/sys/kernel/iommu_groups/16/devices/0000:05:00.0 +/sys/kernel/iommu_groups/6/devices/0000:00:1c.0 +/sys/kernel/iommu_groups/14/devices/0000:03:00.0 +/sys/kernel/iommu_groups/4/devices/0000:00:16.0 +/sys/kernel/iommu_groups/12/devices/0000:01:00.0 +/sys/kernel/iommu_groups/2/devices/0000:00:04.0 +/sys/kernel/iommu_groups/10/devices/0000:00:1c.7 +/sys/kernel/iommu_groups/0/devices/0000:00:00.0 +/sys/kernel/iommu_groups/9/devices/0000:00:1c.6 +``` + 至此 PVE 的系统调整已经完成。