I'm just wondering what is the equivalent of
apt-get upgrade apt upgrade yum update
with OpenWRT or LEDE?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
There no single command or argument, but you can easily do it. To upgrade all of the packages, LEDE recommends,
opkg list-upgradable | cut -f 1 -d ' ' | xargs -r opkg upgrade
There are other less efficient ways where people use AWK and such.
Since OpenWrt firmware stores the base system in a compressed read-only partition, any update to base system packages will be written in the read-write partition and therefore use more space than it would if it was just overwriting the older version in the compressed base system partition. It's recommended to check the available space in internal flash memory and the space requirements for updates of base system packages.
As far as I can tell the correct answer to this question is that there is no equivalent for apt upgrade on OpenWrt and no set of commands that will create equivalent functionality. OpenWrt repos aren't maintained with the intention of keeping end user's packages updated (you're expected to move from release to release by flashing) and opkg does not handle or even check dependencies.
There's an infobox warning for the OpenWRT User Guide that addresses this topic which sates in part:
Generally speaking, the use of opkg upgrade is very highly discouraged. It should be avoided in almost all circumstances. In particular, bulk upgrading is very likely to result in major problems, but even upgrading individual packages may cause issues. It is also important to stress that this is distinctly different from the sysupgrade path for upgrading OpenWrt releases (major versions as well as maintenance upgrades). opkg upgrade will not update the OpenWrt version. Only sysupgrade can do that. The two are not equivalent.
Unlike the 'big distros' of Linux, OpenWrt is optimized to run on systems with limited resources. This includes the opkg package manager, which does not have built-in ABI (Application Binary Interface) compatibility and kernel version dependencies verification. Although sometimes there may be no issues, there is no guarantee and the upgrade can result in various types of incompatibilities that can range from minor to severe, and it may be very difficult to troubleshoot. In addition, the opkg upgrade process will consume flash storage space. Since it does not (and cannot) overwrite the original (stored in ROM), it must store the upgraded packages in the r/w overlay.
It sums up with:
Blindly upgrading packages (manually or via script) can lead you into all sorts of trouble.
Just because there is an updated version of a given package does not mean it should be installed or that it will function properly. Inform yourself before doing any upgrades to determine if it is safe to upgrade.
There are two ways to manage/install packages in OpenWrt: with the LuCI web interface Software menu (System > Software), and via the command line interface (CLI). Both methods invoke the same CLI opkg executable, and as of OpenWrt 19.07.0, the LuCI interface now has an 'Updates' tab with a listing of packages that have available upgrades. The LuCI Upgrade… button performs the same opkg upgrade command that is discussed in this article. The same warnings apply to upgrading packages using LuCI and the CLI.
The whole infobox is worth reading. It appears at the top of this section of the User Guide about showing available package upgrades.
Remaining content of my original post preserved below
Quotes from the OpenWrt forums:
Those of us who have more experience with OpenWrt know that it is a bad idea to use opkg upgrade (unless there is a very specific reason) as things can break. But many other users do not know -- they assume that it is just like any other linux installation and that the upgrades should work most of the time.
DO NOT USE OPKG UPGRADE!
Seriously, don't. Ever. Unless you know what you are doing, have a very good reason to do it, and are willing to face the consequences if you mess up your router when it doesn't go well. It will consume flash memory space, but even more importantly, there can be kernel mismatches and other broken dependencies which can cause various issues for OpenWrt -- some of them just at the nuisance level, others can be quite severe requiring re-flashing and such.
Never, ever use opkg upgrade - this method will likely cause you major problems and does not actually upgrade the version. Some people will say that they have used opkg upgrade successfully, but for every one of those people, there are many more who have problems caused entirely by that process - some minor, some major. Just don’t do it
In short, there is a reason there isn't a GUI option included in LUCI for performing this action. The methods being suggested for use in other answers here will achieve something similar to apt/apt-get but the underlying tools simply do not work the same way as apt or yum. The possible problems go beyond the mentioned possibility of running out of storage space (which is bad, but can be avoided if careful).
I'm not an OpenWRT expert, I arrived at this thread because it is still a top web search result for 'updating wrt'. After reading this thread, I continued to the OpenWrt forums, including the threads linked above. I'm only trying to help end users avoid future problems by passing on information I've found which was presumably written by those more familiar/knowledgeable on the subject than I am.
Those who wish to continue advocating the use of various commands to keep packages up to date on OpenWrt, please consider taking the time to verify with the OpenWrt team that this is a reasonable way to use the tools provided. I'd love to be proven wrong.
I have created a little script called
opkg-upgrade to deal with upgrading in a better way.
It is available on github:
It will make upgrading as easy as:
As mentioned on the readme.md file, there may be problems with upgrading though.
I should also mention that upgrading from CRON is a very bad idea!
I would say that not even on a regular Linux distro blind upgrades are a good idea.
There are many things that can go wrong on upgrades and since OpenWrt usually runs on devices that can be bricked, it makes even less sense to do it unattended.
In short, the only cases where I would EVER upgrade are:
Still, I would never upgrade from cron.
I would also think 20 times before upgrading internal Flash (even big ones), since that would degrade it faster.
My script has the option to send an e-mail report with the available updates.
So I would recommend to add the reporting tool to cron, and then people can upgrade manually after receiving the e-mail. This makes things safer while also giving the option to revise the upgrades.
As of OpenWrt 19.07, performing
opkg upgrade [pkgname] may throw this error.
Collected errors: * pkg_hash_add_from_file: Failed to open /var/opkg-lists/openwrt_routing: Out of memory.
A workaround is to use
opkg install instead, which is the same as how
luci-app-opkg upgrades packages.
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg install
If you get error like this
- xsystem: wget: vfork: Out of memory. * opkg_download: Failed to download http://downloads.openwrt.org/releases/18.06.4/packages/mips_24kc/base/opkg_2020-01-25-c09fe209-1_mips_24kc.ipk, wget returned -1. * opkg_install_pkg: Failed to download opkg. Perhaps you need to run 'opkg update'?
try to upgrade each file separately in while:
opkg list-upgradable | cut -f 1 -d ' ' | while IFS='$\n' read -r line; do opkg install $line ; done
On my NanoPI R6S there are 496 packages to update on the default image. I noticed that it takes a very long time and unless the entire command finishes, I have to start over.
This script does it 50 at a time and is much quicker if there are problems. It uses parts of the other answers (thanks!)
opkg update && opkg list-upgradable | cut -f 1 -d ' ' | xargs -n 50 opkg upgrade