更新 PVE 初始化配置

This commit is contained in:
CallMeR
2023-06-24 12:24:27 +08:00
parent dde5487fcf
commit 512f178314
+48 -55
View File
@@ -1,30 +1,46 @@
## 1.更换系统软件源
## 1.更换软件源
在上一篇文章 [01.PVE系统安装](./01.PVE系统安装.md) 中,我们从刚装好的 PVE 系统中获取了系统的一些参数:
在上一篇文章 [01.PVE系统安装](./01.PVE系统安装.md) 中,从刚装好的 PVE 系统中获取了系统的一些参数:
![PVE系统信息](img/p01/pve_sys_info.png)
![PVE系统信息](img/p01/pve_sys_info.jpeg)
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `bullseye`
此处显示出 PVE 底层使用的是 Debian 的系统,代号为 `bookworm`
为了后续能对 PVE 系统进行升级,需要更换其镜像仓库,也就是大家熟知的软件源。
为了后续能对 PVE 系统进行升级,需要更换其镜像仓库,也就是大家熟知的软件源。
由于我们目前处于 **“离线”** 安装状态,因此更换完软件源后,在没有网络的情况下无法对系统更新。
由于目前处于 **“离线”** 安装状态,因此更换完软件源后,在没有网络的情况下无法对系统更新。
### 1.1.系统软件源替换
### 1.1.系统软件源
使用 SSH 工具登录到 PVE 服务器,首先对现有的软件源配置进行备份:
使用 SSH 工具登录到 PVE 服务器,首先对现有的软件源配置进行备份:
```bash
## 进入系统软件源配置文件目录
cd /etc/apt
## 查看系统默认镜像配置
cat sources.list
## 将默认软件源配置文件进行备份
cp sources.list sources.list.bak
cp sources.list sources.list.bak
```
系统默认镜像配置记录如下:
```bash
deb http://ftp.debian.org/debian bookworm main contrib
deb http://ftp.debian.org/debian bookworm-updates main contrib
# security updates
deb http://security.debian.org bookworm-security main contrib
```
这里我将使用 [中国科技大(USTC](http://mirrors.ustc.edu.cn/help/proxmox.html) 的镜像仓库进行替换,使用如下命令:
**注意:该命令为两行,在输入时请逐行输入并回车执行**
**注意:该命令为两行,在输入时请逐行输入并回车执行**
执行完成后,检查是否执行正确,如果输出结果中有 USTC 的镜像地址,则表示命令已经正确执行。
```bash
## 替换系统软件仓库
@@ -35,55 +51,24 @@ sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian
```
执行完成后,检查是否执行正确
如果希望能更新 CPU 的 `microcode` ,则需要手动添加镜像 `non-free``non-free-firmware` 参数,完整系统源示例如下
```bash
## 输出系统源配置文件,检查是否正确
cat /etc/apt/sources.list
```
deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
如果输出结果中有 USTC 的镜像地址,则表示命令已经正确执行。
如果希望能更新 CPU 的 `microcode` ,则需要手动添加镜像的 `non-free` 参数,完整系统源示例如下:
```bash
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/ bookworm-updates main contrib non-free non-free-firmware
# security updates
deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
```
此处我放出 Debian Bullseye 的完整镜像源以供参考, **非常不建议** 将 PVE 的系统源替换成完整的 Debian 源,以避免系统故障。
### 1.2. PVE 软件源
```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 驱动)上遇到麻烦,才需尝试 Debian 的完整镜像源。
### 1.2.PVE 订阅源替换
默认情况下,PVE 启用了一个官方的源,而该源为订阅制收费,我们需要替换为免费的源。
默认情况下,PVE 启用了 2 个官方的源,而该源为订阅制收费,我们需要替换为免费的源。
进入订阅源的目录:
**注意:rm 命令为高危险操作命令,请正确使用,请勿手抖,请勿手抖**
**注意:rm 命令为高危险操作命令,请正确使用,请勿手抖,请勿手抖**
```bash
## 进入订阅源目录
@@ -95,32 +80,40 @@ 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
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy $VERSION_CODENAME no-subscription" > /etc/apt/sources.list.d/ceph-no-subscription.list
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve $VERSION_CODENAME pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```
创建完成后对其进行检查:
创建完成后对其进行检查:
```bash
## 检查PVE免费源
cat /etc/apt/sources.list.d/pve-no-subscription.list
cat /etc/apt/sources.list.d/ceph-no-subscription.list
cat /etc/apt/sources.list.d/pve-no-subscription.list
```
如果输出结果中有 USTC 的镜像地址,则表示命令已经正确执行:
```bash
## 输出内容参考:
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bullseye pve-no-subscription
## Ceph
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
## PVE
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
```
### 1.3.PVE CT Templates 替换
### 1.3. PVE CT
如果需要使用 Proxmox 网页端下载 CT Templates,可以替换 CT Templates 的源。
@@ -135,7 +128,7 @@ sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /us
```
如果修改了 CT Templates 地址,需要重启 PVE 服务器才能生效。
如果修改了 CT Templates 地址,需要重启 PVE 服务器才能生效。
### 1.4.替换后操作