How do I remove a package from the alternate partition?

Hardware: Linksys WRT1900AC
OpenWRT: 21.02.2

I installed "OpenVPN with OpenSSL" package. Upon finishing the LEED interface switched to "Updating package information,"then eventually timed out. No network device could ping the router IP address. All connectivity to non-LAN was gone.

Reboot router via power-switch: no behavioral change. Router booted. LEDs are flashing. No pings are responded to, all LAN traffic is dead.

Reboot to alternate partition: Cycle power three times via power switch, then let router boot. Alternate partition is booted from. Internet traffic resumes working.

So - OK. I now have a functional partition and a non-functional partition. How can I remove the OpenVPN package from the other partition to (hopefully) restore functionality? Or delete config files? On in some way rescue that partition without completely wiping it and starting over with the overall (somewhat intricate) configuration currently on it?

Thanks!

Trying to edit installed packages on the non-mounted other partition is difficult, so I suggest a simpler approach:

When you next time sysupgrade from the working partition, the sysupgrade process will overwrite the other partition and switch to using it (and copies your current config)

Sysupgrade is a round-robin thing I these dual-firmware devices.

2 Likes

Thanks hnyman. That DOES appear to have restored the problem partition to a functional status, but with the side effect of not preserving any of my installed packages (which, I suppose, was sort of the point). I haven't determined yet is all my configuration has been preserved and the packages just need to reinstalled, or if I've lost all their configuration too.

Note for future searchers:

sysupgrade -c -v "[URL]"

where [URL] is the link to the sysupgrade image offered up on the "Download OpenWrt firmware for your device" page. In my case, for the Linksys WRT1900AC v1, the command looks like:

sysupgrade -c -v "https://downloads.openwrt.org/releases/21.02.3/targets/mvebu/cortexa9/openwrt-21.02.3-mvebu-cortexa9-linksys_wrt1900ac-v1-squashfs-sysupgrade.bin"

Configuration is preserved in the normal sysupgrade, but installed packages are not.

Naturally you could use the toolchain to compile a personal firmware with all of your package installed, or use auc to cook up a firmware based on your currently installed packages.

Yep. And that may be a project for Future Me to do. For now I followed this path:

  1. I manually resolved downloads.openwrt.org and placed it in my hosts file (due to DNS tomfoolery the default set of OpenWRT packages can't do DNS resolution with the preserved config). Adding 168.119.138.211 downloads.openwrt.org to my /etc/hosts file allowed me to execute opkg update
  2. I forced a reboot back to the functional, but slightly out of date, partition to grab a list of packages: ls /overlay/upper/usr/lib/opkg/info/*.list | sed -e 's/.*\///' | sed -e 's/\.list//'. I captured this list to my local computer.
  3. I rebooted back to the sorta-vanilla-partition and did a full install of all the packages that were identified (I know that opkg will skip packages already installed and/or updated, so I was reasonably confident this would be safe). The CLI seems to have a character limit, so I did multiple runs of opkg to get them all installed. Locally I prepped for multi-package installs by changing the package-per-line format into "all packages on a single line separated by a space" format: cat installed_1 | awk '{print $1}' | tr '\n' ' ' I took those results and copied as many characters as the CLI would accept at a time until I had run out of packages to install.
  4. I then discovered that for whatever reason my dpkg was pulling package lists for OpenWrt 21.02.2 but my sysupgrade had landed me on 22.0.2.3, so I fixed that alignment and did another upgrade/update loop (easier, this time, since the packages are already installed and just need to be brought up to date): opkg upgrade ( opkg list-upgradable | awk '{print $1}' | tr "\n" " " )

One other note - this was ALSO further complicated because a number of the files my configuration wants to use are stored on USB storage rather than internal storage. I had forgotten that USB kernel modules, etc aren't part of the base package and thus my /mnt/sdb1/ file system was missing. The above steps fixed that, but there were a few minutes of panic early on as I noticed minor databases (rrd files, etc) were missing.

Thanks again fore the pointer hnyman. If nothing else, it pointed away from dead-ends and toward the ultimate solution.

Wouldn't it be easier to ?

  • save your config
  • create your own custom build with all the packages you need
  • reverse to alternate firmware, and flash the custom build
  • restore your config

In fact you can even include your config files in the custom build, so your system will boot already configured.

Dunno. Could be. I've never seriously considered rolling my own build as an "easier" path, and have therefore never really looked into what it actually requires.

As I noted in the post above:

that may be a project for Future Me to do

Considering what you wrote, you clearly have the skill to create your own builds. A custom build already contains all the packages you need. Once done, there is no need to remove/add packages on any partition.

As you have a dual partitions device, use one as a failsafe, and use the other as the active. The failsafe can be a default OpenWrt image, with the minimum of config to run. The active will be highly configured (packages, setup).

Thanks for the advice. I'll look into it when I have some time.

1 Like

Apparently this device can be used with luci-app-advanced-reboot. It allows to switch from one partition to the other.