User Tools

Site Tools


doc:howto:virtualbox

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:virtualbox [2012/10/03 05:43]
evoltech
doc:howto:virtualbox [2017/09/11 04:41] (current)
oska874
Line 1: Line 1:
 +====== OpenWrt in VirtualBox ======
 +This document describes how to run the OpenWrt x86 port in [[https://​www.virtualbox.org|VirtualBox]].
 +
 +===== Prerequisites =====
 +  * Download and install [[https://​www.virtualbox.org/​wiki/​Downloads|VirtualBox]]
 +  * Get an OpenWrt image:
 +    * Either use an existing image,
 +      * Download the //generic combined// image for x86 (32-bit), e.g. [[https://​downloads.openwrt.org/​chaos_calmer/​15.05.1/​x86/​generic/​openwrt-15.05.1-x86-generic-combined-ext4.img.gz|chaos_calmer/​15.05.1/​x86/​]]) [[https://​downloads.lede-project.org/​releases/​17.01.1/​targets/​x86/​generic/​lede-17.01.1-x86-generic-combined-ext4.img.gz|LEDE 17.01.1 x86]]
 +      * Download the //generic combined// image for x86_x64 (64-bit), e.g. [[https://​downloads.openwrt.org/​chaos_calmer/​15.05.1/​x86/​64/​openwrt-15.05.1-x86-64-combined-ext4.img.gz|chaos_calmer/​15.05.1/​x86/​64]]) [[https://​downloads.lede-project.org/​releases/​17.01.1/​targets/​x86/​64/​lede-17.01.1-x86-64-combined-ext4.img.gz|LEDE 17.01.1 x86_x64]]
 +      * Uncompress the image if needed: ''​gunzip openwrt.img.gz''​
 +      * Convert it to native VirtualBox format: ''​VBoxManage convertfromraw %%--%%format VDI openwrt.img openwrt.vdi''​ (in virtualbox version 5.0.12 the "''​%%--%%format VDI''"​ is at the end of command)
 +      * For vmdk format : VirtualBox format: ''​VBoxManage convertfromraw %%--%%format VMDK openwrt.img openwrt.vmdk''​
 +    * Or [[about:​toolchain|compile your own image]] (//Target System -> x86// and //Target Images -> Build VirtualBox image files//). ''​ext4''​ needs to be enabled first.
 +
 +===== Notes =====
 +
 +for x86_x64 (64-bit) make sure Intel VT-x or AMD-V is enabled, If you do not see this option in your motherboard,​ you must check the motherboard manual and specifications to identify whether the motherboard supports **virtualization technology**,​ Some of the old motherboards on Desktop or Laptop do not offer this feature, x86 is ok.
 +===== VM Setup in VirtualBox =====
 +  * Start VirtualBox
 +{{media:​doc:​howtos:​virtualboxwrt1.png?​600|Initial Form}}
 +  * Click //New// to add a virtual machine (VM)
 +
 +{{media:​doc:​howtos:​virtualboxwrt3.png?​600|OpenWrt and Kernel version}}
 +  * Choose a //Name// for your virtual machine
 +  * Choose ''​Linux''​ for your //Operating System//
 +  * Choose ''​Other Linux (32 bit)''​ or ''​Other Linux (64 bit)'' ​ for your //Version//
 +  * Click //Next//
 +  * Optionally decrease RAM size from ''​256 MB''​ to something smaller
 +  * Click //Next//
 +
 +{{media:​doc:​howtos:​virtualboxwrt4.png?​600|}}
 +
 +  * Choose //Use existing hard disk//
 +  * Click the //file// icon to open //Virtual Media Manager//
 +{{media:​doc:​howtos:​virtualboxwrt5.png?​600|}}
 +  * Click //Add// and choose your ''​.vdi''​ or ''​.vmdk''​ file using the dialog
 +  * Select your image in the list and click //Select//
 +  * Click //Next// and //Finish//
 +{{media:​doc:​howtos:​virtualboxwrt6.png?​600|}}
 +
 +  * This concludes the VM setup!
 +  * Click //Start// to boot the OpenWrt VM
 +
 +{{media:​doc:​howtos:​virtualboxwrt9.png?​600|}}
 +
 +  * [[doc:​techref:​bootloader|GRUB]] greets you, and boots using one of the available configurations (unless you intervene)
 +  * ''​dmesg''​ boot messages scroll by
 +  * Press Enter to activate the console
 +
 +===== Troubleshooting =====
 +  * If your virtual machine boots but doesn'​t activate the console
 +    * Press Enter
 +
 +  * If you rebuild the disk image, and VirtualBox complains about invalid UUIDs for the disk
 +    * You need to remove the disk from **both** the VM **and also** from the //Virtual Media Manager//
 +    * Then add the disk image to the VM again
 +
 +  * If your virtual machine is booting and one of the messages seen is ''​Waiting for root device PARTUUID=-02...''​ and you compiled the image
 +    * Make sure the machine you compiled the image on has the command ''​hexdump''​ and ''​dd''​ installed on it before compiling the image
 +
 +
 +===== Setting up networking =====
 +=== Enable Internet access through VirtualBox'​s NAT gateway ===
 +  * ''​halt''​ the VM if it runs
 +  * Open the VM's settings
 +  * In the //Network// tab
 +    * Configure //Adapter 1// to use //NAT//
 +    * Configure //Adapter 2// to use //Bridge Adapter//
 +        * Select your host machine'​s interface , e.g.wlp2s0 is wireless interface in Ubuntu 15.0
 +        * Best to disable promiscuous mode or its your choice
 +  * Boot into your openwrt VM
 +  * In file ''/​etc/​config/​network''​ do the following
 +       <​code>​ config '​interface'​ '​wan'​
 +                  option '​proto'​ '​dhcp'​
 +                  option '​ifname'​ '​eth0'​
 +              ​
 + ​config '​interface'​ '​lan'​
 +                  #option type '​bridge'​
 +                  option ifname '​eth1'​
 +                  #option ip6assign '​60'​
 +                  </​code>​
 +  * Reboot openwrt VM
 +
 +Your OpenWrt VM now has Internet access through VirtualBox'​s NAT gateway.
 +
 +
 +=== Set up networking with other VirtualBox VMs ===
 +  * ''​halt''​ the VM if it runs
 +  * Open the VM's settings
 +  * In the //Network// tab
 +    * Configure //Adapter 1// to use //internal network//, and choose a name for it
 +    * If you also need Internet connectivity,​ configure another adapter to use NAT, as above.
 +  * Boot the VM
 +  * In file ''/​etc/​config/​network''​ configure the ''​lan''​ interface to use ''​eth0'',​ and set an interface type and address <​code>​config interface '​lan'​
 +        option ifname '​eth0'​
 +        option type '​bridge'​
 +        option proto '​static' ​
 +        option ipaddr '​192.168.1.1'​
 +        option netmask '​255.255.255.0'​
 +#       ​option ip6assign '​60' ​ # Unused, no IPv6 in this example</​code>​
 +
 +/* See this discussion thread for more info on the "​ip6assign"​ option: ​
 +http://​comments.gmane.org/​gmane.comp.embedded.openwrt.devel/​24053 */
 +
 +  * If you want to use VirtualBox'​s internal network'​s DHCP server, use ''​option proto '​dhcp'​ ''​
 +  * Bring up the ''​lan''​ interface with ''​ifup lan''​
 +
 +Your OpenWrt VM can now interface with other VirtualBox VMs on your host that are also configured to use the //internal network// you set up.