How do I use a usb drive for packages

I want to use a usb drive for packages so that I can install docker because the built in storage is only like 15mb

ive tried https://openwrt.org/docs/guide-user/additional-software/extroot_configuration but that didnt help(I think it does mount the drive on boot now tho)

also if anyone knows anything else that could help with getting docker working on openwrt tell me

Just pick a mount point and configure your docker config files to use that mount point. I do this for lxc on a device that has no room either.

# cat /etc/config/fstab 

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option enabled '1'
	option uuid '04cc6e19-3217-4486-99a0-e087ac950576'
	option target '/mnt/sda1'
	option fstype 'ext4'

# cat /etc/lxc/lxc.conf
lxc.lxcpath = /mnt/sda1/lxc

I cant even install the docker package because I dont have the 12 mb required

I have no experience with your situation.

What you want is extroot, as you said you've tried.

It should absolutely mount the drive on boot... did you follow the process exactly? Did you see any error messages or other clues as to why it wasn't working for you?

What device are you using? I ask because you may not have enough RAM to actually run Docker (you can easily expand the flash storage space using a USB stick or other external media, but you will probably run out of RAM).

ubus call system board
3 Likes

im using an AVM FRITZ!Box 4040 and it has like 250mb ram or something, so now I am actually not sure if I will be able to run docker but I still want more space for other packages either way

and for extroot, it is mounting the drive because I can access it with cd /mnt and see it when I go to 192.168.1.1/cgi-bin/luci/admin/system/mounts but it isnt letting me install anything there when I go to 192.168.1.1/cgi-bin/luci/admin/system/opkg pretty sure the command also doesnt let me

also I dont think there are any errors but also not really sure where to look and every command looked like it ran correctly

If you’ve setup extroot, you can verify the status by look at these commands:

mount
df -h

Please post the output of that here.

mount:

/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock14 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,noexec,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
/dev/sda1 on /mnt type ext4 (rw,relatime)

df -h:

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 4.0M      4.0M         0 100% /rom
tmpfs                   121.2M      1.2M    120.0M   1% /tmp
/dev/mtdblock14          21.7M     15.3M      6.4M  71% /overlay
overlayfs:/overlay       21.7M     15.3M      6.4M  71% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               461.8M     31.1M    401.6M   7% /mnt

This shows that sda1 has ~462MB of space (total), but it looks like the extroot didn't work to mount this as overlay.

I'd recommend resetting the router to defaults, then following the extroot process exactly -- post the entire ssh session and we'll see if there are any mistakes.

1 Like

how would I reset it to defaults and would that break anything?

firstboot -y && reboot

Well, it resets the router to the completely default state (including wifi disabled, default network configuration, no installed packages)... so... "break" depends on your perspective. This is usually the way to 'fix' things where there are unknown or old configs that might be wrong... fresh start and then rebuild.

Before you reset, you can make a backup of your current config (this doesn't include user-installed packages, but the config files for those packages would be included in the backup).

1 Like

would I be able to do this but still have wifi to be able to access the router? also would this delete any file that I have made on the router and if it does how would I back those up?
also how much ram is required for docker?

You can backup whatever files you want by making sure it is included in the sysupgrade config file /etc/sysupgrade.conf

While there are ways to get wifi to be on by default, you'd have to create your own custom images. That's doable, but maybe more work than is warranted. Without that, you'd reset your router to defaults and you'd need to connect by ethernet to do the initial config (such as turning on Wifi). Then, from there you'd follow the extroot process and go from there.

looks like 512MB is the absolute minimum.

k ill try to get it connected with ethernet tomorrow and also would just putting /root/ in /etc/sysupgrade.conf be a good idea?

Yes, if you have files stored there, it will back them up.

also would it be possible to run a docker container in swap memory and if yes, how do I setup swap on openwrt

also so this sysupgrade.conf file will work?

## This file contains files and directories that should
## be preserved during an upgrade.

# /etc/example.conf
# /etc/openvpn/
/etc/init.d/startinfo.sh
/root/

Yes, but no.
I think it would function, yes. But the performance would be unacceptably slow. It would also wear out your external storage very rapidly.
If you really want to try it:

Don't forget -- if this is your main router and wifi AP, that would mean that everything gets slowed down. It simply isn't a good idea to try to run Docker on an embedded device like this that is also a key part of your network infrastructure.

Yes.

1 Like

the command said something was mounted as /overlay only erasing files and the wifi still works

nevermind, fixed it

resetting it fixed it and now it works