Bluestone-青石の个人站 - 2024年6月
https://blog.960111.xyz/2024/06/
我还没有去到遥远的地方。
-
PVE的初始配置
https://blog.960111.xyz/archives/44.html
2024-06-09T08:11:00+00:00
一、基本配置1.更新软件源vi /etc/apt/sources.list.d/pve-no-subscription.listdeb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscriptionvi /etc/apt/sources.list# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
2.安装常用软件apt-get updateapt-get upgradeapt-get install vim sudo glances htop net-tools neofetch3.切换普通用户adduser mingusermod -aG sudo mingsu - ming配置环境变量export PATH=$PATH:$HOME/bin:/sbin:/usr/bin:/usr/sbin更换ssh端口并禁止root登录sudo apt-get install firewalldfirewall-cmd --zone=public --add-port=31400/tcp --permanentfirewall-cmd --zone=public --add-port=34100/tcp --permanentfirewall-cmd --zone=public --add-port=8006/tcp --permanentfirewall-cmd --reloadvim /etc/ssh/sshd_config(更改端口,禁止root登录)二、开启硬件直通在/etc/default/grub中修改为GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream i915.enable_guc=3 i915.max_vfs=7"在/etc/modules中添加vfiovfio_iommu_type1vfio_pcivfio_virqfd然后update-grubupdate-initramfs -u -k allreboot检查一下lspci三、重建VM存储1.在数据中心-存储删掉lvm-thin2.删除lvm-thin的pve-data,重建lvm的data并挂载到指定目录lsblk查看目前删除pve-datalvremove /dev/pve/data创建名为vm的新分区lvcreate -L 10G -n vm pve然后扩展到需要的大小lvresize -L 100G /dev/pve/vm或者lvresize -l +100%FREE /dev/pve/vm格式化mkfs.ext4 /dev/pve/vm再挂载到指定的位置mount /dev/pve/vm /data在/etc/fstab写死/dev/pve/vm /data ext4 defaults 0 1在数据中心-存储增加一个存储(目录)vm四、导入虚拟机(硬盘)对于vhdx格式的文件,可以先转换qemu-img convert -O qcow2 Z-8DV.vhdx Z-8DV.qcow2 也可以直接导入qm importdisk 101 Z-8DV.vhdx vm --format=qcow2