Month: October 2017

  • Plex Media Server Package not starting anymore after moving its Library

    In order to empty a volume of my Synology, I did move all shared folders from that volume to another. After this operation, I was not able to play movies anymore with Plex. I noticed that, although I was still able to browse the movies via my Plex Apps, the Plex Media Server Package was actually stopped and unable to restart. To fix this, I had to edit the path of plex’s library in the adequate config file.

    Click to Read More

    Moving some “standard” Shared Folders used by Synology’s Packages didn’t result in any issue. Ex.: when moving the “music” folder, Synology prompted me to ask if it could stop properly the “Audio Station”. And once the folder moved, I was able to restart the “Audio Station” without any problem later.

    But this wasn’t the case for the “Plex” folder.

    Moving Shared Folders
    Moving Shared Folders

    Opposite to moving the “music” folder, Synology didn’t stop here explicitly the “Plex Media Server” Package. But once the “Plex” folder moved, the Package appeared to be stopped anyway. And trying to restart it, the following error was displayed by the Package Manager: Failed to run the package service …

    I found the following error in the log file using the command: cat /var/log/messages

    init: pkgctl-Plex Media Server pre-start process terminated with status 1
    synoscgi_SYNO.Core.Package.Control_1_start: servicecfg_internal_lib.c: Failed to start job [pkgctl-Plex Media Server] [0xD900 privilege.cpp]

    What was weird, is that I was still able to browse the movies in Plex Apps. The reason was that Plex processes were still running as I noticed later.

    To fix the problem, I did open a SSH Console using Putty, logged in as admin and went into root mode by typing the command: sudo -i

    I did next kill all the Plex processes:  kill -9 $(ps -gaceux | grep ‘plex’ | awk ‘{print $2}’)

    I went to the Plex Media Server path: cd /var/packages/Plex Media Server/target

    And did replace the old volume of the library (volume3) with the new one (volume1) : sed -i “s/volume3/volume1/” plex_library_path

    Et voilà, I was next able to start the Plex Media Server Package.

    Loading

  • Synology Cloud Station and Cloud Sync are slow

    I was wondering why Cloud Station Backup and Cloud Sync were so slow on my NAS. It appeared that it was “normal” for Cloud Sync, but could be improved for Cloud Station Backup, especially on my LAN, by using my NAS’ local IP instead of the “QuickConnect” feature.

    Click to Read More

    Cloud Station

    I found here that using “QuickConnect” with Cloud Station, the traffic was routed through Synology’s servers, making it incredibly slow. In my LAN, it really accelerated as soon as I replaced QuickConnect by the local IP of my NAS or with a domain address resolved by my local DNS.

    Cloud Sync

    I found here the reason why Cloud Sync was slower than native Sync applications. The answer given by Synology is:

    Could Sync is performing sync, it is heavy process, please see below detailed information from help:Why is Cloud Sync slower than other cloud services’ PC applications?

    Due to the below limitations, Cloud Sync might take longer to sync files with public cloud services than the official PC applications such as Dropbox and Baidu.

     

    • Speed limits imposed by cloud service providers: Although no public cloud service provider has disclosed any information related to this topic, it is highly possible that public cloud servers communicate with their official PC applications through a dedicated tunnel/protocol, or impose bandwidth limitations on third-party applications that access their services on a regular basis (such as Cloud Sync).
    • No incremental update: Some cloud service providers do not releases a public API for developers to track file changes. This means Cloud Sync must re-download and sync the entire file every time a file has been modified, even when you’ve only made partial modifications. On the other hand, cloud service providers’ official PC applications might be able to re-download and sync the modified bits only, reducing sync time.
    • No local network sync: Certain public cloud service providers offer LAN sync, a technique that allows one client to obtain files from existing clients in the same local area network (LAN), thus significantly boosting sync speed. However, LAN sync accesses files in client computers without notifying them, which could possibly become a security backdoor. Therefore, this feature is not included in Cloud Sync.

    Given the above limitations, the syncing performance of Cloud Sync shall continue to be enhanced, while also maintaining the safety and security of your Synology NAS.

    DS currently does not control the sync speed, and does not have function to enhance it.

    However, we will continue to try improve our service and product.

    Loading

  • df and du commands hanging/very slow and not displaying all info

    I have developed a Synology Package to move Packages from a volume to another. He suddenly became very slow when trying to display the list of Packages and Volumes existing on my NAS. I finally found that it was due to mount points not accessible and making the ‘df’ command not responsive.

    Click to Read More

    In my Package, named Package Mover (See Blog’s menu SPK Server), I am using the command ‘df’ to list the existing Volumes. This is the one that was extremely slow.

    To investigate the problem, I did display the errors of the System Kernel with the command ‘dmesg’ and found plenty of messages like ”CIFS VFS: Unexpected lookup error -112″

    I also noticed that when ‘df’ was finally displaying results, there was no information about the volume1.

    As by accident, I remembered that I did use CIFS VFS to recently mount some shared drives of a remote Windows Server, I checked if there was any issue with those. And there was:

    xxxx:~# ls -la /volume1/mount/Storage/
    ls: cannot access /volume1/mount/Storage/Movies: Host is down
    ls: cannot access /volume1/mount/Storage/Series TV: Host is down
    ls: cannot access /volume1/mount/Storage/Series: Host is down

    total 0
    drwx——+ 1 admin users 42 Oct 15 19:00 .
    d———+ 1 root root 42 Oct 14 11:56 ..
    d?????????? ? ? ? ? ? Movies
    d?????????? ? ? ? ? ? Series
    d?????????? ? ? ? ? ? Series TV

    I noticed how serious was this issue when my shell crashed while trying to autocomplete the name of a mounted folder:

    umount /volume1/mount/Storage/^C
    malloc: unknown:0: assertion botched
    free: called with unallocated block argument
    last command: ls /volume1/mount/
    Aborting…Aborted (core dumped)

    => Shell killed !!

    So, I did unmount and delete all the subfolders, and the problem disappeared

    xxx:~# umount /volume1/mount/Storage/Movies
    xxx:~# umount /volume1/mount/Storage/Series
    xxx:~# umount /volume1/mount/Storage/Series\ TV
    xxx:~# ls /volume1/mount/Storage/
    Movies Series Series TV
    xxx:~# rm -R /volume1/mount/Storage/Movies
    xxx:~# rm -R /volume1/mount/Storage/Series
    xxx:~# rm -R /volume1/mount/Storage/Series\ TV
    xxx:~# ls /volume1/mount/Storage/

    Now, ‘df’ executes within a ms and lists all the expected information!

    Loading

  • WebStation 2.1.0-0128 beta – php display_error enabled

    I did update my WebStation to the latest beta version. And although the option to “enable Display_Errors to display php error message” was disabled in the WebStation configuration pane, I saw warnings everywhere in my WordPress blog. No choice but erase the WebStation and reinstall it.

    Click to Read More

    Errors were appearing although the option was disable both for php 7.0 and php 5.6.

    Enable Php Display Errors
    Enable Php Display Errors

    Impossible to uninstall the WebStation as the Configuration Center see that various other Packages denpend on it: Apache2.4, WordPress, Apache2.2, phpMyAdmin.

    Also impossible to downgrade by manually installing a previous version.

    So, I had no choice but connect on my NAS via a SSH console using Putty and enter the root mode (with the command sudo -i) to delete the WebStation Setup :

    • ls -la /var/packages/WebStation/target  => this is showing you the volume<x> where it’s installed
    • rm -R /usr/syno/etc/packages/WebStation
    • rm -R /var/packages/WebStation
    • rm -R /volume<x>/@appstore/WebStation
    • rm -f /usr/syno/synoman/webman/3rdparty/WebStation

    I did next manually installed the WebStation 2.0.1-0111 from https://usdl.synology.com/download/Package/spk/WebStation/

    I had to reconfigure the General Settings and Php Settings, et voilà.

    Loading

  • Install Git command on Synology

     

    Installing git on Synology using IPKG is really easy.

    Click to Read More

    Install first IPKG as explained here and, in the ssh console, run next as root: ipkg install git

    You can also simply install it using ipkgGui. That’s even much easier than using a ssh console 😉

    Now, you can use the command git in a ssh console…

    Ex.: first thing you should do is to set up your name and email by typing:

    git config –global user.email <your_email>
    git config –global user.name <your_name>

    To clone a remote projet, in a local folder,  type:

    cd /<some_local_path>/

    git clone https://github.com/<user-name>/<repository>.git –branch <remote_branch-name>

    where “remote_branch-name” is a branch like “master”, “develop”, …

    The URL can be found using the “Clone or download” button of any GitHub project (See “Clone with HTTPS”).

    Clone GitHub Repository
    Clone GitHub Repository

    To update that project with a specific branch, type e.g.:

    git fetch origin develop

     

    Documentation can be found here.

    NB.: To install Git Server, look here

    Loading

  • Synology: Expanding Volume shows no progress

    I did start an expansion of my main volume by adding 2 x 3 TB, 24h ago, and looking at the progress, it’s still 0%. But it seems that the display is incorrect. Looking via a console, on can see some concrete progress.

    Click to Read More

    If I look into the Storage Manager, I see no progress:

    Expanding (Checking parity consistency 0.00%)

    Expand Volume No Progress
    Expand Volume No Progress

    To see some progress, try the following command in a ssh console:

    cat /proc/mdstat

    One can see that a disk is currently resyncing and should end in xxx minutes. Another one is waiting for a resync.

    Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
    md3 : active raid5 sdd7[2] sdc7[1] sdg7[0]
         1953485824 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]
         [===>...............] resync = 28.7% (281233152/976742912) finish=846.3 min speed=13696K/sec
    md5 : active raid5 sdd6[4] sdc6[3] sdg6[2] sdb6[1] sda6[0]
         1953485824 blocks super 1.2 level 5, 64k chunk, algorithm 2 [5/5] [UUUUU]
         resync=DELAYED
    md2 : active raid5 sdd5[6] sdc5[5] sdg5[4] sdf5[3] sde5[2] sdb5[1] sda5[0]
         11692100736 blocks super 1.2 level 5, 64k chunk, algorithm 2 [7/7] [UUUUUU U]
    md4 : active raid1 sdh5[0]
         3902187456 blocks super 1.2 [1/1] [U]
    md1 : active raid1 sda2[0] sdb2[1] sdc2[2] sdd2[3] sde2[4] sdf2[5] sdg2[6] sdh2[ 7]
         2097088 blocks [8/8] [UUUUUUUU]
    md0 : active raid1 sda1[0] sdb1[1] sdc1[2] sdd1[3] sde1[4] sdf1[5] sdg1[6] sdh1[ 7]
         2490176 blocks [8/8] [UUUUUUUU]

    Loading

  • Synology: My Own Knowledge Base

    I always forget plenty of details useful to work on my Synology, such as path, tips & tricks, command or service names, etc.. So, to retrieve them more easily, I will publish them here.

    Click to Read More

    Post under construction…

    Connect on a Synology

    • via SSH console: see here
    • via GateOne on DSM: see here

    Synology Commands

    • Located in /usr/syno and /usr/syno/sbin resp. for binaries and script requiring root privileges
    • Interesting scripts in /usr/syno/etc.defaults/rc.sysv/ (to be used as root)
      • ./apparmor.sh {start|stop|restart|try-restart|reload|force-reload|status|kill|add_packages_profile|remove_packages_profile}
      • ./share-preapre.sh start
      • ./sftp.sh reload
      • ./tfpt.sh reload
      • ./ningx.sh reload
      • ./synomount.sh {start|stop}
      • ./pgsql.sh {start|stop|restart|reload|status}
      • ./S80samba.sh {start|stop}
      • ./S83nfsd.sh {start|stop}
      • ./inetd.sh { prestart_telnetd | poststop_telnetd | prestart_cups_lpd | poststop_cups_lpd }

    Other command paths:

    Interesting Paths

    • Web folder: /var/services/web
      • Reference onto /volumex/web
    • Package folder: /var/packages/<Package Name>
      • See 3rd Party Packages bellow
    • Link onto all 3rd party packages
      • /usr/syno/synoman/webman/3rdparty

    Synology Services

    • Names:
      • Packages’ service name: pkgctl-<package>
      • Ex.: pkgctl-WebStation
      • For others, execute: /usr/syno/sbin/synoservicecfg –list
    • Config
      • path: /usr/syno/etc/synoservice.d/<service>
    •  Commands:

    Need to be root:

      • /usr/syno/sbin/synoservice −−help
      • /usr/syno/sbin/synoservicecfg −−help (alias of above)
      • /usr/syno/sbin/synoservicectl −−help (limited features of above)
      • /usr/syno/sbin/synoservicemigrate −−help
      • Ex.: synoservice −−restart pkgctl-WebStation

    No need to be root:

      • /usr/syno/sbin/synopkg
      • /usr/syno/sbin/synopkgctl
    •  Status for Packages:
      • Each service has a file named “enabled” which is created when the service is started via the Packager Center UI (/var/packages/<package>/enabled).
      • This file is deleted once one stops the service via the Package Center UI.
      • This file is not deleted if one stops the service with the command line /usr/syno/sbin/synoservicecfg –stop pkgctl-<package>
      • This ile is not recreated if one (re)starts the service with the command line /usr/syno/sbin/synoservicecfg –start pkgctl-<package>
      • Command line ex.:
        • /usr/syno/sbin/synoservicecfg –stop “pkgctl-AudioStation”
        • output: warn: The runkey of service [pkgctl-AudioStation] has been set to “No”
        • /usr/syno/sbin/synoservicectl –stop “pkgctl-AudioStation”
        • output: pkgctl-AudioStation stoped.
    • List all Services
      • /usr/syno/sbin/synoservicecfg –list
      • /usr/syno/sbin/synoservicecfg –list-config
    • More options
      • /usr/syno/sbin/synoservicecfg —help-dev

    3rd Party Packages

    • Access path: /usr/syno/synoman/webman/3rdparty/
      • This is a link to the binaries/web page/scripts of the actual application to run.
      • ls -la /usr/syno/synoman/webman/3rdpart/<packagename> will give you the actual path
    • Access Url: http://<YourNas>:<Admin Port>/webman/3rdparty/<Package Name>/….
      • To check the URL of a 3rd Party Package, simply Right Click on it in DSM’s Main Menu and select “Open in new window”
    • Setup path (scripts, config, enabled “flag”, INFO): /var/packages/<package>/
      • This is the location of all info used be DSM to install, access and run the package
      • Link onto the package itself /var/packages/<package>/target => /volume<x>/@appstore/<Package Name>
        • target/ is only created after the installation and can therefore not be used in Package’s pre-installation script.
      • Link onto the package configuration : /var/packages/<package>/etc => /usr/syno/etc/packages/<Package Name>
        • etc/ is only created after the installation and can therefore not be used in Package’s pre-installation script.
    • Installation path: /volume<x>/@appstore/<package>
      • This is the path to the binaries/web page/scripts of the application.
      • Found via: ls -la /var/packages/<package>/target
    • Configuration path: /usr/syno/etc/packages/<package>
      • This is the path where the configuration settings of the application can be stored.
      • This path is not deleted during an upgrade/uninstallation.
      • Found via: ls -la /var/packages/<package>/etc
    • List the custom feeds: cat /usr/syno/etc/packages/feeds

    So, concretely, the structure of a Package Folder under /var/packages/<Package name> is like:

    • conf/
    • enabled
    • etc -> /usr/syno/etc/packages/<Package name>
    • INFO
    • scripts/
      • postinst
      • postuninst
      • postupgrade
      • preinst
      • preuninst
      • preupgrade
      • start-stop-status
    • target -> /volume<x>/@appstore/<Package name>
    • WIZARD_UIFILES/
      • install_uifile or install_uifile.sh
      • uninstall_uifile or uninstall_uifile.sh
      • upgrade_uifile or upgrade_uifile.sh
      • NB.: each file can be postfixed with the language. Ex.: install_uifile_enu or install_uifile_fre

    NB: Sometimes, ‘target’ can be a link on -> /usr/local/packages/@appstore/<Package name>

    Volumes

    • Volume Raid storage calculator: https://www.synology.com/fr-fr/support/RAID_calculator

    Logs

    • Main Log path: /var/log/
    • Package installation log: /var/log/synopkg.log
    • Services log:  /var/log/synoservice.log
    • Services’ path start/stop logs: /var/log/startup
    • Apache’s log: /usr/local/etc/apache22/logs /usr/local/etc/apache24/logs
    • nginx’s log: /var/log/nginx/

    If something goes wrong and you look for information, delete all existing logs (rm -R) and redo the failing operation. Next, look for newly created logs 😉

    Web Server

    The Web server can be nginx, apache22 or apache24, as:

    • Configured globally in the Web Station > General Settings > HTTP back end Server or
    • Configure per Virtual Host in Web Station > Virtual Host

    Config files are per Web server types:

    • Apache 22’s configs are under /usr/local/etc/apache22. Ex.:
      • virtualhost config file: /usr/local/etc/apache22/sites-enabled/httpd-vhost.conf (notice: changes in this file are lost after restarting the Web Station)
      • httpd conf file:  /usr/local/etc/apache22/conf/httpd22.conf
    • Apache 24’s configs are under /usr/local/etc/apache24
    • Nginx’s configs are under usr/local/etc/nginx

    But also in the Web Station configs:

    • Virtual Host, depending if using php56 or php 70, are also in  /var/packages/WebStation/etc/php56/conf.d/webstation_vhost.ini (notice: changes in this file are lost after restarting the Web Station)

    Restart Web Server:

    • synoservicecfg restart nginx
    • synoservice restart pkgctl-Apache2.4
    • synoservice restart pkgctl-WebStation

    Interesting website info here.

    Plex Server

    • Plex Media Server data path: /Volume<x>/Plex/Library/Application Support/Plex Media Server/
    • Complete Server Backup:
      • Stop Plex Media Server (via the Package Center)
      • Copy the directory mentioned above to backup Plex’s database et configuration.
      • Restart Plex Media Server
    • Database Backup:
      • Backups are in /Volume<x>/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/
      • Stop Plex Media Server (via the Package Center)
      • Move away the followin file
        • com.plexapp.plugins.library.db
        • com.plexapp.plugins.library.db-shm
        • com.plexapp.plugins.library.db-wal
      • Rename the latest (or any older) com.plexapp.plugins.library.db-YYYY-MM-DD into com.plexapp.plugins.library.db
      • Restart Plex Media Server

    Synology Certificates

    They are (in most recent DSM version) under /usr/syno/etc/certificate/system

    Synology Model

    Notifications

    • Notification messages: /usr/syno/synoman/webman/texts/enu/mails
    • Notification sending mode: /usr/syno/etc/notification/notification_filter.settings
    • Other Notification messages (unknown usage): /usr/local/share/notification/dsm/enu/mails
    • Command:
      • /usr/syno/bin/synonotify <notification>  ‘{“[%VAR1%]”: “value1”, “[%VAR2%]”: “value2”}’
    • Debugging:
      • syno_hibernate_debug_tool –enable 10
      • syno_hibernate_debug_tool –disable

    Event Logs

    • Event messages: Events : /usr/syno/synosdk/texts/enu/events
    • Command:
      • synologset1 [sys | man | conn] [info | warn | err] eventID(%X) [substitution strings…]

    Package Installation scripts

    • Documentation about installation scripts are here .
    • The etc folder of the package is a link onto /usr/syno/etc/packages/<Package Name>/
    • A script must exit 0 to succeed. Any other value will fail the installation/upgrade/uninstallation.
    • One can redirect all errors into the log with code like this:

    exec 2<&-
    exec 2>>/var/log/MyPackageErr.log

    • All information logged in $SYNOPKG_TEMP_LOGFILE are displayed at the end of the installation/upgrade/uninstallation in any cases (success or failure).
    • Add a <br> at the end of each line in $SYNOPKG_TEMP_LOGFILE to have a nice display. Ex.: sed -i ‘s/$/<br>/’ “$SYNOPKG_TEMP_LOGFILE”
    • One can decide to fail an installation/upgrade/uninstallation with code like this:

    if [ -s “/var/log/MyPackageErr.log” ]; then
    sed -i ‘s/$/<br>/’ “/var/log/MyPackageErr.log”
    cat /var/log/MyPackageErr.log >> $SYNOPKG_TEMP_LOGFILE
    exit 1
    fi

    • Add or Remove an port configuration in the firewall by command:

    SERVICETOOL=”/usr/syno/bin/servicetool”
    FWPORTS=”/var/packages/<Package Name>/scripts/<Package Name>.sc”

    In the ‘posinst’ script:

    ${SERVICETOOL} –install-configure-file –package ${FWPORTS} >> /dev/null

    In the ‘preuninst’ script:

    if [ “${SYNOPKG_PKG_STATUS}” == “UNINSTALL” ]; then
    ${SERVICETOOL} –remove-configure-file –package $<Package Name>.sc >> /dev/null
    fi

    The structure of the <Package Name>.sc file is described here https://help.synology.com/developer-guide/integrate_dsm/install_ports.html

    Following ports are used by Synology : https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Network/What_network_ports_are_used_by_Synology_services

    Using commands is only required with firmware version < 6.0-5936

    Loading