ProxmoxVE操作指南(已更新至pve8.0)

pve 使用笔记

安装教程太多而且傻瓜式,直接略过

PVE 第三方手机客户端:点此下载 ProxMon (墙裂建议)

pve 初始设置

设置默认 GUI 语言

1
nano /etc/pve/datacenter.cfg

添加

1
language: zh_CN

更换 debian 源

1
nano /etc/apt/sources.list

sources.list中将原镜像源用#注释,在下方填入以下镜像源 (清华源中科大源二选一)

pve8.xx 版本

1
2
3
4
5
6
7
8
9
10
11
12
13
#清华源

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

pve7.xx 版本

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.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

保存

1
2
ctrl + s
输入y ,回车

更换 pve 源

1
nano /etc/apt/sources.list.d/pve-no-subscription.list

填入 (清华源中科大源二选一)

1
2
3
4
5
6
7
#清华源

deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription

#中科大源

deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription

保存

1
2
ctrl + s
输入y ,回车

添加完成后在 webui 将 pve 默认的企业源禁用

修复 401 错误(有报错才执行)

1
echo "deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list

更新软件包

1
2
apt update
apt upgrade -y

移除无效订阅弹窗

进入 shell

1
sed -i.bak "s/data.status.toLowerCase() !== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js

重启服务

systemctl restart pveproxy

虚拟机或容器假死无法关机

查询虚拟机进程

1
ps -ef|grep "/usr/bin/kvm -id [VM_ID]" |grep -v grep
1
kill [进程_ID]

存储路径

备份路径
1
/var/lib/vz/dump
镜像路径
1
/var/lib/vz/template/iso

虚拟机设置

打开硬件直通

前提 bios 开启 vtd

1
nano /etc/default/grub

找到

1
GRUB_CMDLINE_LINUX_DEFAULT="quiet"

替换为

1
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"

保存

更新 grub

update-grub

如未生效请重启

直通硬盘

查询硬盘识别码

1
ls -la /dev/disk/by-id/|grep -v dm|grep -v lvm|grep -v part
1
qm set [VM_ID] --scsi[x] /dev/disk/by-id/[硬盘_ID]

删除硬盘直通

1
qm set [VM_ID] -delete scsi[x]

Lxc

CT 模板换源

在 pve 控制台执行

1
2
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm

重启服务

1
systemctl restart pvedaemon.service

修改容器配置

在 pve 控制台编辑容器配置文件

1
nano /etc/pve/lxc/[CT_ID].conf

粘贴

1
2
3
lxc.apparmor.profile: unconfined
lxc.cgroup2.devices.allow: a
lxc.cap.drop:

显卡直通

在 pve 控制台执行

1
nano /etc/pve/lxc/[CT_ID].conf

填入参数

1
2
3
4
5
6
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
lxc.apparmor.profile: unconfined

进入容器

检查是否直通成功

1
cd /dev/dri
1
ls

换 Debian 源

1
2
mv /etc/apt/sources.list /etc/apt/sources.list.bk
nano /etc/apt/sources.list

粘贴

1
2
3
4
5
6
7
8
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src 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-src 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-src 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-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

保存

1
2
ctrl + s
输入y ,回车

更新

1
2
apt update
apt upgrade -y

挂载 NAS smb 共享目录

安装 SMB 组件

1
apt install cifs-utils -y

创建共享目录

1
mkdir /mnt/nas

创建密码文件

1
nano ~/.smbcredentials

设置 SMB 登录密码,自行替换:

1
2
username=[用户名]
password=[密码]

修改自动挂载文件

1
nano /etc/fstab

修改挂载路径(一般只修改 smb 共享路径和挂载路径)

1
//[smb_server]/nas /mnt/nas cifs credentials=/root/.smbcredentials,iocharset=utf8 0 0

docker 安装

1
2
apt install curl -y
curl -sSL https://get.daocloud.io/docker | sh

portainer 安装

官方原版

1
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

中文版

1
docker run -d --restart=always --name="portainer" -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data 6053537/portainer-ce

迅雷 docker安装

以下以 /mnt/nas/downloads 为实际的下载保存目录 /mnt/nas/docker/xunlei 为实际的数据保存目录 为例
根据实际情况更改
如果已经安装过的(/mnt/nas/docker/xunlei 目录已存在),再次安装会复用,而且下载目录不可更改,如果要更改下载目录,请把这个目录删掉重新绑定。

1
docker run -d --name=xunlei --hostname=mynas --net=host -v /mnt/nas/docker/xunlei:/xunlei/data -v /mnt/nas/media/downloads:/xunlei/downloads --restart=unless-stopped --privileged cnk3x/xunlei:latest

迅雷 docker 无法启动解决方法

在 pve shell 命令行编辑容器配置文件

1
nano /etc/pve/lxc/[CT_ID].conf

粘贴

1
2
3
lxc.apparmor.profile: unconfined
lxc.cgroup2.devices.allow: a
lxc.cap.drop:

重启容器


ProxmoxVE操作指南(已更新至pve8.0)
https://imgod.me/posts/61099.html
作者
GOD
發布於
2023年1月10日
許可協議