info_i_25x25.png Due to unforeseen weather conditions we are experiencing higher chat wait times. Remember you can also submit a ticket and one of our support representatives will get back to you as soon as possible. We apologize for the inconvenience.

EdgeRouter - Are my changes lost when I upgrade the firmware image?

Q: I followed the instructions for adding debian packages to my system, but will those packages be lost when I upgrade to a new image?

A: Yes, the upgrade creates a new filesystem.  One approach that I use is to putting the following script in /config/scripts/post-config.d/

[email protected]:/config/scripts/post-config.d$ cat install_my_packages.sh
#!/bin/bash

doneit='/var/lib/my_packages'
packages='screen rsync iftop iptraf mtr-tiny bmon'

if [ -e $doneit ]; then
exit 0;
fi

apt-get update
apt-get install -y $packages 
if [ $? == 0 ]; then 
 echo package install successful 
 touch $doneit 
else 
 echo package install failed 
fi 
exit 0

Things to note:

  1. The entire /config directory gets copied to the new image, so that's a good place to put things like scripts, openvpn keys, etc.
  2. Every executable in /config/scripts/post-config.d directory get run after boot-up and configuration is complete.  This script creates a file when upon completion, so it should only try to fetch the packages once.


Users have reported that the above script can cause problems when there is not enough space available on the root device. In which case the script below can be used to alleviate these issues:

sudo cat /config/scripts/post-config.d/install_my_packages.sh 
#!/bin/bash
packages='screen' doneit='/var/lib/my_packages' if [ -e $doneit ]; then
exit 0
fi
mount -t tmpfs -o size=30% tmpfs /var/lib/apt/lists

if [ $? != 0 ]; then

echo Could not mount tmpfs on /var/lib/apt/lists

exit 1

fi

apt-get update apt-get --no-install-recommends install -y $packages

if [ $? == 0 ]; then

echo Package install successful touch $doneit
else
echo Package install failed
fi

umount /var/lib/apt/lists
exit 0

Q: Since the system keeps 2 images, how do I switch back to the old image?

A: See the section on switching images at EdgeMAX image management.

 

Q: Can I find a file on the old image without rebooting into it?

A: Yes, the old filesystem can be found at  /root.dev/w.o/