USB drive erasing after snapshot update

Topic says it all, using vnstat2 and luci-app-statistics, I have a mounted usb 32gb thumbdrive which these statistics are written to. Any type of reboot seems to hold historical with out an issue. Any type of system firmware snapshot update seems to loose or overwrite all data. I have tried to also unmount and remove the drive during the update and re-mount after, no luck. Any type of firmware snapshot upgrade looses all data... I am assuming I am missing either some simple configuration issues or step during this. Thoughts?

Are you certain that the drive is actually being erased? It is likely (i.e. assured unless you are building custom images) that the snapshot upgrades you are doing do not include the necessary USB storage drivers and possibly the file system support, as well as file sharing packages if you are accessing this drive from another device. This means you have to re-install those packages to have access to the data on the drive.

1 Like

To be honest? I am not sure exactly what is going on, except for some reason the statistics from the 2 different monitoring apps are both being lost (only on an update). When I initially setup the usb drive I did go through the quick setup, but no extra packages had to be installed. I do build my own snapshot packages but do not include anything extra relating to the usb drive, it just has always worked, unless something is being auto installed once it is detected?

In other words, i am not installing any packages after the fact for the usb drive to work. All my packages are installed before applying any update.

Are you sure? What was the "quick setup" -- do you have a wiki page or tutorial that you followed?

Nothing is auto-installed. It isn't clear to me how it worked in the past if you never installed any additional packages and you don't include them in your snapshot builds. Usually you need some kmods for USB and for the file system on the drive (such as ext4, fat32, etc.)

I think you should be installing packages and configuring a mount point. When you upgrade, no user installed packages are maintained. And any mount points you have created are not going to be part of the configuration unless you "keep settings" when doing the upgrade.

You might want to unplug the drive from your router and take a look at it on a regular computer. It is very unlikely that anything was erased as a function of your upgrade.

Finally, see this documentation about using USB storage:

1 Like

First of all I get a bit confused when you talk about a “quick setup” in OpenWRT?
Nothing in OpenWRT is similar to a “quick setup”!?

Are you sure you have ever written any data to the actual USB flashdrive? You could have written the data to the router flash instead?

It happened to me on a raspberry once. The only real way to tell is to remove the flash drive when it works and see if the data is still “there” or look in the flash drive from another computer.

1 Like

Follow the link @psherman posted.
Fwiw, I'm a CLI type, but found using LuCI a better fit to accomplish this.

By reference, I use a 32Gb USB partitioned equally into /mnt/sda1 - /mnt/sda4. If you have all prerequisites ready, go to Luci/System/Mount Points. Click on Generate Config, and select "Automount Filesystem". Scroll down to Mounted File Systems and look for your USB drive (sda*). Go down again to Mount Points and you should see your drive listed along with additional options,

Click on enabled, Edit, select your mount point, save and apply.

OR, check for example, Vnstat2 configured for persistent storage showing usage over a period:
Screenshot from 2021-12-07 01-38-52
cd /mnt/testing/project - vi - cat - verify changes survived.

Yes but did you lock the file address to the flash drive with fixed link to hardware UUID or UID (I don’t remember now which one is hardcoded actual hardware ID and which one is software ID and changed when you do different operations).

I have it configured to mount the device by UUID instead of mounting it using a fixed device node.

The Vnstat statistics is held in a database file. If you move this file to a flash drive, then the flash drive will hold it. All you have to do after a upgrade is to point the vnstat configuration file to the flash drive database file.The default destination for the database file is RAM (/tmp) due wear-off of the flash memories in the devices.

Sorry for the delay in response, work, life, etc... got some time to look back into this. Stopped writing to the drive on Nov 14th. Package ' block-mount ' was missing from the build causing the issue. Everything between Nov 14th and Dec 10th are missing, as it appears it was just writing to the router flash and not the usb flash. Seems to be working properly again.

Quick setup was used here

Went through some more detailed things here

Missing the block-mount package in the build is the issue. No other additional package required.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.