Synology Terminal Commando

Synology Terminal Commando

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 Twee-factor Authenticatie

Synology reset 2FA met SSH ingeschakeld

Synology reset 2FA legt uit hoe 2FA te resetten als SSH nog steeds ingeschakeld is. De commando’s worden uitgevoerd via een terminal sessie en SSH moet ingeschakeld zijn op de Synology NAS. In het geval dat er 1 administrator op de NAS is en 2FA moet gereset worden omdat alle 5 emergency codes verbruikt zijn is het nog mogelijk 2FA te resetten als SSH ingeschakeld is.

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.

Zorg dat SSH is ingeschakeld op de Synology NAS. Dit kan in control panel onder Terminal & SNMP. Voor Windows kan je gebruik maken van PuTTY om een SSH verbinding te maken.

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 synchronisatie terminal

Synology rsync synchronisatie 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 command

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 & Map

Synology Terminal Mount Volume & Map

Synology Terminal Mount Volume & Map 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 Controle

Synology Parity Consistency Controle

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

Synology parity consistency controle 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 Controle

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 SMB Mount Linux besturingssyteem

Synology SMB Mount op Linux besturingssysteem

In deze Synology post leg ik uit hoe een Synology SMB Mount commando via een terminal uitgevoerd  moet worden om op een Linux besturingssysteem een SMB verbinding te maken met een Synology gedeelde map. Op de Synology NAS is SMB v1 uitgeschakeld vanwege de onveiligheid van deze versie van SMB. Ik heb hieronder de situatie beschreven van de Synology NAS en de gebruikte Linux systemen. Als niet wordt ingelogd als root gebruiker dient het sudo commando gebruikt te worden om het Mount commando uit te voeren voor de SMB verbinding met de Synology NAS.  

Situatie:

Synology NAS versie: DSM 6.1.x

Geïnstalleerde Packages:  Active Directory (AD)

Gebruikers zijn gedefineerd in Active Directory en lokaal op de Synology NAS.

Op de Synology NAS is SMB ingeschakeld. SMB v1 is uitgeschakeld.

Linux operatingssystems: Ubuntu 16.04 en Centos 7

Ubuntu 16.04 LTS:

Hoe maak ik via de terminal een SMB verbinding met de Synology NAS met het Mount commando?

In een terminal sessie als gebruiker root.

Verander eerst naar root gebruiker. 

sudo su - 

Geef het volgende Mount commando om een SMB verbinding te maken met de Synology gedeelde map.

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>

Om Nautilus op te starten vanuit Gnome GUI voer het volgende commando uit als root.

nautilus

In een terminal sessie als normale gebruiker:

geef het volgende Mount commando om een SMB verbinding te maken met de Synology gedeelde map.

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>

Om Nautilus op te starten vanuit Gnome GUI voer het volgende commando uit als normale gebruiker in een terminal sessie:

sudo nautilus

Connect from Centos 7

In een terminal sessie als gebruiker root:

Verander eerst naar root gebruiker.

sudo su - of su -

geef het volgende Mount commando om een SMB verbinding te maken met de Synology gedeelde map:

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)

Om Nautilus op te starten vanuit Gnome GUI voer het volgende commando uit als root.

nautilus

In een terminal sessie als normale gebruiker:

geef het volgende Mount commando om een SMB verbinding te maken met de Synology gedeelde map:

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)

Om Nautilus op te starten vanuit Gnome GUI voer het volgende commando uit als normale gebruiker.

sudo nautilus

Synology terminal S.M.A.R.T rapportage

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

Monitor de Apache Webserver op je Synology DSM

DSM 5:

Login as root via a terminal session on your Synology NAS.

vi /etc/httpd/conf/httpd.conf-user

add the following lines and fill allow from:

--

#Apache server status
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from <fill in the ip address of your server running your Anturis agent>
</Location>

#Apache server status
#To obtain a full report with current status information
ExtendedStatus On

--

Restart httpd-user daemon:

synoservicectl --restart httpd-user

Within Anturis fill in the monitoring settings:

Apache server connection:

Apache statistics web-page URL (requires mod_status): <servername/server-status>

You can now monitor your Apache webserver running on your Synology NAS.

DSM 6:

Login as admin via a terminal session on your Synology NAS.

sudo -i

create file for example status.conf under /usr/local/etc/httpd/sites-enabled/

--

#Apache server status
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from <fill in the ip address of your server running your Anturis agent>
</Location>

#Apache server status
#To obtain a full report with current status information
ExtendedStatus On

--

Reload Apache server:

reload pkg-apache22

1 2