Synology DSM (terminal) service control

DSM 6

Webuserinterface, Synology recommended:

Control Panel, Task Scheduler, Create Scheduled Task, Stop/Start Service

Terminal command:

ssh <admin account>@server

sudo -i

synoservicecfg --list

synoservicecfg --hard-stop <service>

synoservicecfg -stop <service>

synoservicecfg --hard-start <service>

synoservicecfg -start <service>

synoservice –status

synoservice –restart <service>

synoservicectl –restart <service>

Apache webserver:

stop pkg-apache22

start pkg-apache22

reload pkg-apache22


restart DSM Webapplication:

restart synoscgi


DSM 7

Terminal command:

ssh <admin account>@server

sudo -i

To list installed packages, try: synopkg list --name and hit Enter.
To stop a package, try: synopkg stop <package name> and hit Enter (EG synopkg stop USBCopy).
To start a package, try: synopkg start <package name> and hit Enter.
To restart a package (stops a package, then starts it), try: synopkg restart <package name> and hit Enter.

 

Restart HybridShare

synopkg restart HybridShare

 

 

 

 

 

Synology Terminal Commands

Synology Terminal Commands

Synology Terminal Commando laat meerdere commando's zien die uitgevoerd kunnen worden na het maken van een ssh verbinding met de Synology NAS. Ssh moet wel eerst ingeschakeld worden op de Synology NAS om verbinding te kunnen maken.

Synology Terminal Commando

 

 

 

 

 

 

 

start terminal via ssh

ssh user@host

sudo -i

Geef nogmaals het wachtwoord op, hierna kunnen commando's uitgevoerd worden.

Check Network traffic and Bandwidth on Synology NAS.

synogear install

iftop

Synology Terminal commando check open port en programma:

netstat -natpu

-a, --all                display all sockets (default: connected)

-n, --numeric        don't resolve names

-p, --programs      display PID/Program name for sockets

-t                         display only TCP connections

-u.                       display only UDP connections

Synology check network performance

ifconfig

ethtool -S eth0

ethtool -g eth0

netstat -s -p TCP

Synology display activity like pid, processor, memory and

htop

Synology geheugengebruik

free -h

Check Space Usage

cd /volume1

du -h -d1

 

Synology reset Two-Factor Authentication

Synology reset 2FA with SSH enabled

Synology reset 2FA explains how to reset 2FA when SSH is still enabled. The commando’s are run via a terminal session and SSH has to be enabled on the Synology NAS server. In case there is only one administrator on the NAS to reset 2FA and this user has exceeded all standard 5 emergency codes then it is still possible to reset 2FA when SSH is turned on.

Synology terminal session

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

cd /usr/syno/etc/preference/

choose the user which 2FA you want to reset.

cd <user>

rm google_authenticator

 

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal explains the steps to synchronise two shared folders via the rsync protocol. The rsync commando's are executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Turn on rsync on the Synology NAS-servers

To turn on rsync on the Synology NAS open control panel, file services, enable rsync service. Both Synology NAS-servers should have the rsync service running otherwise the Synology rsync synchronisation terminal commands don't run.

Identify both folders for Synology rsync synchronisation

Choose which folder on the source Synology NAS you want to synchronise to the other Synology NAS server which will be the destination. When the folder on the destination doesn't exits it will be created but not seen in the control panel as a shared folder. You can make it a shared folder afterwards and the synchronised data will not be overwritten. It is also possible to create first the shared folder on the destination NAS before the synchronisation. The advantage here is that the folder is created with the correct settings like permissions.

Hyper Backup and the difference with Synology rsync synchronisation terminal commands

With Hyper Backup you can create a rsync copy (single-version). The disadvantage from this way is that a subfolders are created under the destination shared folder and not directly inside the shared destination folder. The rsync job will create a backup folder and is not suitable for this purpose.

Shared Folder Sync and the difference with Synology rsync synchronisation terminal commands

When you have already on the destination, shared folders with identical names as the source shared folders, the folders at destination will be renamed! When the folders don't exists on the destination the will be created. When you already have a shared folder on the destination and the data is quit large, deleting the folder will take more time than to synchronise only the differences. After the creating of the shared folder at the destination you cannot access the files without changing the permissions. Also changing the files/folders at the destination after changing the permissions will not result in synchronising the source folders to the destination, running a full synchronisation does the job.

Synology rsync synchronisation terminal commands

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server01 or server02:

Terminal command:

ssh <admin user>@<servername>

sudo -i

command is run from server01 or server02:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Delete files/folders within the destination shared folder to make sure that the destination shared folder is the same as the source shared folder.

Running the Synology rsync synchronisation terminal command

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

from server 02:

rsync -avhz --delete <admin user>@server01:"'/volume1/test test/'" "/volume1/test test/"

from server 01:

rsync -avhz --delete "/volume1/test test/" <admin user>@server02:"'/volume1/test test/'"

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

-v, --verbose               increase verbosity

-h human readable

-z, --compress              compress file data during the transfer

-r, --recursive             recurse into directories

-l, --links                 copy symlinks as symlinks

-p, --perms                 preserve permissions

-t, --times                 preserve modification times

-o, --owner                 preserve owner (super-user only)

-g, --group                 preserve group

     --devices               preserve device files (super-user only)

     --specials              preserve special files

-D                          same as --devices --specials

--delete delete files in the destination.

Synology scp commands

Synology scp command

Synology scp command via the terminal explains the steps to secure copy a folder to another NAS folder via the scp command. The scp command is executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology scp command

Synology scp command terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Identify both folders:

Choose which folder on the source Synology NAS you want to copy to the other Synology NAS server which will be the destination. If the destination folder doesn't exists you can create it before the copy.

Synology scp command

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following scp command at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server02:

Terminal command:

ssh <admin user>@server01

sudo -i

command is run from server01:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Secure copy files/folders within the source shared folder to the destination folder. Also copy hidden files.

Running the Synology scp command

Run the following scp command at your own risk and first test before usage!!!!

cd /volume1

pwd

scp -rp  test\ test/.  <admin user>@server02:"'/volume1/test test/'"

-r      Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal

-p     Preserves modification times, access times, and modes from the original file.

.       Will copy also hidden files.

Synology Terminal Mount Volume & Folder

Synology Terminal Mount Volume & Folder

Synology Terminal Mount Volume & Folder shows commands you can execute via the terminal to mount volumes or encrypted shared folders. Always contact Synology support first for help and follow their directions and make sure you have a working backup. If you like to try it is on your own risk!

 

Synology Terminal Mount

 

Always contact Synology support first for help and make a working backup first. Use this steps on your own risk!

Synology Terminal Mount after a crashed volume:

after a crashed volume which is not recoverable from the GUI you can try to mount the volume as read-only in a terminal.

Make terminal ssh connection to Synology NAS.

cat /etc/fstab

fdisk -l

cat /proc/mdstat

mdadm --detail /dev/<mdX, check cat /proc/mdstat>

check md not listed. For example md9

use at own risk:

mdadm -A -R /dev/<md not listed> /dev/<disk not crashed> /dev/<disk not crashed>

-A, --assemble Assemble a pre-existing array

-R, --run Attempt to start the array even if fewer drives were given than are needed for a full array. Normally if not all drives are found and --scan is not used, then the array will be assembled but not started. With --run an attempt will be made to start it
anyway.

command should return the message "mdadm: /dev/<md not listed>  has been started with x drives."

lvm vgscan : take note of volume group name

vgchange -a y <volume group name, for example:vg1000>

-a, --activate

The command to mount the volume as read-only in order:

mount -o ro,noload /dev/<volume group name>/lv /volume1

volume group must exists on your system.

the volume should be reachable in the terminal session.

To see the data in DSM using File Station or Windows File Service (SMB)

synospace --map-file -d

synocheckshare

Synology Terminal Mount encrypted map:

Always contact Synology support first for help and make a working backup first. Use this steps on your own risk!

You need the password to decrypt the shared folder.

If you don't have the password but you have the key file, you can run the following command to retrieve the password, I used a Ubuntu Linux system with ecryptfs-utils installed.

printf "%s" "\$1\$5YN01o9y" | ecryptfs-unwrap-passphrase <keyfile.key>

Make terminal ssh connection to Synology NAS.

cd /volume<>

ls -al

check your folders, for example  an encrypted folder named encrypt

@encrypt@ and encrypt

If only @encrypt@ exits and not encrypt this could mean the @encrypt@ folder is not mounted on mount point encrypt.

check with ls command the ls

ls -al @encrypt@ and ls-al encrypt

mount

and check it encrypted folder is mounted ( for example):

when it is mounted it will show:

/volume1/@encrypt@ on /volume1/encrypt type ecryptfs (rw,relatime,ecryptfs_fnek_sig=<>,ecryptfs_sig=<>,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs)

when encrypt is not mounted it will not show this line after the mount command.

to mount the @encrypt@ folder on mount point encrypt.

first check if encrypt folder exists.

if not exits run mkdir encrypt ( this directory wil be deleted after encrypting the folder from the GUI, the folder cannot be removed with the rm command)

to mount:

mount.ecryptfs \@encrypt\@/ encrypt/

Passphrase: <fill in the password used to encrypt the folder, without the password you cannot see your data>

Select cipher:

1) aes: blocksize = 16; min keysize = 16; max keysize = 32

2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56

3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24

4) twofish: blocksize = 16; min keysize = 16; max keysize = 32

5) cast6: blocksize = 16; min keysize = 16; max keysize = 32

6) cast5: blocksize = 8; min keysize = 5; max keysize = 16

Selection [aes]: select 1 aes

Select key bytes:

1) 16

2) 32

3) 24

Selection [16]: 2 (32)

Enable plaintext passthrough (y/n) [n]: n

Enable filename encryption (y/n) [n]: y

WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt],

it looks like you have never mounted with this key

before. This could mean that you have typed your

passphrase wrong.

Would you like to proceed with the mount (yes/no)? : yes

Would you like to append sig [] to

[/root/.ecryptfs/sig-cache.txt]

in order to avoid this warning in the future (yes/no)? : yes

Successfully appended new sig to user sig cache file

Mounted eCryptfs

run command, mount and check

/volume1/@encrypt@ on /volume1/encrypt type ecryptfs (rw,relatime,ecryptfs_fnek_sig=<>,ecryptfs_sig=<>,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs)

cd  /volume1/encrypt

ls -al to check your data

you could use scp to copy your data to another device

To see the data in DSM using File Station or Windows File Service (SMB)

synospace --map-file -d

synocheckshare

 

Synology Parity Consistency Check

Synology Parity Consistency Check

Synology Parity Consistency Check to control and check with terminal commands the process

Synology parity consistency check terminal commands. How to see the status of the check and control it for example to let it run faster. Also to see where logging takes places.

Running this commands are at your own risk!  

Synology Parity Consistency Check

start ssh session with Synology NAS.

as root:

To check the status of the running parity consistency check:

cat /proc/mdstat

You can also see the speed.  speed=

Showing the running speed:

cd /sys/block/md<X>/md

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

cat sync_speed will show the running speed

To control speed:

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

cat sync_speed_min

cat sync_speed_max

By changing this values you can control the speed.

echo <value> >sync_speed_max

The standard value sync_speed_max is high so there is no limit.  By lowering this value you can max the speed and slow down the process.

The standard value sync_speed_min is set low By making this value higher you can try to speed up the process. Just check the current speed and try to make this setting higher and check what happens.

Start/Stop and Pause the parity check

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

Start:

echo check > /sys/block/mdX/md/sync_action

Pause:

There is no actual pause, since you will still fall back a little bit or resume from the beginning if you reboot the unit. But below is the closest one.

#echo idle > /sys/block/mdX/md/sync_action

Stop:

#echo frozen > /sys/block/mdX/md/sync_action

You will need to replace mdX with your volume. For example, md2, md3... ( md0, md1 are system partitions. )

Where logging takes place? 

/var/log/kern.log

To change debug setting:

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

echo 1 > sync_debug

tail -f /var/log/kern.log will show the last messages

Messages like this to watch for:

md: data-check of RAID array md2

md: md2: data-check stop due to MD_RECOVERY_INTR set.

md: md_do_sync() got signal ... exiting

Do you want Diktio Solutions to help you. Click Here to contact Diktio Solutions.

Synology File System Check

Synology File System Check

How to run a Synology File System Check on a ext4 file system?

Synology File System Check

DSM used:  DSM 6.2

When checking the log files on a ext4 file system under /var/log I discovered the log file fsck. It appears that every time the system is started the following command is run for Synology File System Check:  /sbin/e2fsck -pvf. From the GUI on my Synology NAS it is not possible to start a Synology File System Check on a ext4 file system.

-p Automatic repair (no questions)

-n Open the filesystem read-only, and assume an answer of 'no' to all questions. Allows e2fsck to be used non-interactively. This option may not be specified at the same time as the -p or -y options.

-v Be verbose

-f Force checking even if filesystem is marked clean

How to run the Synology File System Check on a ext4 manually?

Running this commands are at your own risk. Always make sure you have a good backup as there are risks off data loss.

turn on telnet and don't forget to turn it off again. It is a security issue, passwords go unencrypted over the line. In control panel under Terminal & SNMP you can turn telnet on. You need a telnet program on your computer to connect to the Synology NAS. Don't use SSH because when running the below commands you will loose connection.

df -h and search for volume needed. For example volume1: /dev/vg1000/lv

syno_poweroff_task -d or umount /volume1, if this doesn't work try umount /volume1 -f -k (-k is for killing processes accessing the file)

(syno_poweroff_task) -d debug mode. This command is for killing all processes.

vgchange -ay

-a (--available) for activate or deactivate -y|--yes ]

commands to check the file system:

e2fsck -nvf -C 0 /dev/vg1000/lv (-n option see above)

fsck.ext4 -pvf -C 0 /dev/vg1000/lv or e2fsck -pvf -C 0 /dev/vg1000/lv (-p option see above)

-C 0

-C fdThis option causes e2fsck to write completion information to the specified file descriptor so that the progress of the filesystem check can be monitored. This option is typically used by programs which are running e2fsck. If the file descriptor number is negative, then absolute value of the file descriptor will be used, and the progress information will be suppressed initially. It can later be enabled by sending the e2fsck process a SIGUSR1 signal. If the file descriptor specified is 0, e2fsck will print a completion bar as it goes about its business. This requires that e2fsck is running on a video console or terminal.

After completion run:  reboot

Do you want Diktio Solutions to help you. Click Here to contact Diktio Solutions.

Synology SMB connection with shared folder

Synology SMB Connections

Synology NAS DSM 6.1 with Active Directory (AD) installed on the NAS. Users in AD and Synology NAS users. On the NAS is SMB v1 disabled 

Connect from Ubuntu 16.04 LTS (Latest Stable Version) Gnome desktop 

from the terminal: 

as root:

sudo su -

mount -t cifs //<ip address or DNS name Synology NAS>/<Share> /mnt (or other mount point) -o username=<AD user or NAS user>,vers=<2.1 or 3.0> 

To start within Gnome GUI from terminal:

as root:

nautilus 

or as user: 

sudo mount -t cifs //<ip address or DNS name Synology NAS>/<Share> /mnt (or other mount point) -o username=<AD user or NAS user>,vers=<2.1 or 3.0> 

To start within Gnome GUI from terminal:

sudo nautilus

Connect from Centos 7

from the terminal: 

as root:

sudo su - or su - 

mount -t cifs //<ip address or DNS name Synology NAS>/share -o,user=<AD user or NAS user,domain=<AD netbios domain or other name for NAS users>,vers=<2.1 or 3.0> /mnt (or other mount point)

To start within Gnome GUI from terminal:

as root:

nautilus 

or as user: 

sudo mount -t cifs //<ip address or DNS name Synology NAS>/share -o,user=<AD user or NAS user,domain=<AD netbios domain or other name for NAS users>,vers=<2.1 or 3.0> /mnt (or other mount point)

To start within Gnome GUI from terminal:

sudo nautilus

Synology terminal show S.M.A.R.T report

smartctl --scan

smartctl -a -d sat -T permissive /dev/sda

/dev/sda is the drive

-aPrints all SMART information about the disk.

-d satSpecifies device type. “Sat” is SCSI to ATA Translation (SAT) that is required with Synology.

 -T permissiveDefines tolerance type. “Permissive” tells to ignore failure(s) of mandatory SMART commands and is required with Synology.
 
The commando also shows Hardware disk information:
 
Model Family:     

Device Model:     

Serial Number:   

LU WWN Device Id:

Firmware Version: 80.00A80

User Capacity:    

Sector Sizes:     

Device is:       

ATA Version is:   

SATA Version is:  

Local Time is:    

SMART support is: 

SMART support is: 

 

To run a short S.M.A.R.T test: 

smartctl -d sat -t short /dev/sda

1 2