Default OpenWrt images have limited storage space. For development and testing, use pre-expanded images from openwrt-virtualbox-build.
Recommended: openwrt-24.10.4-x86-64-generic-ext4-combined.img.vdi
The ext4 filesystem allows post-installation expansion if you need more space later.
Pre-Configuration: Network Setup
Critical: Configure networking before the first boot, or OpenWrt won't have internet access.
Configure VirtualBox Host-Only Network
- Open VirtualBox → File → Host Network Manager
- Note the adapter IP (default:
192.168.56.1) - In the DHCP Server tab, uncheck "Enable Server"
This prevents IP conflicts between VirtualBox's DHCP and OpenWrt's network configuration.
Creating the Virtual Machine
Basic Settings
- OS Type: Linux 2.6
- OS Version: Linux 2.6 (64-bit)
- Memory: 4096 MB
- CPU Cores: 4
Attach the Disk
When prompted for a hard disk, select "Use an existing virtual hard disk file" and choose the downloaded .vdi file.
Network Configuration
Configure two network adapters:
- Adapter 1: Host-Only Adapter (for management access from host)
- Adapter 2: Bridged Adapter (for internet access)
First Boot Configuration
Set Root Password
After booting, immediately set the administrator password:
passwd
Configure Static IP
Set OpenWrt's IP to match your host-only network range (192.168.56.2-255). Choose a higher number to avoid conflicts:
uci set network.lan.ipaddr=192.168.56.66
uci commit
reboot
The system will reboot with the new IP address.
Setting Up SSH Key Authentication
Generate SSH Key on Host
If you don't already have an SSH key:
ssh-keygen -t rsa
Save it with a descriptive name like ~/.ssh/openwrt.
Add Public Key to OpenWrt
Option 1: Web UI
- Navigate to
http://192.168.56.66 - Go to System → Administration → SSH-Keys
- Paste the contents of your
~/.ssh/openwrt.pubfile - Click Add Key
Option 2: Command Line
OpenWrt uses Dropbear SSH server, which stores keys in a different location:
cat ~/.ssh/openwrt.pub | ssh root@192.168.56.66 "cat > /etc/dropbear/authorized_keys"
Note: The standard ~/.ssh/authorized_keys path won't work with Dropbear.
Connect via SSH
ssh root@192.168.56.66 -i ~/.ssh/openwrt
You can simplify this by adding an entry to ~/.ssh/config:
Host openwrt
HostName 192.168.56.66
User root
IdentityFile ~/.ssh/openwrt
Port 22
Then connect with just:
ssh openwrt
Verifying Storage
Check the current filesystem usage:
df -h
Initial output shows limited space:
Filesystem Size Used Available Use% Mounted on
/dev/root 98.3M 25.5M 70.7M 27% /
tmpfs 1.9G 204.0K 1.9G 0% /tmp
/dev/sda1 15.7M 5.7M 9.7M 37% /boot
tmpfs 512.0K 0 512.0K 0% /dev
Only ~70MB is available on the root filesystem, even though the VDI image is 4GB.
Expanding the Root Filesystem
To utilize the full 4GB capacity, follow the official expansion guide.
# Install packages
opkg update
opkg install parted losetup resize2fs blkid
# Download expand-root.sh
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
# Source the script (creates /etc/uci-defaults/70-rootpt-resize and /etc/uci-defaults/80-rootpt-resize, and adds them to /etc/sysupgrade.conf so they will be re-run after a sysupgrade)
. ./expand-root.sh
# Resize root partition and filesystem (will resize partiton, reboot resize filesystem, and reboot again)
sh /etc/uci-defaults/70-rootpt-resize
Verify Expansion
After the reboots complete, check storage again:
df -h
Expected output:
Filesystem Size Used Available Use% Mounted on
/dev/root 4.0G 27.3M 4.0G 1% /
tmpfs 1.9G 188.0K 1.9G 0% /tmp
/dev/sda1 15.7M 5.7M 9.7M 37% /boot
tmpfs 512.0K 0 512.0K 0% /dev
The root filesystem now has ~4GB available, perfect for development work.
Top comments (0)