Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Last active December 29, 2022 12:19
Show Gist options
  • Save MarshalW/bc186c041c962655b6c0c20881f74a55 to your computer and use it in GitHub Desktop.
Save MarshalW/bc186c041c962655b6c0c20881f74a55 to your computer and use it in GitHub Desktop.
pve 基本使用

pve 基本使用

安装

直接刻盘安装。下载

升级

# 备份 /etc/apt/sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 清空 /etc/apt/sources.list
cat /dev/null > /etc/apt/sources.list

# 设置为清华大学的镜像
cat > /etc/apt/sources.list <<EOF
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb-src 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-src 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-src 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-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
EOF

# 更新
apt update

# 升级
apt full-upgrade

# 查看升级后的版本
pveversion -v

pve 基本命令

命令如下:

# 下载镜像
# 20.04
wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
# 22.04
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

template_id=500
vm_number=1

# 创建模板
qm create $template_id --name temp --memory 2048 --net0 virtio,bridge=vmbr0
qm importdisk $template_id focal-server-cloudimg-amd64.img local-lvm
qm set $template_id --virtio0 local-lvm:vm-$template_id-disk-0
qm set $template_id --boot c --bootdisk virtio0
qm set $template_id --agent 1
qm set $template_id --ide2 local-lvm:cloudinit
qm template $template_id

# 克隆虚拟机
qm clone $template_id 20$vm_number --name p$vm_number

# 修改磁盘大小
qm resize 20$vm_number virtio0  20G 

# 启动虚拟机
qm start 20$vm_number

# 停止虚拟机
qm stop 20$vm_number

# 删除虚拟机
qm destroy 20$vm_number

# 查看磁盘使用情况
pvs

在 Terraform 下使用

创建 terraform 用户、角色和 token:

pveum role add TerraformProv -privs "VM.Allocate VM.Clone VM.Config.CDROM VM.Config.CPU VM.Config.Cloudinit VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Monitor VM.Audit VM.PowerMgmt Datastore.AllocateSpace Datastore.Audit"
pveum user add terraform-prov@pve
pveum aclmod / -user terraform-prov@pve -role TerraformProv
pveum user token add terraform-prov@pve terraform-token --privsep=0

问题

You do not have a valid subscription for this server

You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.

解决办法: https://dannyda.com/2020/05/17/how-to-remove-you-do-not-have-a-valid-subscription-for-this-server-from-proxmox-virtual-environment-6-1-2-proxmox-ve-6-1-2-pve-6-1-2/

sed -i.backup -z "s/res === null || res === undefined || \!res || res\n\t\t\t.data.status.toLowerCase() \!== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

需要清空浏览器缓存(shift+command+r)或者使用无痕模式打开。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment