synology

so this houses a collection of how-to guides for synology. there are some obsolete instructions but i still kept this in, well, just in case it might be needed again. these obsolete ones will be flagged as obsolete, for your notice. eventually, i’ll find the time to have these archived.

jump straight to…

ssh commands required
majority of the ssh commands requires nano or vim. my choice of a terminal editor would be nano. to find out more how to use nano, visit the following page to get the basics.

look out for notes
notes are placed in the guides, these markers requires your attention.

report inaccuracies and errors
if something in this guide is inaccurate, wrong, or outdated, report it by scanning the qr code.


👨🏻‍💻 [cronjob]

cronjob for cacti poller needs to be added in every time a reboot is performed. (provided you still have cacti installed)

  1. login to your terminal shell and key in the following:

     vi /etc/crontab
  2. in the crontab screen, enter the following:

     */5 * * * * nobody /usr/bin/php /volume1/web/cacti/poller.php > /dev/null 2>&1
  3. Save the crontab

  4. Run the command:

     /usr/syno/sbin/synoservicectl --restart|stop|start crond.   

🗣 note: each space for the crontab entry (/5 * …) has to be spaced via TAB on your keyboard.*


👨🏻‍💻 [startssl]

useful if you are hosting websites on your synology box, however, word of warning: revocation of cert carries a USD24.95 fee.

  1. for existing certs, renewal to be sent to your registered startssl, 2 weeks before expiration.

  2. for new implementation, refer below.

[mikebeach.org] (http://mikebeach.org/2012/11/13/startssl-ssl-certificate-on-synology-nas-using-subdomain/)


👨🏻‍💻 [watchtower for docker synology]

watchtower is used to assist with keeping your docker containers updated. i’m currently using that to assist with this.

  1. firstly, ssh into your Synology and add the symlink:

     ln -s /var/run/docker.sock /volume1/docker/docker.sock
  2. next, logon to your synology box and create a scheduled task

  3. go to control panel” > task scheduler”

  4. click create” > scheduled task” > user-defined script”

  5. on the create task: window, make sure user:” is selected as root” and rename the task:” to whatever you like.

  6. click schedule” tab. under date - run on the following days”, select daily”. under time - frequency”, select every 1 hour(s)” (just to be on the safe side).

  7. click task Settings” tab. under run command - user-defined script”, paste sudo ln -s /var/run/docker.sock /volume1/docker/docker.sock into the text box and press ok”

  8. the newly created task will be listed there. click to highlight it and then click run” to run it once, immediately.

  9. head back to your ssh and execute the following:

     sudo docker run -d --name watchtower -v /volume1/docker/docker.sock:/var/run/docker.sock centurylink/watchtower --interval 82800 --cleanup
  10. exit your terminal window and you’re done.


👨🏻‍💻 [istats for synology]

istats can be installed on your synology box and monitor through your apple devices

  1. ssh into your synology box.

  2. access debian chroot via the following syntax

     /var/packages/debian-chroot/scripts/start-stop-status chroot
  3. create a istats directory which will be temporary only

     mkdir /opt/istat
  4. install all the required depedencies

     apt-get install g++
     apt-get install autoconf
     apt-get install libxml2-dev
     apt-get install libssl-dev
     apt-get install libsqlite3-dev
     apt-get install libsensors4-dev
     apt-get install libavahi-common-dev
     apt-get install libavahi-client-dev
  5. next change directory to istats:

     cd /opt/istats
  6. and grab the istatserver file:

     wget https://s3.amazonaws.com/bjango/files/istatserverlinux/istatserver-x.xx.tar.gz
  7. untar it:

     tar -zxvf istatserver-3.01.tar.gz
  8. next build it:

     ./autogen
     ./configure
     make
     make install
  9. run it:

     /usr/local/bin/istatserver -d
  10. you will need the 5-digit pin when you add your box into your iStat app. see the pin by accessing the following:

    nano /usr/local/etc/istatserver/istatserver.conf
  11. you’re done, exit the terminal screen and check on your apple devices


👨🏻‍💻 [crashplan]

on 22 aug 2017, Code42, has shutdown their home-based backup plans. if you decide to use this, they now only offer business plans, i am not sure of their pricing tier but the free shit is now gone. therefore, i am no longer using this.

this guide is to setup a headless client and requires that you have docker installed on your synology box.

  1. ssh into your synology box and login as root.

  2. install the crashplan container

     sudo docker pull jrcs/crashplan
  3. now run the container:

     sudo docker run -d --name Crashplan -p 4242:4242 -p 4243:4243 -v /volume1:/volume1 jrcs/crashplan:latest

🗣 note: If you have more volumes to backup simply add more -v as needed, like -v /volume2:/volume2 — etc.

  1. login to dsm and navigate to: docker > container > crashplan > details > terminal > create > bash

  2. type the following:

     cat /var/lib/crashplan/.ui_info
  3. copy the guid string

🗣 note: It is the one which is in bold: 4243,89d0deff-512s-433c-89sa-7482e3cjdu7a,0.0.0.0

  1. next, go to docker > container > crashplan and stop the container.

  2. click on edit then check enable auto restart then ok and start the crashplan container again.

  3. you are done with the setup for the synology box.

these next parts is to be done on your mac server

  1. now lets edit the .ui_info file located on mac server.

  2. ssh into your mac server and execute the following command:

    vim /Library/Application Support/CrashPlan/.ui_info
  3. ensure that with the copied guid from your synology box in step 6 above and replace the original guid in the .ui_info file on your mac server. the ip address should reflect your synology lan ip, sample as shown below

    4243,89d0deff-512s-433c-89sa-7482e3cjdu7a,192.168.1.100 
  4. save and exit

  5. now, the last step, edit the ui.properties file.

🗣 note: it is likely that your ui.properties file is named ui_macusername.properties, edit that file.

  1. enter the following information:

    serviceHost=192.168.1.100

  2. save and exit.

  3. launch the crashplan app and let it run.

⚠️ important: for every 1tb of data being backed up, your Synology box must have ram (memory) that correlates, e.g. 1tb = 1gb ram and so on. if your device does not have enough ram, i would suggest to not back up your plex library but your important documents instead. :)


👨🏻‍💻 [unable to update dsm - insufficient disk space]

if you ever get this issue, it is likely your /dev/md0 partition does not have enough space to have the update installed. i previously had this issue so i ended up removing all the log files in that partition and get it below 69%.

  1. ssh into your synology and gain root access.

  2. change to your root directory and then execute the following command:

     du -h /var/log
  3. this will then provide the directory of /var/log and the file sizes. so as you can see my log directory is indeed larger than the rest.

image

  1. what i did was to do a logrotate first.

     truncate -s 0 nameoflog.log
  2. you can see the progress here:

     logrotate -vf /etc/logrotate.conf 
  3. once you are done, check again and you will see that the disk space has dropped for /dev/md0.

     du -h /var/log 
     df -h
  4. if all else fails, you can also remove the log files:

     rm -rf *.log 
  5. good luck.