Physical Linux installation run as a VM in Proxmox

I’ve had Proxmox running for a few years with plenty of VMs and Containers (Linux, MacOS, Windows, etc) and I’ve passed through GPUs, USB devices, and physical hard drives . What I’ve not been able to do is run a physical Linux installation as a VM.

  1. I thought I could create a Linux VM and then boot from a physical hard drive much like booting from an iso… no success.

  2. I’ve seen instructions for migrating a physical installation to a VM, but I’d like to run from the hard drive. This is my “goto” Linux installation that I plugin to check old hardware. I’d like to run it from Proxmox server and then eject it when I need it for hardware testing.

Has anyone had any success? I’ve done quite a bit of searching and there is probably an obvious guide that I’ve overlooked.

Thanks!

This should be possible. Pass the hard drive and boot off an iso. Chroot into the system on the hard drive and recreate your initramfs images. Also maybe reinstall the bootloader(grub2 for instance). The only tricky thing might be the hard drive swapping. If you take it out I’m not sure if PVE will keep the drive associated to the VM.

Are you passing the whole, existing, already installed HDD through to the VM?

Perhaps you need a vm efi partition for a uefi bootloader? Just a shot in the dark?

Not tried it myself, but am curios now…

Thank you for the replies. I discovered my problem… I had a corrupted EFI partition/broken grub. Bottomline, you can easily mount and run Linux off an external drive as a PVE VM. It would also appear that you can install a fresh Linux OS on an external VM, though I haven’t tested this theory.

I’ll briefly describe by scenario and the fix incase it may be of assistance to someone down the line.


BACKGROUND

I have two Proxmox systems: 1) My homelab which provides “essential” home services, and 2) an old motherboard that I used as a “sandbox”. The sandbox, an Intel DH57JG motherboard w/ a very old i5 processor, has a corrupted bios and is therefore dead.
In the sandbox, I would swap between an SSD with a PVE installation and an Ubuntu Mint SSD depending on my needs. This obscured the problem… that along the way the Ubuntu Mint EFI & grub were corrupted.


Prerequisite
Upload the Ubuntu Installer via web upload > Download from URL > https://mirror.math.princeton.edu/pub/ubuntu-iso/23.10.1/ubuntu-23.10.1-desktop-amd64.iso


Create the VM (I’m using id: 140)
cat /etc/pve/qemu-server/140.conf

agent: 1
balloon: 2048
bios: ovmf
boot: order=sata0;ide2
cores: 2
cpu: host
efidisk0: taichi-zfs:vm-140-disk-1,efitype=4m,pre-enrolled-keys=1,size=1M
ide2: store:iso/ubuntu-23.10.1-desktop-amd64.iso,media=cdrom,size=5052730K
memory: 8192
meta: creation-qemu=7.2.0,ctime=1692982877
name: TaichiLinuxPT
net0: virtio=9A:CB:A9:F6:1A:84,bridge=vmbr0,firewall=1
numa: 1
ostype: l26
sata0: /dev/disk/by-id/ata-TOSHIBA_THNSNJ128GCST_747S104JTRAY,backup=0,replicate=0,size=125034840K
scsi0: taichi-zfs:vm-140-disk-0,cache=writeback,discard=on,iothread=1,size=32G,ssd=1 # This drive may be removed
scsihw: virtio-scsi-single
smbios1: uuid=2de1f8e9-bab3-4534-94f6-a27e5e60095a
sockets: 1
spice_enhancements: foldersharing=1,videostreaming=all
vga: qxl
vmgenid: ff9603e3-86e2-4469-a6e0-db08a0b02281


Passthrough Harddrive
In PVE terminal, identify the drive to passthrough

lsblk -o NAME,MODEL,SERIAL,SIZE,LABEL,UUID,FSTYPE
NAME      MODEL                   SERIAL                    SIZE LABEL       UUID                                   FSTYPE
sda       TOSHIBA THNSNJ128GCST   747S104JTRAY            119.2G
├─sda1                                                      512M
└─sda2                                                    118.7G Thin_Data   e3986daa-858c-4ae6-a882-4fa2c53a6652   ext4
...

Determine the disk id

ls /dev/disk/by-id/
...
ata-KINGSTON_SVP100S2256G_Y1BS106WTEUZ-part1  ata-TOSHIBA_MK5055GSX_79MLS54ZS-part1               wwn-0x50024e9205859f9a
ata-KINGSTON_SVP100S2256G_Y1BS106WTEUZ-part9  ata-TOSHIBA_THNSNJ128GCST_747S104JTRAY              wwn-0x50024e9205859f9a-part1
ata-Optiarc_BD_ROM_BC-5640H                   ata-TOSHIBA_THNSNJ128GCST_747S104JTRAY-part1        wwn-0x50024e9205859f9a-part2
...

Mount full physical drive (vs partitions).
qm set 140 -sata0 /dev/disk/by-id/ata-TOSHIBA_THNSNJ128GCST_747S104JTRAY,backup=0,replicate=0


Fix a Corrupted or Broken System using boot-repair
Source: https://www.baeldung.com/linux/grub-efi-reinstall
Set boot order from the installation cd.
qm set 140 --boot order='ide2;sata0'
Boot into console and Live Ubuntu > Open a terminal in the VM

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt update
sudo apt install -y boot-repair && boot-repair

advanced options > GRUB Location: sdb2 > Apply > Let boot-repair do its job
shutdown
qm set 140 --boot order='sata0;ide2'