Category: Synology

  • Synology’s Scheduled Tasks

    I would like to find how to create Scheduled Tasks to execute a User-Defined Scripts on Synology using commands in a shell script. But I don’t find how-to. Here are the only info I was able to get.

    Click to Read More

    The tasks created via Control Panel > Task Scheduler > Create > Scheduled Task > User-defined Script, are stored in the file /etc/crontab. Ex.:

    The tasks id are stored in /usr/syno/etc/scheduled_tasks. Ex.:

    [1]
    id=1
    last work hour=23
    can edit owner=1
    can delete from ui=1
    edit dialog=SYNO.SDS.TaskScheduler.EditDialog
    type=daily
    action=#common:run#: /usr/local/bin/php73 /var/packages/MODS_ServerMonitor/target/ui/cron/status.cron.php
    can edit from ui=1
    week=1111111
    app name=#common:command_line#
    name=Update Server Mon
    can run app same time=1
    owner=0
    repeat min store config=[1,5,10,15,20,30]repeat hour store config=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]simple edit form=1
    repeat hour=0
    listable=1
    app args={“notify_enable”:false,”notify_if_error”:false,”notify_mail”:””,”script”:”/usr/local/bin/php73 /var/packages/MODS_ServerMonitor/target/ui/cron/status.cron.php”}
    state=enabled
    can run task same time=0
    start day=0
    cmd=L3Vzci9sb2NhbC9iaW4vcGhwNzMgL3Zhci9wYWNrYWdlcy9NT0RTX1NlcnZlck1vbml0b3IvdGFyZ2V0L3VpL2Nyb24vc3RhdHVzLmNyb24ucGhw
    run hour=0
    edit form=SYNO.SDS.TaskScheduler.Script.FormPanel
    app=SYNO.SDS.TaskScheduler.Script
    run min=0
    start month=0
    can edit name=1
    start year=0
    can run from ui=1
    repeat min=15

    The task can also be displayed via a command line run as root (See here):  sudo synoschedtask –get id = 1

    ID: [1]
    Name: [Update Server Mon]
    State: [enabled]
    Owner: [root]
    Type: [daily]
    Start date: [0/0/0]
    Run time: [0]:[0]
    Repeat every [15] min (s) until [23]:[45]
    Command: [/usr/local/bin/php73 /var/packages/MODS_ServerMonitor/target/ui/cron/status.cron.php]
    Last Run Time: Mon Oct 28 23:00:02 2019
    Status: [Success]


    Loading

  • Use opkg instead of ipkg on Synology

    IPKG is not maintained anymore since 2014. As a replacement, one can use Entware, which offers more than 1800 packages.

    Click to Read More

    First enter a SSH session on your nas as root (See here).

    Check if your CPU model is a armv5, armv7, mips, x86-32 or x86-64. You can do so with one of the following command:

    • cat /proc/cpuinfo | grep -m 1 ‘model name’ | cut -d “:” -f 2 | cut -d “@” -f 1
    • uname -a

    Create now a folder to install Entware (NB.: The folder /opt may not yet exist. I.e.: Optware may not be installed yet. We will delete it if it exists. If it cannot be deleted – you could have a message that it’s in use – then reboot your Synology first).

    mkdir -p /volume1/@entware-ng/opt
    rm -rf /opt
    ln -sf /volume1/@entware-ng/opt /opt

    Depending on your CPU, execute one of the following commands

    • For armv5: wget -O – http://pkg.entware.net/binaries/armv5/installer/entware_install.sh | /bin/sh
    • For armv7: wget -O – http://pkg.entware.net/binaries/armv7/installer/entware_install.sh | /bin/sh
    • For mips: wget -O – http://pkg.entware.net/binaries/mipsel/installer/installer.sh | /bin/sh
    • For x86-32: wget -O – http://pkg.entware.net/binaries/x86-32/installer/entware_install.sh | /bin/sh
      For x86-64: wget -O – http://pkg.entware.net/binaries/x86-64/installer/entware_install.sh | /bin/sh

    Go now to your DSM and open the “Control Panel”. There, select the “Task Scheduler” > “Create” > “Triggered Task” > “User-defined script”

    Configure this new task to run at “Boot-up” :

    And to run the following commands:

    /bin/ln -sf /volume1/@entware-ng/opt /opt
    /opt/etc/init.d/rc.unslung start

    Finally, to include /opt/bin and /opt/sbin to the PATH variable, add . /opt/etc/profile at the end of /etc/profile with this command:

    echo “. /opt/etc/profile” >> /etc/profile

    You can now use the command opkg. The first action to do is: opkg update

    Check the list of packages available with: opkg list | more

     

     

    NB.: To remove IPKG from your Synology:

    1. umount /opt
    2. rm -R /opt
    3. rm -R /volume1/opt or rm -R /volume1/@optware (depends on where IPKG was installed)
    4. delete every reference to optware in /etc/rc.local
    5. rm /etc/rc.optware
    6. check that there is nothing related to ipkg in /etc/crontab
    7. reboot your NAS

    Loading

  • Retrieve files and folders from a Synology C2 backup

    My Nas Synology died recently and I wanted to retreive some content from my Synology C2 Backup.

    Click to Read More

    After 3 years being 24/7, my DS1815+ does not turn on anymore when I press the power button. The problem is not with the power supply. I did change it, but with no luck.

    Fortunatelly, I was using Hyper Backup to daily compy everything into “Synology C2 backup”. 

    But it’s not possible to retreive a complete foder from the backup via the Synology C2 web page. One can only download file by file 🙁

    To download a complete folder at once, you need the “Synology Hyper Backup Explorer” for desktop available in the Destkop Utilities section of the downloads.

    Loading

  • Setup DSM 6.2.2 in a Virtual Synology DS3617xs using VMWare

    Here is a step by step “How-To create a Virtual Machine to emulate a DS3617xs running DSM 6.2.2” using VMWare and Xpenology

    Click to Read More

    Xpenology is a bootloader for Synology’s operating system which is called DSM. It can be used to setup DSM on a PC or in a Virtual Machine like VirtualBox or VMWare.

    I am using VMWare 15. But any version from VMWare 11 should work.

     

    1: Download and unzip this package, containing:

    • the configuration of the virtual machine (dsm.ovf, dsm.vmx, disk.vmdk and synoboot.vmdk),
    • the xpenology boot file for DS3617xs (synoboot.img) and
    • the image of the DSM 6.2.2 for DS3617xs (DSM_DS3617xs_23739.pat)

    Notice that only the image “23739” is compatible with the boot file (Jun’s loader 1.03b).

    2: Open VMWare Workstation. If you never configured the default location where you want to create your Virtual Machines, press CTRL-P to open the “Preferences” panel. There, set this default location (I am using D:\VMWare).

    3: Go next to “Windows Explorer”, in the folder where you have unzipped the package, and double click dsm.ovf. This is going to import the VM into VMWare. Type a name for the new virtual machine (I am using DSM3617 6.2.2) and click “Import”.

    4: Here is the outcome to the importation. You can now click on “Power on this virtual machine”. But first, be ready to type F2 in the console to enter the Bios. You will have only 2 seconds to do so!

    5: As soon as you have run the VM, click into it to capture the keyboard, and press “F2”. If you missed it, the VM will try to boot from the network. In such a case restart the VM and try again! Once in the Bios, go to the Boot tab and swap the SATA Hard Disk with  the SCSI Hard disk. The VM has indeed to boot with the SATA disk containing the boot loader. Finally, Save and Exit the Bios. The VM will reboot.

    6: Again, quickly click into it to capture the keyboard and press the “down arrow” to select the loader for “VMWARE/ESXI” (attention, you don’t have a lot of time to start the selection). Press next Enter and the boot will load. The VM is ready to install the DSM image.

    7: Open the “Synology Assistant”, which is more efficient than the page http://find.synology.com to find your VM, and after 1 minute click on “Search”. If you didn’t wait long enough, you will see an Error message (In such a case, click Search “Again”. I never had to do this more than 3 times).

    8: Finally, the Assistant will find your VM. A webpage should automatically open (Otherwise, right click on the VM and select “Install”). Click on “Set up” in that page.

    9: Click next on the link “Manual Install”.

    10: Click on Browse to select the image of the DSM 6.2.2 for DS3617xs and select the file “DSM_DS3617xs_23739.pat” in the folder when you unzipped the package downloaded here previously.

    11: Finally, click on “Install Now” and confirm that the installation can override the disk… it’s the virtual SCSI Hard Disk member of the VM. No worry 😉

    12: The installation will take a few minutes and once completed, you will see in the VMWare Workstation that the VM is rebooting.

    13: On the installation page, you see a count down. If you want to check the status of the VM, you can go back to the Synology Assistant and Click Search. You should see that it’s restarting, etc… and is finally ready. At that moment, you can select the VM and click Connect.

    14: You will now be able to login into the VM and configure it. DO NOT select “Install the latest DSM version automatically” or “Install the important updates of DSM automatically”!!! The image 37739 is the latest compatible with the loader used by this VM. Upgrading your DSM will break the VM.

     

    15: You have now a DS3617xs with the DSM 6.2.2-23739.

    16: DO NOT upgrade or the disk will disappear and the VM won’t work anymore (Someone mentions that mounting the Disk on a SATA controller instead of a SCSI one helped… See here. But it didn’t work for me). Looking into the Synology Assistant, you would see that the Virtual Synology is not configured.

    17: It’s now time to use the SCSI Hard Disk to create a first Volume. Open the DSM Main Menu and start the Storage Manager. Go to “Storage Pool” and click “Create”. Use the HDD of 20GB. Next, go to “Volume” and click “Create”. Use the “Storage Pool” created previously.

    18: Now, you can upgrade the VM to your version of VMWare. Shutdown the DSM Properly (via the menu on the Buddy Icon in the top-right corner). The VM will soon stop.

     

    19: Once the VM stopped, upgrade it by clicking on “Upgrade this virtual machine”.

    Et voilà !

    Loading

  • Setup DSM 6.2.2 in a Virtual Synology DS918+ using VMWare

    Here is a step by step “How-To create a Virtual Machine to emulate a DS918+ running DSM 6.2.2” using VMWare and Xpenology

    Click to Read More

    Xpenology is a bootloader for Synology’s operating system which is called DSM. It can be used to setup DSM on a PC or in a Virtual Machine like VirtualBox or VMWare.

    I am using VMWare 15. But any version from VMWare 11 should work.

     

    1: Download and unzip this package, containing:

    • the configuration of the virtual machine (dsm.ovf, dsm.vmx, disk.vmdk and synoboot.vmdk),
    • the xpenology boot file for DS918+ (synoboot.img) and
    • the image of the DSM 6.2.2 for DS198+ (DSM_DS918+_24922.pat)

    2: Open VMWare Workstation. If you never configured the default location where you want to create your Virtual Machines, press CTRL-P to open the “Preferences” panel. There, set this default location (I am using D:\VMWare).

    3: Go next to “Windows Explorer”, in the folder where you have unzipped the package, and double click dsm.ovf. This is going to import the VM into VMWare. Type a name for the new virtual machine (I am using DSM918 6.2.2) and click “Import”.

    4: Here is the outcome to the importation. You can now click on “Power on this virtual machine”. If you want, you may also first increase the Memory, the Processors or the size of the SCSI Hard Disk (Do not touch the SATA Hard Disk which contains the boot loader).

    5: As soon as you have run the VM, click into hit to let it capture the keyboard, and press the “down arrow” to select the loader for “VMWARE/ESXI” (attention, you don’t have a lot of time to start the selection). Press next Enter and it will boot.

    6: Open the “Synology Assistant”, which is more efficient than the page http://find.synology.com to find your VM, and after 1 minute click on “Search”. If you didn’t wait long enough, you will see an Error message (In such a case, click Search “Again”. I never had to do this more than 3 times).

    7: Finally, the Assistant will find your VM. A webpage should automatically open (Otherwise, right click on the VM and select “Install”). Click on “Set up” in that page.

    8: Click next on the link “Manual Install”.

    9: Click on Browse to select the image of the DSM 6.2.2 for DS918+ and Select the file “DSM_DS918+_24922.pat” in the folder where you unzipped the package downloaded here previously.

    10: Finally, click on “Install Now” and confirm that the installation can override the disk… it’s the virtual SCSI Hard Disk member of the VM. No worry 😉

    11: The installation will take a few minutes

    12: Once the installation complete, you will see in the VMWare Workstation that the VM is rebooting. On the installation page, you see a countdown. If you want to check the status of the VM, you can go back to the Synology Assistant and Click Search. You should see that it’s restarting, installing patches, reconnecting and finally ready. At that moment, you can select the VM and click Connect.

    13: You will now be able to login into the VM and configure it.

    14: It’s now time to use the SCSI Hard Disk to create a first Volume. Open the DSM Main Menu and start the Storage Manager.

    15: Go to Volume and click Create. Select the HDD of 20GB, etc…

    16: You have now a brand new DS918+ with the DSM 6.2.2-24922 Update 3.

    17: Now, you can upgrade the VM to your version of VMWare. Shutdown the DSM Properly (via the menu on the Buddy Icon in the top-right corner). The VM will soon stop.

    18: Once the VM stopped, upgrade it by clicking on “Upgrade this virtual machine”.

    Et voilà !

    Loading

  • Capture a Synology Package during installation

    This is an update of a previous post on this topic.

    I noticed that since a recent update of DSM, my previous script was not working fine anymore, when trying to capture a spk during installation. So here is an improved version.

    Click to Read More

    [code language=”bash”]

    #!/bin/bash
    VOLUME=$1
    TARGET=$2

    #Copy also the expanded package ?
    COPYEXPAND=false

    if [ -z "$VOLUME" ]; then
    echo "usage: capture <source VOLUME> <target dir>"
    exit 0
    fi

    if [ -z "$TARGET" ]; then
    echo "usage: capture <source VOLUME> <target dir>"
    exit 0
    fi

    pattern="volume[0-9]+"
    if [[ ! $VOLUME =~ $pattern ]]; then
    echo "The name of the source volume must be like ‘volume<i>’ where <i> is numeric"
    exit 0
    fi

    if [ ! -d "/$VOLUME/@tmp" ]; then
    echo "Temporary dir not found: /$VOLUME/@tmp"
    exit 0
    fi

    if [ -d "/$VOLUME/@tmp/SynoCapture" ]; then
    rm -R "/$VOLUME/@tmp/SynoCapture"
    fi

    if [ -d "/$VOLUME/@tmp/@synopkg" ]; then
    rm -R "/$VOLUME/@tmp/@synopkg"
    fi

    echo "Press any key to stop the capture"

    if [ -t 0 ]; then stty -echo -icanon -icrnl time 0 min 0; fi

    count=0
    keypress=”
    echo "Going to copy the packages into $TARGET/SynoCapture"

    if [ ! -d "$TARGET/SynoCapture" ]; then
    mkdir "$TARGET/SynoCapture"
    fi

    while [ "x$keypress" = "x" ]; do
    if [ -d "/$VOLUME/@tmp/@synopkg/@download/" ]; then
    cp -nlR "/$VOLUME/@tmp/@synopkg/@download/." "/$VOLUME/@tmp/SynoCapture/"
    fi

    if [ "$COPYEXPAND" = true ]; then
    if [ -d "/$VOLUME/@tmp/pkginstall/" ]; then
    cp -nlR "/$VOLUME/@tmp/pkginstall/." "/$VOLUME/@tmp/SynoCapture/pkginstall/"
    fi
    fi
    let count+=1
    echo -ne $count’\r’
    keypress="`cat -v`"
    done

    if [ -t 0 ]; then stty sane; fi

    find "/$VOLUME/@tmp/SynoCapture/" -type f -name ‘@SYNOPKG_DOWNLOAD_*’ -exec sh -c ‘x="{}"; mv "$x" "${x}.spk"’ \;
    if [ "$COPYEXPAND" = true ]; then
    if [ -d "$TARGET/SynoCapture/pkginstall" ]; then
    rm -R "$TARGET/SynoCapture/pkginstall"
    fi
    fi
    cp -fR "/$VOLUME/@tmp/SynoCapture" "$TARGET/"
    rm -R "/$VOLUME/@tmp/SynoCapture"

    echo "$count captures done"
    exit 0

    [/code]

    Now the script will copy only the SPK file into the specified target folder. It’s also possible to copy the expanded version by setting the variable COPYEXPAND=true

    Also, now, I don’t find anymore a folder name “pkglist.tmp” containing files synoserver.enu and otherserver.enu. Those files used to contain the URL’s of all SPK available respectively on the official Synology website and on the various SPK servers that you configured in your Package Center > Settings > Package Sources.

    To make the capture even easier, I have create a Package named “MODS Package Capture, available on my SPK Server and published on GitHub.

    Loading

  • Can’t install/uninstall/repair Synology Virtual Machine Manager – Upgrade DSM not possible

    I was unable to upgrade my DSM from 6.1.7 to 6.2.1 because it was pretending to be member of a Virtual Machine Manager cluster. Which was not correct as Virtual Machine Manager was not installed ‘anymore’.

    Click to Read More

    I used to test the beta version of Virtual Machine Manager a long time ago. But since a while, Virtual Machine Manager is not installed anymore on my Synology and it was clearly visible neither in the DSM menu nor in the Package Center.

    Unfortunately, for some unknown reasons, my DSM thought that it was still part of Virtual Machine Manager cluster. As a consequence I was getting the following warning when upgrading my DSM: “This device is part of a Virtual Machine Manager cluster. Other hosts in the Virtual Machine Manager cluster will also need to be updated“.

    Trying to upgrade was always failing (without breaking my DSM, fortunately).

    I initially thought it could possibly be due to the network Bond I did create. So I tried to remove it via Control Panel > Network. But it failed with the message : “Creating or deleting this bond is prohibited because the operating interfaces includes the cluster interface of Virtualization. Please shutdown these quests and try again: {0}. Creating or deleting the bond is prohibited because of abnormal status of Virtualization cluster, please go to Virtual Machine Manager see the details.”

    Based on this message, and since it was not installed anymore, I tried to reinstall the Virtual Machine Manager. Unfortunately, the installation was failing and the package was stuck in a “repair” status.

    Being unable to ‘repair’ it by clicking on the “Repair” button, I tried to uninstall it. This was also failing, with the following message: “You cannot remove this package because this Synology NAS is a part of a Virtual Machine Manager Cluster. Please remove the host from the cluster to proceed.”

    Argh !!!

    Bref… I tried to ‘erase’ the package using my own Package Manager (See my SSPK server). It’s doing something similar to the trick explained here to delete all files related to the ‘Virtualization’ package.

    Once the package fully erased, I did reinstall it again but still without any success… And again it was stuck in a “repair” status and I was unable to uninstall it properly.

     

    As I couldn’t find any config file where I could see that my NAS was a member of a Virtual Machine Manager cluster, I tried to fix myself the installation of the package. I couldn’t really fix it (I couldn’t see which step of which installation or upgrade script was failing). But I have been able to force the installation to complete by deleting the file ‘/var/packages/Virtualization/installing’.

    Next, the package Virtual Machine Manager appeared in status ‘Installed’ but ‘stopped’. I was however able to “Start” it without any problem !! I could see in this Manager that my NAS indeed used to be configured as a member of cluster.

    And, miracle (even without deleting the cluster), running now the upgrade of my DSM finally succeeded !!!

    After the upgrade, I did remove my NAS from the cluster.

    Et voilà.

    [PS] I did use the Virtual Machine Manager a long time ago to test how Windows was running in a VM. It was a bit too slow for me so I did remove the Virtual Machine Manager. Probably that the cluster was not deleted at that time. Hence all the problems here above.

    [Edit] Once the DSM upgraded, I did delete the Virtual Machine Manager cluster. But as a consequence, I did lost all connections onto the NAS (ftp, web, plex, ssh, …). I was only able to see the NAS using the Synology Assistant. TO solve the problem I did shutdown the NAS by pressing the power button for a long period. After the reboot, everything as working fine. No, starting the Virtual Machine Manager, it starts a wizard to create a new cluster.

    Loading

  • Search for file on Linux using grep and find

    Search for files containing a certain text, on my Synology, ignoring warnings like ‘ Permission denied’

    Click to Read More

    Just a note for myself… as I always forgot the syntax :/

    Using grep only

    grep -rnlw ‘/path/to/somewhere/’ -e ‘pattern’ 2>/dev/null

    grep -rnlw ‘text’ ‘/path/to/somewhere/’ 2>/dev/null

    • -r or -R is recursive,
    • -n is line number, and
    • -w stands for match the whole word.
    • -l (lower-case L) can be added to just give the file name of matching files.

    Using find

    find ‘/path/to/somewhere/’ -type f -exec grep “text” ‘{}’ \; -print

    Loading

  • Find and kill all tasks running for a service/package on a Synology

    I wanted to kill all tasks running on my Synology for a package before uninstalling this one. Here is the how-to:

    Click to Read More

    The tasks running for a service are all listed in /sys/fs/cgroup/cpuacct/[the service]/tasks

    The service can be pgsql, nginx, nmbd, ftpd, sshd, … or synotifyd, synologd, synobackupd, … or a package like pkgctl-CloudSync, pkgctl-AudioStation, pkgctl-SurveilanceStation, …

    Ex.:

    • To see all tasks running for Synology’s StorageAnalyzer, type something like: cat /sys/fs/cgroup/cpuacct/pkgctl-StorageAnalyzer/tasks
    • To kill all those tasks, type something like: for task in $(cat /sys/fs/cgroup/cpuacct/pkgctl-StorageAnalyzer/tasks); do kill $task; done

    Loading

  • License and installation wizard not shown when installing Synology Package

    I noticed this morning that my Synology is not showing the License and the Installation Wizard anymore when installing my own Packages (Packages made with my app MODS and hosted on my own SSPK Server).

    Click to Read More

    I am not yet able to understand why the Installation Wizards and the Licence file of my own packages are not shown anymore, when installing them from my SSPK server via “Package Center” > “Community”. But everything works fine when installing them “Manually” via “Package Center” > “Manual Install” (and browsing to pick the spk into the folder of my SSPK server).

    The Upgrade Wizards and even the “Confirm settings” screen are also not displayed… While the Uninstallation Wizard works fine in all cases ?!

    My DS1815+ is running DSM 6.1.7-15284.

    I have compared all the logs created in /var/log/ during the installation and noticed a few differences. First, when installing a package from my SSPK server, there are ‘messages’ being logged:

    2018-11-03T22:26:05+01:00 … synoscgi_SYNO.Core.Package.Installation_1_install[21663]: resource_api.cpp:163 Acquire service-cfg for [the package I am installing] when 0x0001 (done)

    This is logged each time I am installing a package from my SSPK Server but not when install the same package manually.

    Next to those messages, the following INFO are also logged in synofeasibilitycheck.log:

    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:87 FeasibilityCheck: [Info] Start feasibility check [package_install] with type [hard].
    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:106 FeasibilityCheck: [Info] [0] of feasibility check [package_install] failed.
    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:79 FeasibilityCheck: [Info] No [package_install] feasibility check config with type [soft].

     

    Loading