流浪Ubuntu计划
设计思路
目标:将物理机3090的Ubuntu系统无损迁入PVE环境下,实现由物理机到虚拟机的迁移
流程:先在arch linux将目标机的物理磁盘转换为虚拟磁盘,再安装Proxmox,加入集群后安装VM
前置工作:Ventoy将移动硬盘制作成多系统启动盘,在里面放入archlinux-2025.05.01-x86_64.iso
和proxmox-ve_8.4-1.iso
,还需要一个外置网卡(例如拓展坞),需要注意的是对于archlinux镜像文件,要先将安装好qemu-img的linux系统打包成镜像
实现步骤
磁盘转换
挂载接入的物理磁盘sda里的sda3分区到指定目录/mnt/sda1
fdisk -l
cd /mnt && mkdir sda1
cd sda1
mount /dev/sda3 /mnt/sda1
df -h
然后使用qemu-img
将物理磁盘的disk名/dev/nvme0n1
压缩并转成qcow2
格式的虚拟磁盘vm3090.qcow2
qemu-img convert -c -O qcow2 /dev/nvme0n1 vm3090.qcow2 -p
老李说再check一下img
qemu-img check vm3090.qcow2
ok没问题,接下来安装Proxmox
Proxmox安装
初始化pve
reboot然后加载pve的img
踩坑点1:在加载Proxmox镜像时卡在 loading drivers 处
PVE纵览-安装系统卡“Loading Driver”的快速解决方案
Adding the nomodeset Kernel Parameter
官方解释如下
Problems may arise on very old or very new hardware due to graphics drivers. If the installation hangs during boot, you can try adding the nomodeset parameter. This prevents the Linux kernel from loading any graphics drivers and forces it to continue using the BIOS/UEFI-provided framebuffer.
On the Proxmox VE bootloader menu, navigate to
Install Proxmox VE (Terminal UI)
and presse
to edit the entry. Using the arrow keys, navigate to the line starting with linux, move the cursor to the end of that line and add the parameter nomodeset, separated by a space from the pre-existing last parameter.Then press
Ctrl-X
orF10
to boot the configuration.
bootloader界面选择Graphical
,然后在GUI界面按e
编辑启动参数,加入参数
nomodeset
ctrl + x
保存后自动boot
踩坑点1.5:在初始化时遇到网络无法连接的问题
PVE必须占用1张有线网卡,但没装驱动无法识别本机上的r8125,只能接拓展坞的外置网卡
开始初始化
初始化设置password
,接着是 Hostname pve3090.lan
和 IP Address 192.168.8.4
,注意IP Address根据自己的需求来,这里是用的预留IP Address
结束初始化
替换Debian和PVE的软件源
pve里vi不好用,用的nano
nano /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
ctrl-x
保存,Y
确认,Enter
结束
类似的操作
nano /etc/apt/sources.list.d/pve-no-subscription.list
然后复制
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
保存同上
再在Proxmox WebUI端打开本结点pve3090
,中间选择Updates
-Repositories
,将enterprise开头的两个源Disable
后Reload
https://enterprise.proxmox.com/debian/ceph-quincy
https://enterprise.proxmox.com/debian/pve
更新apt
apt update
给pve安装有线网卡驱动
查看网卡型号
lspci | grep Ethernet
07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 0c)
下载并安装对应网卡r8125的驱动
wget https://github.com/awesometic/realtek-r8125-dkms/releases/download/9.015.00-1/realtek-r8125-dkms_9.015.00-1_amd64.deb
踩坑点2:在编译安装时遇到missing headers
这个是缺少kernel headers,需要提前安装pve的headers
安装完pve-headers
后再安装
apt update && apt install pve-headers
apt install ./realtek-r8125-dkms_9.015.00-1_amd64.deb
踩坑点3:驱动打上了但 ifconfig 无法看到新网卡
查看网卡时发现没有新网卡添加进来,尝试查看所有网卡和驱动安装情况
ifconfig -a
lsmod | grep 8125
modinfo r8125
没有发现问题,后面老李提到,之前apt update是有更新kernel的,在安装驱动时编译到新的内核里面了,现在用的是旧内核
查看日志发现果然如此
uname -a
reboot
重启后恢复正常
回到Proxmox WebUI界面,在System
-Network
里把虚拟网卡桥接到物理网卡上,这里我是把vmbr0
的Linux Bridge
桥接到了enp7s0
的Network Device
,最后把刚才用到的拓展坞网卡删去即可
Proxmox操作
加入集群
操作简单不再赘述
创建VM
右上角Create VM
General:填写Node名字,VM ID不需要动
OS:选Do not use any media
system:Graphic Card默认default
,machine选q35
,BIOS选OVMF(UEFI)
Disks:删除默认的配置,直接next
CPU:type选host
,cores选了个8
Memory:搞了个大的16384MiB
Network:用的上面设置好的vmbr0
这样就创建好了VM
挂载磁盘并实现lvm存储转目录
PVE 基于 QCOW2 格式进行虚拟机硬盘迁移,实现 lvm 存储转目录
比较简单
fdisk -l
cd /mnt/
mkdir sda3
mount /dev/sda3 /mnt/sda3
cd ./sda3/
qm disk import 105 vm3090.qcow2 local-lvm
这样就实现了Physical-to-Virtual Migration
Q.E.D.