Accidently deleted OPKG folder

Hello,

I recently encountered an issue with my Raspberry Pi 4B running OpenWRT firmware where the opkg package manager stopped working. In my attempts to fix the problem, I accidentally removed the opkg folder from /etc. To resolve this, I decided to reinstall the OpenWRT image file, formatting the SD card in the process. However, after reinstalling, I no longer receive any error messages, even though opkg still isn't functioning.

I would greatly appreciate any assistance or solutions you can offer. Thank you in advance for your help.

It is still there in /rom/usr/lib/opkg

1 Like

I'm curious to understand why, even after reinstalling the OpenWRT image, the situation remains unchanged. It seems as though the new image flashing might have failed, or perhaps there's another reason why the previous contents persist.

It would be also nice to show some actual output from the errors:

Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board; \
opkg update; head -n -0 /etc/opkg.conf; head -n -0 /etc/opkg/* ; uci export network; \
uci export dhcp; uci export firewall; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/* ; head -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
root@OpenWrt:/# ubus call system board
{
	"kernel": "5.15.134",
	"hostname": "OpenWrt",
	"system": "ARMv8 Processor rev 3",
	"model": "Raspberry Pi 4 Model B Rev 1.5",
	"board_name": "raspberrypi,4-model-b",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.0",
		"revision": "r23497-6637af95aa",
		"target": "bcm27xx/bcm2711",
		"description": "OpenWrt 23.05.0 r23497-6637af95aa"
	}
}
root@OpenWrt:/# opkg update
root@OpenWrt:/# head -n -0 /etc/opkg.conf
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
option check_signature

root@OpenWrt:/# head -n -0 /etc/opkg/*  (Couldn't copy complete log)
Package: libucode20220812
ABIVersion: 20220812
Version: 2023-06-06-c7d84aae-1
Depends: libc, libjson-c5
Provides: libucode
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: kmod-lib-lzo
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-crypto-acompress
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: ubox
Version: 2022-08-13-4c7b720b-2
Depends: libc, libubox20230523, ubusd, ubus, libubus20230605, libuci20130104
Status: install user installed
Architecture: aarch64_cortex-a72
Conffiles:
 /etc/modules.conf 83dab538976e37112de89ad9569f77410553bd0a8393d19ed656353218ccf6ae
Installed-Time: 1696887935
Auto-Installed: yes
Alternatives: 100:/sbin/rmmod:/sbin/kmodloader, 100:/sbin/insmod:/sbin/kmodloader, 100:/sbin/lsmod:/sbin/kmodloader, 100:/sbin/modinfo:/sbin/kmodloader, 100:/sbin/modprobe:/sbin/kmodloader

Package: kernel
Version: 5.15.134-1-4d407d5f01a611de6825ef905c07d710
Depends: libc
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: rpcd-mod-iwinfo
Version: 2023-07-01-c07ab2f9-1
Depends: libiwinfo (>= 2023-01-21), libc, libubus20230605, libubox20230523, rpcd, libiwinfo20230701
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: luci-mod-network
Version: git-23.283.21598-257f54c
Depends: libc, luci-base, rpcd-mod-iwinfo
Status: install user installed
Architecture: all
Installed-Time: 1696887935
Auto-Installed: yes

Package: kmod-nft-core
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-nfnetlink, kmod-nf-reject, kmod-nf-reject6, kmod-nf-conntrack6, kmod-nf-nat, kmod-nf-log, kmod-nf-log6, kmod-lib-crc32c
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: kmod-fixed-phy
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-libphy
Status: install ok installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: kmod-nls-base
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710)
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: uhttpd-mod-ubus
Version: 2023-06-25-34a8a74d-1
Depends: libc, uhttpd, libubus20230605, libblobmsg-json20230523
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: fwtool
Version: 2019-11-12-8f7fe925-1
Depends: libc
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: jsonfilter
Version: 2018-02-04-c7e938d6-1
Depends: libc, libubox20230523, libjson-c5
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: liblucihttp-ucode
Version: 2023-03-15-9b5b683f-1
Depends: libc, liblucihttp0, libucode20220812
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: libubox20230523
ABIVersion: 20230523
Version: 2023-05-23-75a3b870-1
Depends: libc
Provides: libubox
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: hostapd-common
Version: 2023-09-08-e5ccbfc6-4
Depends: libc
Status: install ok installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: kmod-hid
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-input-core, kmod-input-evdev
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: bcm27xx-gpu-fw
Version: 2022-05-16-3673be308132de102fdff491d1333d9d0f823557
Depends: libc
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: kmod-mdio-devres
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-libphy
Status: install ok installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: wireless-regdb
Version: 2023.09.01-1
Depends: libc
Status: install ok installed
Architecture: all
Installed-Time: 1696887935
Auto-Installed: yes

Package: kmod-slhc
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-lib-crc-ccitt
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: kmod-cfg80211
Version: 5.15.134+6.1.24-3
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), iw, iwinfo, wireless-regdb
Status: install ok installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: rpcd-mod-rrdns
Version: 20170710
Depends: libc, rpcd, libubox20230523, libubus20230605
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

Package: ppp-mod-pppoe
Version: 2.4.9.git-2021-01-04-4
Depends: libc, kmod-pppoe
Status: install user installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935

Package: kmod-phy-microchip
Version: 5.15.134-1
Depends: kernel (= 5.15.134-1-4d407d5f01a611de6825ef905c07d710), kmod-libphy
Status: install ok installed
Architecture: aarch64_cortex-a72
Installed-Time: 1696887935
Auto-Installed: yes

root@OpenWrt:/# 

root@OpenWrt:/# uci export network
uci: Parse error (too many arguments) at line 1, byte 26
root@OpenWrt:/# uci export dhcp
package dhcp

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.auto'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv6 'server'
	option ra 'server'
	option ignore '0'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

root@OpenWrt:/#  uci export firewall
package firewall

config defaults
	option syn_flood '1'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'

config zone
	option name 'lan'
	list network 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'

config zone
	option name 'wan'
	list network 'wan'
	list network 'wan6'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'

root@OpenWrt:/# ip -4 addr
root@OpenWrt:/# ip -4 ro li tab all
root@OpenWrt:/# ip -4 ru
0:	from all lookup local 
32766:	from all lookup main 
32767:	from all lookup default 
root@OpenWrt:/# ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/* 
lrwxrwxrwx    1 root     root            16 Oct  9  2023 /etc/resolv.conf -> /tmp/resolv.conf
lrwxrwxrwx    1 root     root            35 Jun 10 14:14 /tmp/resolv.conf -> /tmp/resolv.conf.d/resolv.conf.auto
-rw-r--r--    1 root     root             0 Jun 10 14:14 /tmp/resolv.conf.auto
-rw-r--r--    1 root     root             0 Jun 10 14:14 /tmp/resolv.conf.d/resolv.conf.auto

/tmp/resolv.conf.d:
-rw-r--r--    1 root     root             0 Jun 10 14:14 resolv.conf.auto
root@OpenWrt:/# head -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
==> /etc/resolv.conf <==

==> /tmp/resolv.conf <==

==> /tmp/resolv.conf.auto <==

==> /tmp/resolv.conf.d <==
head: /tmp/resolv.conf.d: I/O error

==> /tmp/resolv.conf.d/resolv.conf.auto <==
root@OpenWrt:/# 
root@OpenWrt:/# 

root@OpenWrt:/# opkg update -v
opkg version d038e5b6d155784575f62a66a8bb7e874173e92e (2022-02-24)
root@OpenWrt:/# opkg update -V
opkg_conf_parse_file: Loading conf file /etc/opkg.conf.
pkg_hash_load_status_files: 

Additional info

There seems to be some mistake here which creates the problem.
Could you paste the file?
cat /etc/config/network

root@OpenWrt:/# cat /etc/config/network
config device option name 'br-lan'
option type 'bridge'
list ports 'eth0'

config interface 'wan'
option device 'eth1'
option proto 'dhcp'

config interface 'wan6'
option device 'eth1'
option proto 'dhcpv6' 


Obvious fix:

config device \newline
 option name 'br-lan'

Would be easier to start fresh and dont overestimate own skill with command line editors. Nobody is watching, you can use web luci :wink:

3 Likes

Thanks!

However, I'm still facing an issue where opkg update isn't providing any message logs. Sorry for all these questions—I'm a beginner with OpenWRT.

Is your config/installation relatively close to the standard/default state? If so, the fastest solution is to simply pop out the card, re-image it, and then start again.

1 Like

I recently flashed the OpenWRT image again and reinserted the SD card into my Raspberry Pi 4B, but all the previous files are still present, just as they were before. Note: I had accidentally removed the opkg folder prior to this.

Erase the card first to make sure you've got a completely fresh start.

Yes, I formatted the SD card before flashing the new image.

That's odd...

What is the exact filename of the image that you're using to write to the card? Where did it come from (link)?

openwrt-23.05.0-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz

While you're re-writing the card, grab the most recent version of OpenWrt (23.05.3):
https://downloads.openwrt.org/releases/23.05.3/targets/bcm27xx/bcm2711/openwrt-23.05.3-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz

With this new image, all the previous issues seem to be resolved. However, running opkg update still shows download failed messages as follows, despite my LAN connection being fine.`root@OpenWrt:/# opkg update
Downloading https://downloads.openwrt.org/releases/23.05.3/targets/bcm27xx/bcm2711/packages/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/targets/bcm27xx/bcm2711/packages/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/base/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/base/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/luci/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/luci/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/packages/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/packages/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/routing/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/routing/Packages.gz

Downloading https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/telephony/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/23.05.3/packages/aarch64_cortex-a72/telephony/Packages.gz

Collected errors:

You need to connect WAN port to some internet socket to do any downloads.

The pi only has a single Ethernet port and WiFi. There a few ways to approach the issue - the two most recommended would be: enable WiFi and then reconfigure the Ethernet port as your wan, or setup the lan interface such that it can join your existing lan.