Skip to content

Instantly share code, notes, and snippets.

@subrezon
Last active September 27, 2025 22:44
Show Gist options
  • Save subrezon/b9aa2014343f934fbf69e579ecfc8da8 to your computer and use it in GitHub Desktop.
Save subrezon/b9aa2014343f934fbf69e579ecfc8da8 to your computer and use it in GitHub Desktop.
How to set up an OpenWRT VM in Proxmox
  1. Go to OpenWRT release page, select the latest release stable release, then targets -> x86 -> 64. Right-click generic-ext4-combined.img.gz (not the "efi"!) and copy the link.

  2. On the Proxmox host, download the archive and unpack it:

wget *paste link here*
gunzip openwrt-*.img.gz
  1. Resize the image to be the size you want your VM's disk to be (example with 8 GiB):
qemu-img resize -f raw openwrt-*.img 8G
  1. Create a new VM in Proxmox. Make sure to use:
  • No installation media
  • SeaBIOS
  • No drives

Do not start the VM yet.

  1. Import the resized OpenWRT image into the new VM (replace VMID and STORAGEID with yours):
qm importdisk VMID openwrt-*.img STORAGEID
  1. Go to the VM -> Hardware, select the newly imported disk named "Unused Disk 0", press "Edit", set it to VirtIO with "Discard" and "IO Thread" enabled, then press OK.

  2. Go to the VM -> Options -> Boot Order, make sure that virtio0 is at the top and is the only one that is ticked.

  3. Add whatever networking or other devices you need.

  4. You're done! Start the VM and enjoy all the routing.

@ryuheechul
Copy link

Thanks for this gist and I made a similar guide for UEFI case.

@subrezon
Copy link
Author

Thanks for this gist and I made a similar guide for UEFI case.

Cool, glad I was of help. You mention needing Q35 + OVMF to pass through hardware. Just FYI - it works on i440fx + SeaBIOS as well, my OpenWrt has NICs passed through to it and they work just fine.

The major difference between them is that Q35 + OVMF virtualizes an actual PCIe stack, i440fx + SeaBIOS does PCI "overclocked" to PCIe speed. The only situation in which this matters that I know of is when passing through GPUs. Never seen it matter for network interfaces.

@ryuheechul
Copy link

@subrezon that is good to know, thanks!

@dvanmeter
Copy link

Thanks for this install guide!
I do have one thing to add:
After finishing the VM by editing the "unused Disk 0" and adding networking devices I needed to add the new disk to the boot order. Until I did this the VM would not boot since the newly added disk was not selected as a possible boot device.
Do this by clicking on the VM, then click on "Options". Then edit the boot order.

@miyu4u
Copy link

miyu4u commented Jul 10, 2024

if passthrough PCIe, can check cat /proc/interrupts in host machine CLI. thx guys for saving my day.

@xinyo
Copy link

xinyo commented Nov 10, 2024

👍

@natebc
Copy link

natebc commented Nov 10, 2024

hey you guys, thanks for this. this is a great resource!

@ch4r13
Copy link

ch4r13 commented Nov 18, 2024

Thanks, just small syntax edit on proxmox 8.2.2, replace this line:
qm importdisk *VMID* openwrt-*.img *STORAGEID*
to this:
qm disk import VMID openwrt-*.img local-lvm
or change local-lvm to other STORAGEID

@vitas76
Copy link

vitas76 commented Nov 25, 2024

THX good job with this tutor.

@viktorezgeta
Copy link

Hi, this is a good tutorial and I have some additional information.

2GiB of disk space is more than enough for the OpenWRT system and my advice is to resize the disk in this way:

qemu-img resize -f raw openwrt-*.img 2G

After you boot the OpenWRT system the whole 2GiB of space will not be used and to expand the file system and you need to:

  1. Log in via SSH to your router, for example:
ssh [email protected]
  1. Update list of available packages:
opkg update
  1. Install packages:
opkg install parted losetup resize2fs
  1. Download the script from the OpenWRT wiki to automate the process:
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
  1. Make the script executable:
chmod +x expand-root.sh
  1. Run script:
. ./expand-root.sh
  1. Now run the repartitioning script to expand the root partition and root file system to fill the available disk space:
    sh /etc/uci-defaults/70-rootpt-resize

The device will reboot and after that, the root partition and the root file system will be expanded to fill all space available to OpenWRT.

  1. Log again in via SSH again and check disk size:
df -Th

Link to the OpenWRT Wiki: https://openwrt.org/docs/guide-user/advanced/expand_root

@paulverket
Copy link

2GiB of disk space is more than enough for the OpenWRT system and my advice is to resize the disk in this way:

Great writeup and great disk resizing addition -- Thanks!

@kikislater
Copy link

kikislater commented Jul 11, 2025

root@OpenWrt:~# opkg install parted losetup resize2fs blkid
Unknown package 'parted'.
Unknown package 'losetup'.
Unknown package 'resize2fs'.
Unknown package 'blkid'.
Collected errors:
 * pkg_hash_check_unresolved: cannot find dependency libreadline8 for parted
 * pkg_hash_check_unresolved: cannot find dependency libncurses6 for parted
 * pkg_hash_fetch_best_installation_candidate: Packages for parted found, but incompatible with the architectures configured
 * opkg_install_cmd: Cannot install package parted.
 * opkg_install_cmd: Cannot install package losetup.
 * opkg_install_cmd: Cannot install package resize2fs.
 * opkg_install_cmd: Cannot install package blkid.

@viktorezgeta Where to find this libs under OpenWRT 24.10.2 ?

Edit: Strange ... After reboot multiple times I can now install them !

@Nasa1423
Copy link

Hello! I've faced a quite difficult task. I have a x86 machine, I want to setup proxmox and openwrt in it as a vm/ct. Main problem is, I want openwrt to be as gateway router for the network and for the proxmox host (and other virtualised machines). Does anyone know how to correctly setup proxmox and openwrt to work the way I want?

@subrezon
Copy link
Author

@Nasa1423 it is quite simple actually, assuming you have 2 or more NICs.

  • Keep one NIC for the host and use it for a bridge
  • Pass one NIC fully to the VM (this one will be your WAN)
  • Create a virtual interface and attach it to the VM (this will be your LAN)
  • Connect the WAN interface to your modem and the LAN interface to the rest of your network

The LAN port will connect everything attached to the bridge to your network, including the Proxmox host itself, as well as all attached containers and VMs, including OpenWrt.

@Nasa1423
Copy link

Nasa1423 commented Aug 26, 2025

@subrezon And that is the most interesting thing, I want openwrt to be the main gateway router and connect proxmox virtually. If I want proxmox to work in my openwrt network, I should physically connect proxmox NIC to one of the lans. But I want to do it virtually, so all the lan ports would be free to use. Possibly did not completely understand the idea you told me?

@subrezon
Copy link
Author

Let me explain like this: you have two interfaces, let's call them eth0 and eth1.

  • Create a bridge interface, let's call it br0. Attach it to eth0 and assign the Proxmox static IP address to it.
  • Create the OpenWrt VM, pass eth1 through to it fully, and create one virtual interface that is attached to br0.
  • Configure OpenWrt so that the physical interface (eth1) is the WAN and the virtual interface (br0) is the LAN.

Now Proxmox, OpenWrt and the rest of your network that is connected to eth0 are all in the same network and can access each other.

@Nasa1423
Copy link

Yes, that makes much more sense for me! Thank you very much @subrezon!

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