Openwrt on SBC

When it comes to operating systems on the single board computers, openwrt often gets overlooked, But if you have some old single board computers that are collecting dust because it's not powerful enough, openwrt is a very good choice to bring that back to life.

And because openwrt is an operating system designed for routers, you have a web interface, and you can manage it from there.

So today, we are going to install openwrt on the OG raspberry pi one.

Requirements

Before we get started, let's go through what we need.

Hardware

  • Raspberry pi 1B

  • SD Card

  • Computer(Any operating system will do but I recommend Linux)

Software

  • Etcher( But I will use dd )

  • openwrt image for raspberry pi 1B

  • A software that lets you modify partition size on an SD Card, I will use fdisk.

  • ethernet cable.

Burn the image

First let's insert the SD card into the card reader, and plug the card reader into our computer.

Next, we need to identify what our SC card was called on our system, should be /dev/sdX.

Now head over to openwrt's website and download the image, by the time I write this, the latest version of openwrt is 23.05.0 , so the download URL is https://downloads.openwrt.org/releases/23.05.0/targets/bcm27xx/bcm2708/openwrt-23.05.0-bcm27xx-bcm2708-rpi-ext4-factory.img.gz.

After the image is downloaded, extract it, and then run the command:

sudo dd if=openwrt-*.img of=/dev/sdX

When the command is finished, we are done in this step.

Resize the root partition

If you go online and buy an SD card, chances are you will get one with several gigabytes, that is overkill for openwrt, but the default image we just burned in did not use the full size of your SD Card, and we are going to change that,

Let's use fdisk to change the root partition of our SD Card, type the command sudo fdisk /dev/sdX, now we can see the default partition size.

After we type p and hit Enter, we can see the partition from the openwrt image:

Command (m for help): p

Disk /dev/sdc: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: MassStorageClass
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: 0x5452574f

Device     Boot  Start    End Sectors  Size Id Type
/dev/sdc1  *      8192 139263  131072   64M  c W95 FAT32 (LBA)
/dev/sdc2       147456 360447  212992  104M 83 Linux

But we need to remember where the second partition was started, as we need to create a new partition with the exact same starting address, in our case it's 147456 .

Next is to delete the last partition on our SD Card with d and then Enter.

Command (m for help): d
Partition number (1,2, default 2): 

Partition 2 has been deleted.

Then we create a new partition without removing the old partition signature, press n and then Enter, remember the start of the partitoin we just deleted? the newly created partition needs to have the same start.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (2-4, default 2): 
First sector (2048-31457279, default 2048): 147456
Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-31457279, default 31457279): 

Created a new partition 2 of type 'Linux' and of size 14.9 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

And then a check for the changes we've made:

Command (m for help): p

Disk /dev/sdc: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: MassStorageClass
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: 0x5452574f

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdc1  *      8192   139263   131072   64M  c W95 FAT32 (LBA)
/dev/sdc2       147456 31457279 31309824 14.9G 83 Linux

And finally, we type w and hit Enter to write changes to our SD Card.

Command (m for help): w
The partition table has been altered.

We can pop the SD Card out and insert it into our pi.

Openwrt Initial configuration

By default, when the device that runs openwrt only has one ethernet port, that ethernet port is the LAN port, so we can not connect our pi to our router or switch yet, we need to connect the ethernet cable directly to our pi first.

And after we get IP address from our pi, we can log in to openwrt in luci.

Head over to network → interfaces, edit lan, and change protocol from static to dhcp , and apply changes.

Then we can connect pi to our switch, and so can our pc.

Finish

After all the above steps, we should have access to our pi within our network.