Skip to content

Instantly share code, notes, and snippets.

@subrezon
Last active February 24, 2025 13:14
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

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