How to install OpenWrt in Proxmox VE as a VM

How to install OpenWrt in Proxmox VE as a VM

Since OpenWrt only offer IMG file for installation, and Proxmox VE only take ISO file. So we have to use the command line to import IMG file into the virtual machine in order to use OpenWrt as a VM in PVE.

Step 1. Preparation

Proxmox VE: you can download from here.

OpenWrt 19.07: Download the x86_64 firmware from here. Download combined-squashfs.img.gz then unzip it to IMG file.

Step 2. Creating the virtual machine

Login to your PVE web interface then click “Create VM” on the top right corner.

Create VM

Giving your OpenWrt VM a VM ID and the Name you like, click “Advanced” to check “Start at boot”. Then Next.

VM ID, Name and Start at boot

Check “Do not use any media”, then Next.

Do not use any media

Use the default setting for this page, and just click Next.

Just hit Next

For hard disk settings, just give it a random size or just leave it alone, because we will delete this virtual disk later. Then Next.

Give it a random size and Next

For CPU cores, set it based on your usage, normally 2 or 4 cores are good enough. Remember to change the CPU type to host for the best performance!

CPU cores and HOST type

For memory, 1024 MB should be good enough, if you like, you can give as much as ram you want.

1GB RAM

For Network, just leave it alone and click Next.

No need to edit network setting

Just click “Finish” to finish it up.

Finish it

Step 3. Import IMG file and edit the VM hardware

First, find the VM you just created and click “Hardware”

Click Hardware

Select the “Hard Disk” then click “Detach”, then click Yes on the confirmation window.

Detach the hard disk

Select the “Unused Disk 0” and click “Remove” to remove this disk.

Remove the disk

Now, let’s go the Shell of Proxmox and run the following command to download the OpenWrt firmware.

wget https://downloads.openwrt.org/releases/19.07.0-rc2/targets/x86/64/openwrt-19.07.0-rc2-x86-64-combined-squashfs.img.gz

After download finished, use the following command to unzip it to IMG file.

gunzip openwrt-19.07.0-rc2-x86-64-combined-squashfs.img.gz

Then rename it to a shorter name to make it easier to type in.

mv openwrt-19.07.0-rc2-x86-64-combined-squashfs.img openwrt.img
Download, unzip and rename OpenWrt file

You can also download the OpenWrt file locally, then unzip it to IMG file, rename and upload it to the Proxmox server by using WinSCP or MobaXterm.

Here is the most important step, which is import IMG file into the VM. Type in the following command to shell. 200 is the VM ID, and openwrt.img is the file we just downloaded.

qm importdisk 200 openwrt.img local-lvm
import img to vm

Go back to the OpenWrt VM hardware page, you will see there is an “Unused Disk 0”, check it and click “Edit”

edit hardware

Change the Bus/Device to SCSI, then click “Add”

SCSI add

Now, you are ready to start your OpenWrt VM!

Start your VM

If you click the Console, and you are able to access the OpenWrt console.

Congratulations! You successfully created a OpenWrt VM in Proxmox VE and the IP address should be 192.168.1.1, if you want to change the LAN IP address, use the following command. x.x.x.x is the IP address you want to access the web interface.

uci set network.lan.ipaddr='x.x.x.x'
uci commit network
/etc/init.d/network restart
OpenWrt 19.07

Welcome to the world of OpenWrt!

Like this post? Please share this:

16 thoughts on “How to install OpenWrt in Proxmox VE as a VM

  1. Hello, thank you for this How To. It was really helpfull. But there was a problem to boot the imported image. It wasn’t recognized to be bootable. I needed to make sure there is the …

    boot: order=scsi0
    bootdisk: scsi0

    … entry in the [VM ID].conf file of my virtual machine.

    Best regards
    Seraphin

  2. Hi,

    Thanks for the great tutorial!

    Just one highlight: When you detach the generic disk and later attach the new one, the boot order in Options changes from disk-network to network-disk. In my case (PVE 6.3, OWRT 19.07.5) the disk was not even ticked as a boot device. I think it’s worth mentioning in your HowTo so that others will save 10 minutes trying to figure out what’s wrong :).

    Also, would it not be better to use the ext4 image instead of squashfs? PVE is most likely running off a big enough HDD anyway so not much point having squashfs around here.

    1. Hi, thanks for the comment. For squashfs image, the biggest benefit is the ability to reset OpenWrt to factory setting. If you don’t need that, ext4 image maybe is the better option for you.

  3. Thanks!

    One thing, after this just go the VM -> Options -> Boot Order and Add (scsi0) as default boot device!

  4. I just want to add for anyone being too creative like me, it needs to be on local-lvm! I added it to another drive that wasn’t lvm and it cannot grow the space as needed.

  5. Porxmox 7.2 – the directions fail to boot the device without following the comment from Leroy van Logchem

    “One thing, after this just go the VM -> Options -> Boot Order and Add (scsi0) as default boot device!”
    I had to click “enable” and move to top of boot order list.
    By default it’s not enabled to boot from.

  6. Hello Guys,

    I am new here, I just have a question, I see that you are using the vmbr0 (bridge) but where does the second Nic come in, I mean are you using vmbr0 as the lan or wan? I would think it would have to be wan as you would want your IP (Internet) to come from there correct?

    Sorry I am not very good at the network side of things.
    Thanks for your time;
    Michael

  7. Hello. What I have been faced is internet connection is not working with default bridge over ethernet. So, I created another bridge at the pve tab -> network. It contains CIDR 192.168.1.0/24 and no gateway. And then on my Openwrt VM -> Hardware tab I have added one more bridge with bridge that I have just created. Then it workeed

Leave a Reply

Your email address will not be published.