This repository has been archived on 2026-08-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
pve_toss_notes/PVE初始化配置.md
T

107 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1.更换系统软件源
在上一篇文章中,我们从刚装好的 PVE 系统中获取了系统的一些参数:
![PVE系统信息](img/pve_sys_info.png)
此处显示出 PVE 底层使用的是 Debian的 系统,代号为 “bullseye”。
为了后续能够对 PVE 系统进行升级,需要更换其镜像仓库,也就是大家熟知的软件源。
由于我们目前处于“离线”安装状态,因此更换完软件源后,在没有网络的情况下无法对系统更新。
### 1.1.系统软件源替换
首先对现有的软件源配置进行备份:
```bash
## 进入系统软件源配置文件目录
cd /etc/apt
## 将默认软件源配置文件进行备份
cp sources.list sources.list.bak
```
这里我将使用中国科技大(USTC)的镜像仓库进行替换,使用如下命令:
**注意:该命令为两行,在输入时请逐行输入并回车执行**
```bash
## 替换系统软件仓库
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
```
执行完成后,检查是否执行正确:
```bash
## 输出系统源配置文件,检查是否正确
cat /etc/apt/sources.list
```
如果输出结果中有 USTC 的镜像地址,则表示命令已经正确执行:
```bash
## 输出内容参考:
deb https://mirrors.ustc.edu.cn/debian bullseye main contrib
deb https://mirrors.ustc.edu.cn/debian bullseye-updates main contrib
# security updates
deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib
```
此处我放出 Debian Bullseye 的完整镜像源以供参考, **非常不建议** 将 PVE 的系统源替换成完整的 Debian 源,以避免出现问题。
```bash
## Debian Bullseye 完整源 USTC
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
#deb-src 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-src 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-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
#deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
```
可以看到,PVE 的系统源和 Debian 完整源的差异在于 “non-free” 和 “bullseye-backports”。
如果小伙伴在一些软件或者驱动(比如闭源 GPU 驱动)上遇到问题,可以尝试将PVE的系统源替换成Debian的完整源来尝试解决问题。
### 1.2.PVE 订阅源替换
默认情况下,PVE 启用了一个官方的源,而该源为订阅制收费,我们需要替换为免费的源。
进入订阅源的目录:
**注意:rm 命令为高危险操作命令,请正确使用,请勿手抖,请勿手抖**
```bash
## 进入订阅源目录
cd /etc/apt/sources.list.d
## 删除该目录下的所有配置
rm -rvf *.list
```
创建PVE免费源:
```bash
## 创建PVE免费源
source /etc/os-release
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve $VERSION_CODENAME pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```