近期重装了PVE,记录下,省的下次重新百度

换源

先提前备份原来的源

debian的apt源

cp /etc/apt/sources.list /etc/apt/sources.list.bak

这里用的中科大源

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

pve订阅源

先注释官方源,这是付费的,我们无法使用
/etc/apt/sources.list.d/pve-enterprise.list

添加中科大的源

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

ceph源

同样先注释里面的内容
/etc/apt/sources.list.d/ceph.list

接着添加这行内容

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

需要注意的是, bookworm 替换成你debian当前版本的代号,这里使用的是最新的debian12

到这,源就替换好了,使用 apt update 更新下源

安装img镜像的系统

可以先通过sftp或者网页上传镜像到pve,接着使用指令

qm importdisk 101 xxx.img local-lvm
其中101为vm ID
xxx.img为镜像路径
local-vm为存储名

接着点击对应的虚拟,点击硬件,最下面可以看到一个未使用的磁盘,双击后点击添加
此时硬盘已经添加到当前虚拟机,不过容器是非常小的(基本和镜像大小一致)
如果需要给硬盘扩容,将鼠标点击到硬盘,接着点击磁盘操作菜单,即可为硬盘扩容

接着点击选项-引导顺序,将创建的硬盘启用并拖到第一个
启动虚拟机完成安装

参考:
https://mirrors.ustc.edu.cn/help/proxmox.html

磁盘管理相关

lvremove /dev/pve/xxx

lvresize -L -100G /dev/pve/root

vgdisplay pve | grep Free