Improve "Run OpenWrt in VirtualBox" guide

For newcomers it would be nice to try and learn OpenWrt on VM first.
The problem is that this not so easy to do.
We have an article https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm but for me it seems to complicated. I tried to improve it a little bit so please review my changes https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm?do=revisions

Here is few changes that I did:

  1. I used combined-ext4 everywhere instead of combined-squashfs. I just thought that ext4 is more easier to deal with.
  2. But also I copied a short description with differences between them.
  3. I made some direct links to for downloads.

Things to do:
0. TBH is think that is would be great to make a separate VDI file which is already converted from img and ready to be used by VBox.

  1. The network configuration section seems too complicated. On my VM I just made one network adapter with bridge and on VM changed /etc/config/network to
config interface 'lan'
    option proto 'dhcp'
    option ifname 'eth0'

Not sure that I did it correctly but with such config I can ping my VM from host and the VM has an access to host and internet, which I guess is a desirable config for 95% of users.

But as for me this or similar config should be shipped by default because now it's nailed the static IP 192.168.1.1.

It also would be nice to update screenshots because some of them contains LEDE which may confuse newcomers.

This is incorrect, ext4 doesn't provide support for factory resets - the whole filesystem image is writeable, if you mess it up, it's dead for good. With squashfs, you still retain a known good rootfs below the overlay, which can be used for firstboot.

2 Likes

What if one needs: VMDK (for VMWare Player instead), VHD (for Hyper-V), HDD (for Parallels), QCOW or QED (for QEMU), or other format?

VirtualBox is not the only hypervisor solution; and all hypervisors can convert raw IMG files (or has complimentary software installed that does so).

Except if you then need to e.g. bridge PHYs in LAN, then you'd have to put it back. Also, you just seem to wanna bridge into your Hypervisor's network; but note that there's no such thing in full-cloud hypervisors (e.g. VSphere).

Wow, that wouldn't work for most people who want to use OpenWrt as a real production router in VM.

???

You can assign whatever IP you desire.

Thank you, got it.
The whole my point is to make it easy for newcomers who wants to try and learn OpenWrt before risking with their own router. They may not have any previous experience with Linux. And we can encourage users to try and play with OpenWrt first. As far I know the VBox is most user friendly for newcomers, at least it's free. So it will be good to make the VBox Howto written for such non experienced users.
That's why each additional step adds a lot of complexity for them:

  1. Converting img file by running a command line. I guess that VMWare/QEMU users can do this themselves but for newcommers it would be great just to give them already prepared image that can be directly used from VBox. This can be even be the whole VM.
  2. The typical usage will be: run VM, the VM receives an IP via regular DHCP. user tries to login into it with ssh and configure it and install some packages. Also user can open VM's Luci site directly from his browser.

To be fair, getting the host networking right will not be easy for these hypothetical newcomers…

In most cases jumping into the deep end and testing it on real, physical hardware should be considerably easier for most users, than the much more 'virtual wiring' necessary to configure the hypervisor in a way to really test OpenWrt. The later does require some rather exhaustive knowledge to routing and how it all fits together, while the physical hardware clearly labels WAN and LAN and gives to physical wires to connect as you see fit.

--
speaking as someone making very heavy use of virtualization for testing purposes, including OpenWrt, myself, but on linux/ qemu(kvm)

2 Likes

yeah, learning openwrt on a real router may be easier but have some other cons like:

  1. here is a big possibility to brick router e.g. install a lot of packages and get "no space left on disk" error
  2. on some routers it's not so easy to install OpenWrt: you have to set some specific IP etc.
  3. while you playing and configuring you and all your family are without an access to internet. But 3G from phone may help.
  4. if you just want to try and see some demo this is the only way to do this

Given that it makes a lot of sense to propose for newcomers to try OpenWrt in VBox

  1. I like the clarity of your wording
  2. The page is way too text heavy
  3. A hosted .ova would achieve much of your goals
  4. A subguide just focussed on [3] is probably clearer

draft advanced subguide ( shows how complicated explaining vmnet's can get )

A beginner is always going to stumble with "virtuality" and hot-linking to external instructions for much of the "finnicky" networking concepts is likely the most viable option. ( as is keeping them as minimal and clear as possible ).

1 Like

Just for info: We also have the inbox for drafts or pages tha re "in-work" or "under discussion".

1 Like

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

I've created OpenWrt Vagrant image following the official guide. Here is a git repo with instructions in case you want to build box by yourself.

I would be happy to add this information to the official documentation in case you guys find it useful.

For using squashfs images with libvirt/KVM, one need to expand the image first. Or else the booted system doesn't have any space to write the configuration to.

First create a 300MB blank img file, then write the openwrt-xxx-combined-squashfs.img to the created file with conv=notrunc option.

n@n:~/Downloads$ dd if=/dev/zero of=openwrt.img bs=1M count=300
300+0 records in
300+0 records out
314572800 bytes (315 MB, 300 MiB) copied, 0.11842 s, 2.7 GB/s
n@n:~/Downloads$ dd if=openwrt-19.07.3-x86-64-combined-squashfs.img of=openwrt.img conv=notrunc
39854+1 records in
39854+1 records out
20405356 bytes (20 MB, 19 MiB) copied, 0.16736 s, 122 MB/s
n@n:~/Downloads$ ls -lah openwrt* 
-rw-rw-r-- 1 n n  20M Aug 13 16:50 openwrt-19.07.3-x86-64-combined-squashfs.img
-rw-rw-r-- 1 n n 300M Aug 13 16:54 openwrt.img

Tip: The resultant 300MB openwrt.img can be conveniently compressed with gzip to a 7MB file for transmission.

Squashfs img partition:

Disk /dev/loop0: 300 MiB, 314572800 bytes, 614400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x339542e9

Device       Boot Start    End Sectors  Size Id Type
/dev/loop0p1 *      512  33279   32768   16M 83 Linux
/dev/loop0p2      33792 558079  524288  256M 83 Linux