Home button Search button Dr. Hain buttonClinic website Information for Dizzy Patients Fun Various and Sundry

Dr. Hain's various/sundry pages have helpful information about things that Dr. Hain has discovered by trial and error.

Synology NAS workarounds if you want to use it as a Linux server (don't do this unless you are just playing games).

Actually, this is a really really bad idea.

You should not be using your Synology box as a linux server, unless you are just playing games with it. Still, perhaps you are just playing games with it.

If you really want to play games with a linux server, it is far more rational to repurpose an old PC. At least it won't have it's operating system updated every month.

Another way to play games in a more safe manner is to set up a virtual machine linux. There are several big advantages here over using your Synology operating system as a playground. The main one is that it won't change with every update. You are in control of your virtual image -- not Synology.

Well anyway, one can mess around with the Synology linux system -- here is what I learned.

How to change the path for the root/admin user. (this is a bad idea however).

In order to run programs, your box needs to be able to find them. This is a little tricky, and is usually done with the PATH environment variable. Usually paths are set up in ".profile" files, which are run at login. Synology has many of these, and of course, no documentation concerning what is run when, or for that matter, any guarantee that things will still work after the next "update". The shell that synology uses is "ash".

For the current Synology DSM4 configuration, it appears that the root .profile is run after the admin profile. This causes it to overwrite whatever modifications have been made to the PATH by profiles that are earlier in the chain.

Edit the root .profile file. Comment out the PATH=, and EXPORT PATH lines (put a # in front of them). This gets rid of the overwriting.

You can also set up an "ENV" variable and run a local shell script.

How to back up your mysql database every day

Of course, one should not keep anything important in a database without backing it up. File servers have lots of space for this. Before starting however, we do NOT think it is a good idea to run a mysql server on a Synology box. Use a regular Debian box, where you can find linux configuration files where they belong.

Well anyway, I didn't figure this out for a while -- and perhaps someone will find this mistaken use of my time useful. This script was modified from http://www.backuphowto.info/how-backup-mysql-database-automatically-linux-users. The original script had a typo ("data" instead of "date")as well as it was not "tuned" for the synology linux. Still, it was mostly right.

First, test out the command line from below starting with mysqldump ...., make sure to substitute your own root password. Look to see if the file appears in your target directory (the directory has to exist, and perhaps your directory is different than mine).

second, edit /etc/crontab (suggest making a copy of it first).

15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /volume1/Backup/mysql/database_`date '+%m-%d-%Y'`.sql.gz

This causes cron to run the mysqldump script at 2:15 every night.

Thirdly and finally, restart the cron service:

/usr/syno/etc/rc.d/S04crond.sh start

This came from http://forum.synology.com/wiki/index.php/Basic_commands_to_get_around_the_Synology_Box_using_the_CLI#cron

We think it is also wise to use the timebackup program to copy the backup directory to another Synology box, so that there are always two copies.

Cron seems to stop running from time to time, as the backups sometimes stop. This behavior may be due to Synology updating itself, and overwriting the /etc/crontab file. There is no way to prevent this from happening, so vigilance is needed.

To restore your mysql backup

The steps here are to gunzip the dump, and then load it into mysql. Mysql must also be able to run from the command line (see later section).

The shell file that I created to do this is rather simple: I put my dump file into the "public" drive, so change your shell file if it is somewhere else. Of course, edit the password.

gunzip < /volume1/public/database_YOURDATE.sql.gz > dump.sql
mysql -u root -pabcdefg < dump.sql

To get programs to run on the command line (i.e. mysql).

Again, this is a really bad idea. You should not be using your synology box as a linux server, unless you are just playing games with it. If you want to play games, you should buy a raspberry PI or arduino or something like that. Or set up a virtual machine. Well anyway --

To do this you have to edit your synology path. If this is generally useful, then I suggest editing the /etc/profile file.

To edit this file, you must be logged in as root.

cd /etc; vi profile

Change the PATH line to add the last entry

Save it, log out, log back in, and then the PATH should contain mysql.

To mount files on your Synology NAS to Linux, working from windows

This is very difficult -- both ends - -Synology NAS syntax and Linux syntaxes for mounting volumes are both very cryptic. You will probably have to do some trial/error -- do not expect this to work "out of the box" so to speak. Pun intended there.

General information about Linux and setting up mount points:

nfs, or network file system, is the main linux file system. Synology, being a linux box itself, one would think should be very easy to mount to another linux box. Synology supports nfs mounts for some servers, but not others. In particular, the new 415+ encrypted server does not allow nfs mounts. This means you need to use some other type of file system. cifs is one. If you want to figure out what is going on -- it's not easy (which is why I wrote this). You can look at the "man" pages, but I found it useless. Linux documentation is very tough going -- it is generally written for system guru's, and contains far more info than you want to know, but without any working examples. The most useful sources are the synology site itself (unfortunately, it really doesn't work, but it gets close), and some user examples, such as this one:

The two (free) windows utility programs that you need for this are winscp and putty. Winscp gives you a windows like interface to your linux system. Putty gives you a command line interface to your linux system. You will need both. These are easy to download.

1. Prepare first by creating a mount point (/mnt/test is used in the examples below). This is most easily done by logging in as root from putty, and then mkdir /mnt/test.

2. For cifs, you may need to run (from the command line): sudo apt-get install cifs-utils (see here for more info). I am not sure if this is necessary, but it worked for me.

3. Create a /etc/cifspwd file as instructed on the Synology website as well as other places. This is a security measure -- by holding your login credentials in a protected file, you don't have to put them in broad view in your /etc/fstab

4. Next, you edit /etc/fstab (pick one of these two file systems) -- use nfs if you can get it to work.

  1. Linux (Debian) nfs solution: Mount the NAS directory to your server using fstab. This is somewhat erratic -- it will work for one Synology server, but fail on another for mysterious reasons.
    1. An example of line in fstab that works for some synology NAS servers: /var/www/xyz nfs rw,nosuid,noexec 0 0
    2. Some Synology servers will not work with the "volume1" part of the name (see below). This is a trial/error situation.
  2. Linux (Debian) cifs solution. Mount the NFA directory using cifs. (with 123 and xyz substituted for the real stuff).
    1. An example of line in fstab that works for the 415+ synology NAS servers: // /mnt/test cifs user,uid=root,gid=users,rw,suid,credentials=/etc/cifspwd 0 0
    2. Note that the name that Synology uses a for the SAME DIRECTORY is /volume1/xyz (not /xyz). This means that you have to translate between "synology-ese" and "linux-ese".
    3. Note that the style of the address for linux is DIFFERENT betwen nfs and cifs (sigh). This obviously means that you can't just mix/match mount lines in fstab for nfs and cifs.

5. Once fstab is modified, run mount-a. Hopefully this will just return nothing (meaning it worked). Other possibilities mean you have to go back and try every possible permutation over and over again until you luck onto the right one.

  1. It hangs. Type control-D at the console. sometimes it helps to run dmesg | tail (this gives you the last 10 lines or so of the error log).
  2. It says something is wrong.




© Copyright April 18, 2019 , Timothy C. Hain, M.D. All rights reserved.
Dr Hain's CV Clinic dizziness-and-hearing.com FLW Rant-Rave