Compare commits

..
6 Commits
Author SHA1 Message Date
CallMeR 126635206a 优化 DNS 配置参数 2026-08-26 00:00:40 +08:00
CallMeR d3715eaf4e 移除过时 Btrfs 部分 2026-08-21 17:32:16 +08:00
CallMeR 66df985278 优化文案描述 2026-08-20 10:17:15 +08:00
CallMeR dfb4a767a8 修复包顺序 2026-08-19 16:47:30 +08:00
CallMeR d0f4ef53a0 精简配置命令 2026-08-18 23:30:03 +08:00
CallMeR 64595e5190 优化文案描述 2026-08-18 02:54:35 +08:00
12 changed files with 36 additions and 133 deletions
+2 -6
View File
@@ -124,14 +124,10 @@ Microsoft 官方终端工具,可以在 Github 平台或 Microsoft 应用商店
此时会出现 `Target Harddisk` 选项,会显示出设备中存在的硬盘列表,可通过下拉框选择安装 PVE 的目标硬盘。 此时会出现 `Target Harddisk` 选项,会显示出设备中存在的硬盘列表,可通过下拉框选择安装 PVE 的目标硬盘。
如需修改文件系统参数,可点击目标硬盘右侧的 `Options` 菜单。若无特殊要求,建议保持系统默认配置。
![PVE选择安装硬盘](img/p01/pve_hd_choose.jpg) ![PVE选择安装硬盘](img/p01/pve_hd_choose.jpg)
点击硬盘列表右侧的 `Options` ,对 PVE 的硬盘安装参数进行一些调整。
推荐将 `Filesystem` 也就是硬盘的文件系统,设置成 `xfs`
![PVE文件系统](img/p01/pve_hd_fs.jpg)
### 1.4. PVE 时区选项 ### 1.4. PVE 时区选项
此时 PVE 处于未联网的 “离线” 状态,因此不会从互联网中读取时区信息,需要手动设置时区。 此时 PVE 处于未联网的 “离线” 状态,因此不会从互联网中读取时区信息,需要手动设置时区。
+1 -1
View File
@@ -160,7 +160,7 @@ $ apt full-upgrade
$ apt update $ apt update
## 安装系统软件 ## 安装系统软件
$ apt install btop curl knot-dnsutils lm-sensors neovim powermgmt-base unattended-upgrades sshguard tmux $ apt install btop curl knot-dnsutils lm-sensors neovim powermgmt-base sshguard tmux unattended-upgrades
## 安装 CPU 调度调整工具 ## 安装 CPU 调度调整工具
$ apt install linux-cpupower $ apt install linux-cpupower
+17 -104
View File
@@ -27,11 +27,8 @@ update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。 若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash ```bash
## 创建 nvim 配置目录
$ mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本 ## 配置 nvim 鼠标交互行为脚本
$ tee /etc/xdg/nvim/sysinit.vim >/dev/null <<'EOF' $ install -D -m 0644 /dev/stdin /etc/xdg/nvim/sysinit.vim <<'EOF'
set mouse= set mouse=
EOF EOF
``` ```
@@ -140,11 +137,11 @@ analyzing CPU 0:
Active: yes Active: yes
``` ```
这里面主要关注两个点: 这里面主要关注如下几点:
- `driver` CPU 调频驱动方案,例如 `intel_cpufreq``intel_pstate` - `driver` CPU 调频驱动方案,例如 `intel_cpufreq``intel_pstate`
- `governor` :调频策略中使用的调度器,例如 `performance` - `governor` :调频策略中使用的调度器,例如 `performance`
- CPU 驱动为 `intel_cpufreq` 时,推荐使用 `schedutil` 调度器
- CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器
CPU 驱动一般不建议手动调整,而 `governor` 后面的参数表示 CPU 当前调度器设置。 CPU 驱动一般不建议手动调整,而 `governor` 后面的参数表示 CPU 当前调度器设置。
@@ -161,26 +158,7 @@ conservative ondemand userspace powersave performance schedutil
performance powersave performance powersave
``` ```
根据 CPU 所使用的驱动不同,可选调度器也不同,至于每种调度器有什么优劣,欢迎大家深度挖掘 本文通过 systemd 服务自动管理 `cpupower` ,服务启动时将 CPU 调度器设置为 `powersave` ,停止时恢复为 `performance`
- CPU 驱动为 `intel_cpufreq` 时,推荐使用 `schedutil` 调度器。
- CPU 驱动为 `intel_pstate` 时,推荐使用 `powersave` 调度器。
本文使用 `powersave` 调度器创建 `cpupower` 的配置文件。
```bash
## 创建 cpupower 默认配置文件
$ tee /etc/default/cpupower >/dev/null <<'EOF'
# This configuration file is customized by fox,
# Optimize CPU governor settings.
CPUPOWER_START_OPTS="frequency-set -g powersave"
CPUPOWER_STOP_OPTS="frequency-set -g performance"
EOF
```
进一步创建 `cpupower` 服务配置文件,以满足系统自动化设置需求。
```bash ```bash
## 创建 cpupower.service 配置文件 ## 创建 cpupower.service 配置文件
@@ -193,13 +171,11 @@ $ systemctl edit --force --full cpupower.service
[Unit] [Unit]
Description=CPU Power Governor Management Description=CPU Power Governor Management
ConditionVirtualization=!container ConditionVirtualization=!container
After=syslog.target
[Service] [Service]
Type=oneshot Type=oneshot
EnvironmentFile=/etc/default/cpupower ExecStart=/usr/bin/cpupower frequency-set --governor powersave
ExecStart=/usr/bin/cpupower $CPUPOWER_START_OPTS ExecStop=/usr/bin/cpupower frequency-set --governor performance
ExecStop=/usr/bin/cpupower $CPUPOWER_STOP_OPTS
RemainAfterExit=yes RemainAfterExit=yes
[Install] [Install]
@@ -283,24 +259,15 @@ $ editor /etc/apt/apt.conf.d/50unattended-upgrades
``` ```
配置文件中,被修改的参数解释如下: 配置文件中,被修改的参数解释如下:
- 启用了 Debian `trixie-updates` 相关更新
- 启用了 Debian `trixie-updates` 相关更新 - 增加并启用 PVE 自有仓库的更新
- 增加并启用 PVE Ceph 仓库的更新,请按需启用
- 增加并启用 PVE 自有仓库的更新。 - 自动修复被打断的 Dpkg 安装
- 自动移除无用的的内核包
- 增加并启用 PVE Ceph 仓库的更新,请按需启用。 - 自动移除因更新而出现的无用依赖包
- 自动移除以前的无用依赖包
- 自动修复被打断的 Dpkg 安装。 - 自动重启:开启
- 自动重启时间:`02:30`
- 自动移除无用的的内核包。
- 自动移除因更新而出现的无用依赖包。
- 自动移除以前的无用依赖包。
- 自动重启:开启。
- 自动重启时间:`02:30`
因为该配置文件很长,完整的配置文件可查看 [pve_50unattended_upgrades.conf](./src/pve/pve_50unattended_upgrades.conf) 以便对比。 因为该配置文件很长,完整的配置文件可查看 [pve_50unattended_upgrades.conf](./src/pve/pve_50unattended_upgrades.conf) 以便对比。
@@ -505,61 +472,7 @@ $ find /sys/kernel/iommu_groups/ -type l
/sys/kernel/iommu_groups/9/devices/0000:00:14.1 /sys/kernel/iommu_groups/9/devices/0000:00:14.1
``` ```
## 5. BTRFS 调整 ## 5.系统清理
**额外说明:**
- 本节专为 `BTRFS` 单盘 `RAID0`(条带模式)安装的 PVE 系统设计,使用其他安装模式时,请跳过此节
- `BTRFS` 文件系统当前仍为技术预览状态,请谨慎操作
- 有关在 PVE 中使用 `BTRFS` 的详情,请参阅 [Proxmox VE - BTRFS](https://pve.proxmox.com/wiki/BTRFS)
安装 PVE 时,若使用了 `BTRFS` 单盘 `RAID0` 的安装模式,系统默认未启用 swap 和 zstd 压缩,需要手动开启。
通常情况下,内存与 swap 的 **推荐** 比例为 `1:1` 。本机具有 `16GB` 内存,因此设置 `16GB` swap 空间。
执行以下命令,在 `BTRFS` 文件系统中创建子卷,并配置激活 swapfile 。
```bash
## 创建用于存放交换文件的子卷
$ btrfs subvolume create /swap
## 在子卷中创建 16GB 的交换文件
$ btrfs filesystem mkswapfile --size 16g --uuid clear /swap/swapfile
## 激活交换文件
$ swapon /swap/swapfile
```
此时还需进一步修改系统的 `fstab` 配置文件,以启用 `BTRFS` 的 zstd 压缩功能并确保 swap 在系统启动时自动激活。
```bash
## 编辑 fstab 配置文件
$ editor /etc/fstab
```
`fstab` 为系统关键配置文件,直接影响系统启动,修改此文件时,请注意以下几点:
- 仅修改根目录 `/` 对应的挂载选项,添加 `compress=zstd` 参数。
- 在文件末尾新增一行,添加 swap 的自动挂载。
-**不要** 修改其余配置参数,尤其是设备的唯一标识符( `UUID` ),切勿修改。
修改完成后,示例如下。
```bash
#### 系统 fstab 示例配置
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=<DO-NOT-EDIT-YOUR-UUID> / btrfs defaults,compress=zstd 0 1
UUID=<YOUR-UUID> /boot/efi vfat defaults 0 1
proc /proc proc defaults 0 0
/swap/swapfile none swap defaults 0 0
```
## 6.系统清理
PVE 系统配置完成后,可执行以下命令,对系统进行清理。 PVE 系统配置完成后,可执行以下命令,对系统进行清理。
+2 -2
View File
@@ -168,7 +168,7 @@ unused0: successfully imported disk 'local-lvm:vm-1001-disk-2'
![虚拟机使用该磁盘](img/p04/vm_enable_hd.jpg) ![虚拟机使用该磁盘](img/p04/vm_enable_hd.jpg)
导入的镜像仅具备 `3G` 磁盘空间,为方便后续使用,可通过 `qm` 命令直接将该磁盘调整至目标容量。 导入的镜像仅具备 `3GiB` 磁盘空间,为方便后续使用,可通过 `qm` 命令直接将该磁盘调整至目标容量。
```bash ```bash
## 将镜像容量设置为 24G ## 将镜像容量设置为 24G
@@ -183,7 +183,7 @@ $ qm disk resize 1001 scsi0 24G
![虚拟机磁盘扩容](img/p04/vm_hd_resize.jpg) ![虚拟机磁盘扩容](img/p04/vm_hd_resize.jpg)
在弹出的对话框中,给该磁盘增加 `21G` 磁盘空间。 在弹出的对话框中,给该磁盘增加 `21GiB` 磁盘空间。
![虚拟机磁盘增加18G](img/p04/vm_hd_scale_up.jpg) ![虚拟机磁盘增加18G](img/p04/vm_hd_scale_up.jpg)
+1 -4
View File
@@ -162,11 +162,8 @@ update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。 若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash ```bash
## 创建 nvim 配置目录
$ sudo mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本 ## 配置 nvim 鼠标交互行为脚本
$ sudo tee /etc/xdg/nvim/sysinit.vim >/dev/null <<'EOF' $ sudo install -D -m 0644 /dev/stdin /etc/xdg/nvim/sysinit.vim <<'EOF'
set mouse= set mouse=
EOF EOF
``` ```
+3 -2
View File
@@ -102,6 +102,8 @@ $ sudo tee /etc/systemd/resolved.conf.d/10-server-dns.conf >/dev/null <<'EOF'
DNS=127.0.0.1 DNS=127.0.0.1
DNS=::1 DNS=::1
DNSStubListener=no DNSStubListener=no
LLMNR=no
MulticastDNS=no
EOF EOF
``` ```
@@ -383,7 +385,7 @@ server-https https://doh.360.cn/dns-query -fallback
``` ```
`SmartDNS` 主配置文件配置完成后,执行以下命令修正文件权限 `SmartDNS` 主配置文件配置完成后,执行以下命令修正文件权限
```bash ```bash
## 修正 SmartDNS 主配置文件权限 ## 修正 SmartDNS 主配置文件权限
@@ -436,7 +438,6 @@ no-hosts
no-ident no-ident
no-resolv no-resolv
no-round-robin no-round-robin
rebind-localhost-ok
stop-dns-rebind stop-dns-rebind
rebind-domain-ok=/fox.internal/ rebind-domain-ok=/fox.internal/
+5 -7
View File
@@ -168,11 +168,8 @@ update-alternatives: using /usr/bin/nvim to provide /usr/bin/editor (editor) in
若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。 若需完全禁用 `neovim` 鼠标功能;即关闭所有鼠标交互,右键行为完全交给终端 / 控制台处理,需执行以下命令。
```bash ```bash
## 创建 nvim 配置目录
$ sudo mkdir -p /etc/xdg/nvim
## 配置 nvim 鼠标交互行为脚本 ## 配置 nvim 鼠标交互行为脚本
$ sudo tee /etc/xdg/nvim/sysinit.vim >/dev/null <<'EOF' $ sudo install -D -m 0644 /dev/stdin /etc/xdg/nvim/sysinit.vim <<'EOF'
set mouse= set mouse=
EOF EOF
``` ```
@@ -446,6 +443,8 @@ $ sudo tee /etc/systemd/resolved.conf.d/10-server-dns.conf >/dev/null <<'EOF'
DNS=127.0.0.1 DNS=127.0.0.1
DNS=::1 DNS=::1
DNSStubListener=no DNSStubListener=no
LLMNR=no
MulticastDNS=no
EOF EOF
``` ```
@@ -522,9 +521,8 @@ no-hosts
no-ident no-ident
no-resolv no-resolv
no-round-robin no-round-robin
rebind-localhost-ok
stop-dns-rebind stop-dns-rebind
rebind-domain-ok=/fox.internal/ rebind-domain-ok=/fox.internal/ts.net/
# DNS Filter # DNS Filter
@@ -542,8 +540,8 @@ local=/test/
# DNS Server # DNS Server
server=/ts.net/100.100.100.100
server=/fox.internal/172.16.1.1 server=/fox.internal/172.16.1.1
server=/ts.net/100.100.100.100
server=172.16.1.1 server=172.16.1.1
``` ```
Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 KiB

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 KiB

After

Width:  |  Height:  |  Size: 474 KiB

-1
View File
@@ -19,7 +19,6 @@ no-hosts
no-ident no-ident
no-resolv no-resolv
no-round-robin no-round-robin
rebind-localhost-ok
stop-dns-rebind stop-dns-rebind
rebind-domain-ok=/fox.internal/ rebind-domain-ok=/fox.internal/
+2 -3
View File
@@ -19,9 +19,8 @@ no-hosts
no-ident no-ident
no-resolv no-resolv
no-round-robin no-round-robin
rebind-localhost-ok
stop-dns-rebind stop-dns-rebind
rebind-domain-ok=/fox.internal/ rebind-domain-ok=/fox.internal/ts.net/
# DNS Filter # DNS Filter
@@ -39,7 +38,7 @@ local=/test/
# DNS Server # DNS Server
server=/ts.net/100.100.100.100
server=/fox.internal/172.16.1.1 server=/fox.internal/172.16.1.1
server=/ts.net/100.100.100.100
server=172.16.1.1 server=172.16.1.1