Manage Storage for Application Files
When a package is installing, package.tgz will be extracted to /var/packages/[package identity]/target, which is a symbolic link pointing to a folder in a data volume selected by the end user. /var/packages/[package identity]/target is also available at the SYNOPKG_PKGDEST environment variable, one of the seven files in the script folder. Please see the "scripts" for more information.
Despite the fact that the directory /var/packages or /usr/local is reserved for 3rd-party applications, the storage space of system volume is limited. If the size of files to be installed exceeds the capacity of the system volume, storage space will run out. Hence, it is recommended that you directly read or write application files in /var/packages/[package identity]/target or another space of the data volume. You can also make a symbolic link in /usr/local to point to /var/packages/[package identity]/target or another space when running the postinst script. The path can be accessed easier in a library or a daemon. Please note that you may need to specify the correct prefix when running a configuration script so that the application can find the correct path information upon execution.
Synology releases DSM updates on a regular basis. Given that application files might be affected during the update procedure, it is important that you install your application in the correct directory to prevent them from being deleted when DSM is being upgraded in the system partition.
When DSM is being upgraded, the directory /var/packages/[package identity] and /usr/local will be backed up and restored automatically. However, some library files or built-in software might be modified during the upgrade procedure. In other words, if your application depends on the files which are subject to change, the application may not work afterward. In this case, you should check the status of these files or re-link them in the start-stop-status script to repair them if necessary. Alternatively, you can install them directly to /var/packages/[package identity]/target.