Update OpenWRT to Latest Version

Author

Reads 1.5K

Smart home wireless network router device
Credit: pexels.com, Smart home wireless network router device

Updating OpenWRT to the latest version is a straightforward process that can be done in a few simple steps. You can check for available updates in the "System" tab of the LuCI web interface.

First, you'll need to access the LuCI web interface by typing the IP address of your router in a web browser. This is usually 192.168.1.1 or 192.168.0.1, depending on your router's configuration.

To update OpenWRT, you'll need to click on the "System" tab and then select the "Software & System" option from the dropdown menu. This will take you to a page where you can check for available updates.

Once you've checked for updates, you can click on the "Update" button to begin the upgrade process. This may take a few minutes to complete, depending on your internet connection speed and the size of the update.

Preparation

Before you start the OpenWRT firmware update, it's essential to prepare your router. You'll need to make a backup of your files and configuration, as the update process won't automatically carry over your custom changes.

Credit: youtube.com, How to upgrade OpenWrt?

To find out what files will be retained after the upgrade, run the command `ls -a` to see what files are currently retained. You can also edit the sysupgrade config file to mark other files or folders to be retained.

Files that you might want to retain include your config directory and startup file, but it's worth noting that you'll need to redownload and install your custom installed packages once the upgrade is complete.

Obtaining System Image

To obtain a system image, you can use the "attended sysupgrade" (ASU) API to build a custom image that includes your user-installed packages on top of the base images. This reduces the issues that could arise by booting first into the base environment without the user packages.

The process involves sending a JSON-formatted build request to the ASU API, waiting for the build to complete, downloading the resulting root filesystem image, and unzipping it to the target device. This is a very cool concept that simplifies the process of getting the system image.

If this caught your attention, see: Openwrt Build System Setup

A sleek WiFi 6 router with antennas and cable on a wooden desk, perfect for modern home networks.
Credit: pexels.com, A sleek WiFi 6 router with antennas and cable on a wooden desk, perfect for modern home networks.

You can format the build request correctly with the help of awk, which can pass in your installed-packages list and the desired version. This script creates a minimal JSON file that you'll send with your request to tell the image builder which packages and which version of OpenWrt to build with.

The installation and usage of the script is pretty simple: download it to your router, ensure it's executable, and then run it. If you have lots of user-installed applications, it might take a while for the build system to complete, so be patient.

Here's a step-by-step guide to obtaining the system image:

  • Send a JSON-formatted build request to the ASU API
  • Wait for the build to complete
  • Download the resulting root filesystem image
  • Unzip said image to the target device

Plan

Before you start the upgrade process, it's essential to have a clear plan in place. This involves several steps that will ensure a smooth transition to the new version of OpenWRT firmware.

First, you'll need to install script dependencies, which will help the upgrade process run smoothly.

It's also crucial to do a few checks to see what version you're currently on, what the newest release is, and which partitions contain which. This will give you a clear understanding of what needs to be done.

Detailed image of a woodworking router in action, shaping a wooden plank in a contemporary workshop.
Credit: pexels.com, Detailed image of a woodworking router in action, shaping a wooden plank in a contemporary workshop.

To accomplish this, you'll need to get a list of user-installed packages for the new version.

Here's a step-by-step breakdown of the plan:

  1. Install script dependencies
  2. Do a few checks to see what version you're on, what's the newest release, and which partitions contain which.
  3. Get a list of user-installed packages for the new version
  4. Build the custom image, download, and unzip to the target partition
  5. Remove old kernel(s), install new kernel
  6. Update GRUB with new kernel and partition ID's
  7. Copy config and files from current working version to new version

Remember to keep your config directory and startup file safe, as they might not be retained automatically during the upgrade process.

Checks and Variables

In preparation for our script, we need to check which version we are on and use that information as variables throughout the script.

The version information will be used to determine which updated version is available and which version is on the ‘old’ partition. We'll use the lsblk command to get this information.

The lsblk command with the -pPo flags gives us full paths, key=value pairs, and only outputs selected info (columns). This combination is essential for easily finding information by the provided key.

We'll pipe the outputs into grep and sed to grab the relevant information. This process allows us to extract specific details from the output.

The target_dev is limited to either /dev/sda2 or /dev/sda3. This limitation is hard-coded in the script.

Upgrade Process

Credit: youtube.com, Upgrade your OpenWRT firmware in-place, the easy way!

To upgrade your OpenWRT system, you can use the Attended Sysupgrade function, which will be kept for future use. This function allows you to update your firmware in-place, without losing any settings or configurations.

First, navigate to the System menu and select Attended Sysupgrade. From there, click the Search for Firmware Upgrade button and wait for the system to search for available updates. If an update is found, you'll be presented with a list of available versions, including the latest one.

To upgrade, click the Request Firmware Image button, which will send a request to a build server to build a new image for your hardware. Be patient, as this process may take a few minutes. Once the build is complete, you'll be able to download the new image version as a backup copy.

Before proceeding with the upgrade, make sure to check the option to Keep setup and retain the current configuration. This will ensure that your settings and configurations are preserved during the upgrade process.

For another approach, see: Baidu Search Update

Credit: youtube.com, How to Upgrade OpenWrt Router

To confirm the upgrade, you can run the command `cat /etc/openwrt_release`, which will display a file containing your current firmware version information. The DISTRIB_TARGET field will help you locate the firmware file in the OpenWRT firmware download list.

Here are the general steps to follow:

  1. Download the sysupgrade.bin file from the OpenWRT firmware download list.
  2. Run the command `sysupgrade -v /path/to/sysupgrade.bin` to start the upgrade process.

After the upgrade is complete, you'll need to test if you still have access to the device. If you specified the files needed to be retained earlier, you might still have SSH access. Once you've got access to the device again, run the command `cat /etc/openwrt_release` to confirm the firmware version details.

Some devices may require a manual check of settings and configurations after the upgrade. Make sure to check your network settings and internet access to ensure everything is working as expected.

Customization

Customization is key when updating OpenWrt to ensure your changes persist. You can configure specific files to be backed up and restored during the upgrade process in /etc/sysupgrade.conf.

To keep your init changes, you'll need to configure things properly in this file. This is crucial to prevent losing your customizations during the upgrade.

There's a way to make this process easier - you can create an OpenWrt package and use UCI configuration to help you do that.

Using LuCI Web-Admin

Credit: youtube.com, Demonstration - new Interface web LuCI OpenWrt

To use LuCI Web-Admin for sysupgrade, you'll need to use an ubi file, such as ventana-owrt-20.06-normal.ubi.

First, go to the top System tab, then select the lower tab as Backup / Flash Firmware. From there, select the ubi file from your desktop PC under 'Flash new firmware image'.

In the background, the serial console is running a process that's not explicitly shown in the WebGUI.

Customizing Sysupgrade

Customizing sysupgrade is a crucial step in ensuring your customizations persist across upgrades. It's configured in /etc/sysupgrade.conf.

To make sure your init changes stick, you'll need to configure things properly in this file. You may also want to create an OpenWrt package to help with that.

One important thing to note is that the specified set of files gets backed up and restored during a sysupgrade. This is in addition to all of UCI.

If you're looking to create a custom package, you can use UCI configuration to help with that. This will ensure that your customizations are included in the sysupgrade process.

Here are some key files to keep in mind when customizing sysupgrade:

  • /etc/sysupgrade.conf
  • sysupgrade.conf file in the System -> Backup -> Configuration section of the UI

Upgrade Steps

Credit: youtube.com, Updating/Upgrading OpenWrt

To upgrade your OpenWRT system, you'll need to follow these steps. First, select 'Attended Sysupgrade' from the top navigation 'System' menu.

You can then click the 'Search for Firmware Upgrade' button on the upgrade page, which will search for an upgraded version of your current install. Be patient while it searches, as this may take a few seconds.

If an upgraded version is available, you'll be presented with a pop-up window listing the available versions. You can then click the 'Request Firmware Image' button to send a request to a build server to build a new image for your hardware.

Once the build is complete, you'll be able to download the new image version as a backup copy. Make sure to check the option to 'Keep setup and retain the current configuration' before clicking the 'Install Firmware Image' button.

The upgrade process may take a few minutes to complete, and you'll be redirected back to the login screen of your device once it's finished. You can then do a quick manual check of your various settings and configurations to ensure everything looks good.

Credit: youtube.com, OpenWrt upgrade - The EASY way

Here are the detailed steps to follow:

  1. Select 'Attended Sysupgrade' from the top navigation 'System' menu.
  2. Click the 'Search for Firmware Upgrade' button.
  3. Wait for the search to complete and check for available upgrades.
  4. Click the 'Request Firmware Image' button.
  5. Download the new image version as a backup copy.
  6. Check the option to 'Keep setup and retain the current configuration'.
  7. Click the 'Install Firmware Image' button.
  8. Wait for the upgrade process to complete.
  9. Do a quick manual check of your settings and configurations.

Remember to run the command `cat /etc/openwrt_release` to determine your current firmware version, and make sure to download the sysupgrade.bin file, not the factory.bin file.

After Upgrade

After Upgrade, the first thing to do is test if you still have access to the device. If you specified the files needed to be retained earlier you might still have SSH access.

You should run the command to confirm the firmware version details: `cat /etc/openwrt_release`. This will show you the firmware version, and the "DISTRIB_RELEASE" should now match the firmware version (in our case it would be 15.05.1).

Next, you'll need to redownload all custom packages you previously installed. This is because the upgrade process will have removed them. You can do this by running `opkg update` and then reinstalling the packages you need.

You'll also need to disable any processes you may have previously specified. This will vary depending on what you used your device for prior to the upgrade.

Caveats

Credit: youtube.com, Unlock WE2008C's FULL Power: Easy OpenWrt Upgrade Tutorial! (VPN, AdBlock, QoS)

When upgrading OpenWRT, it's essential to consider the potential caveats. One of the main issues is dealing with installed packages, which can be a challenge.

You'll want to run other applications, like memory or CPU-intensive ones, on the new version directly. To do this, you have two main options.

You can use the standard installation, get a list of user-installed packages, and put a small helper script in /etc/uci-default which is run at first boot. Alternatively, you can use the Attended Sysupgrade build server to install the packages ahead, and use that image to have everything installed ahead.

However, if you're using a custom DNS software, like AdGuard Home, you won't have internet access (or at least be able to do DNS lookups) after the upgrade. This can be overcome, but it comes with other challenges as well.

To avoid this issue, you can use the Attended Sysupgrade API to build the image, but keep custom-installed applications on a 4th partition - sda4.

Here are your options summarized:

  1. Use the standard installation and put a helper script in /etc/uci-default.
  2. Use the Attended Sysupgrade build server to install packages ahead.
  3. Use the Attended Sysupgrade API and keep custom applications on a 4th partition.

Potential Solutions

Credit: youtube.com, When is it time to update OpenWRT on a router? (2 Solutions!!)

You can't simply use the opkg list-installed command to get a list of user-installed packages, as it lists every package, including those installed by default.

The release of 22.03.0 moved the firewall backend from iptables to nftables, causing potential conflicts with or rollbacks of updated firewall packages.

To get a list of user-installed packages, you need to filter out system-installed packages, which is not easily done with the opkg list-installed command.

Two solutions from users "spence" and "efahl" work well, but one of them is more efficient and takes less time to create.

The first solution compares installed packages with the package manifest posted with the version released, which takes some time to create and involves two separate scripts.

Using files already existing within the opkg system in combination with grep and awk commands significantly cuts down on run time and is a much smaller addition to the overall script.

Basic Idea

The basic idea behind updating OpenWrt is to make the process as effortless as possible.

Credit: youtube.com, Video Updated: OpenWRT Router Walkthrough: Basic Settings & Easy Setup Guide

You're probably using OpenWrt on an x86/64 machine, but it's not very well supported by the OpenWrt project.

The normal "sysupgrade" option that makes upgrading between versions effortless is only available on WiFi routers, not on x86/64 machines.

Upgrading between versions on an x86/64 machine can be a frustrating process, especially when you get to the "Upgrading" section.

But don't worry, there's a workaround that makes the process much easier.

A user named "frolic" in the OpenWrt forums came up with a simple solution that involves a few straightforward steps.

Dependencies

To update OpenWRT, you'll need to install two packages that aren't included by default: lsblk and curl. The first, lsblk, is necessary for getting partition names.

lsblk is a crucial tool for managing disk partitions, and it's not available out of the box.

The second package, curl, is required because the built-in wget is not a full version of wget and cannot send custom headers in a request. This limitation will become apparent later on.

Kernel

Credit: youtube.com, Cara Mengganti Kernel Di REYRE-WRT Dengan Gampang | OpenWrt

Updating the kernel is a straightforward process. You'll be downloading the kernel that matches the new version of OpenWrt you installed previously.

The new kernel will be named with the release version, making it easy to identify.

To start, make sure you have the new version of OpenWrt installed, as the kernel update relies on this previous step.

Downloading the kernel is a simple matter of matching it to the new OpenWrt version.

Frequently Asked Questions

Should you update OpenWRT packages?

Updating all OpenWRT packages is not recommended, as it can consume device storage and potentially cause instability. For more information, see the OpenWRT forum threads on this topic.

How do I update my latest firmware?

To update your latest firmware, identify your device model and manufacturer, then follow the steps to download and install the latest firmware update. Start by checking for available updates and following the on-screen instructions to complete the process.

Wm Kling

Lead Writer

Wm Kling is a seasoned writer with a passion for technology and innovation. With a strong background in software development, Wm brings a unique perspective to his writing, making complex topics accessible to a wide range of readers. Wm's expertise spans the realm of Visual Studio web development, where he has written in-depth articles and guides to help developers navigate the latest tools and technologies.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.