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 UPS NUT

Synology UPS NUT

Synology UPS NUT (network UPS Tools), connecting a Synology NAS to an UPS prevents dataloss or hardware failure in case of a power failure. It is also possible to turn off other network devices in case off a power failure. Synology has implemented NUT: http://networkupstools.org

 

Synology UPS NUT

Used configuration Synology UPS NUT:

Synology NAS connected via Dataport to APC Back-UPS ES 700.

Synology DSM 6.1 en 6.2

The configuration files on the Synology NAS  are found here:

/usr/syno/etc/ups, which you can access via a terminal

upsd.conf

upsd.users

ups.conf

After changing the file you can reload the configuration:

upsd -c reload

Setting via the GUI, control panel, Hardware & Power, UPS:

Under general you can configure:

restart automatically after a power failure

To get UPS status information from another device and user:

you have to be in the upsd.users file and be in the list of permitted disk station devices, (control panel, Hardware & Power, UPS)

run the following command to check UPS information and status from another device:

upsc <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

for example upsc ups@192.168.1.10

To change a value for example for testing:

upsrw -s battery.charge.low=<new value> -u <user, defined in upsd.conf NAS> -p <password user in upsd.conf> <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

To install a nut client on a Mac:

I used Fink Project;  http://www.finkproject.org to install Fink Project.

To install nut on your Mac:

fink install nut

The configuration files:

/sw/etc/nut

upsmon.conf:

RUN_AS_USER root

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -u -h +0"

NOTIFYCMD /sw/sbin/upssched

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

upssched.conf

CMDSCRIPT /sw/bin/upssched-cmd

PIPEFN /sw/var/run/ups/upssched/upssched.pipe

LOCKFN /sw/var/run/ups/upssched/upssched.lock

AT ONBATT <name ups, see synology ups.conf>@<ip address> EXECUTE on-battery

/sw/bin/upssched-cmd:

case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;

on-battery)
osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" giving up after 20 buttons {"OK"} default button 1 with icon caution'
;;

*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac

To start upsmon manually: 

sudo upsmon -D (/sw/sbin/upsmon)

-D       Raise the debugging level. upsmon will run in the foreground and

prints information on stdout about the monitoring process. Use this

multiple times for more details.

upsmon -c stop ( stop monitoring and exit)

upsmon -c reload ( reread upsmon.conf) 

To start upsmon automatically on a macOS Sierra :

/Library/LaunchDaemons

-rw-r--r--   1 root  wheel   org.networkupstools.upsmon.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.networkupstools.upsmon</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sw/sbin/upsmon</string>
<string>-D</string> <!-- "-D" keeps upsmon from going into the background -->
</array>
<key>KeepAlive</key>
<true/>
<key>SuccessfulExit</key>
<false/> <!-- Do not respawn at shutdown time -->
</dict>
</plist>

To load manually:

sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist

system.log:

com.apple.xpc.launchd[1] (org.networkupstools.upsmon): Unknown key for Boolean: SuccessfulExit
com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This service is defined to be constantly running and is inherently inefficient.

To see if it is running:

sudo launchctl list|fgrep -v com.app

PID     Status  Label

<PID> 0 org.networkupstools.upsmon

ps -ef |grep upsmon

0 88 1 0 9:52AM 0:00.01 /sw/sbin/upsmon -D
0 167 88 0 9:52AM  0:00.50 /sw/sbin/upsmon -D

To install a nut client on Linux CentOS 6.9 :

Download the binary package of Feodora EPEL6, nut-client

Install on Linux machine with rpm command:

for example: rpm -ivh nut-client-2.6.5-2.el6.x86_64.rpm

make a user nutmon and at to group nut:

adduser nutmon

passwd nutmon

usermod -a -G nut nutmon

groups nut

Config files:

/etc/ups/

check nut group read rights upsmon.conf

upsmon.conf:

RUN_AS_USER nutmon

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -h +0"

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

To run upsmon at startup:

chkconfig --list ups

chkconfig ups on

to check upsmon running:

service ups status

ps -ef |grep upsmon:

root          2271     1    0 Jul08 ?          00:00:00 /usr/sbin/upsmon

nutmon    2273  2271  0 Jul08 ?          00:00:09 /usr/sbin/upsmon

To start en stop upsmon:

service ups start

service ups stop

 

Need help. Klik hier 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

OpenVPN configuration Synology VPN server

Client configuration settings: 

remote <dns or ip address>  1194

# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)

redirect-gateway def1

When the local network of the OpenVPN client is the same as the local network of the OpenVPN server than you can add the following line to the ovpn configuration file.

route <ip address> 

for example both networks have the same local network: 192.168.1.0/24 and traffic is not sent inside the VPN tunnel you can add to reach 192.168.1.10 on the local network of the VPN server 

route 192.168.1.10 

When you have problems with DNS for example with the DNS servers of Ziggo who only allow queries from their own network. You can change your DNS settings to the nameservers of Google. Name servers are 8.8.8.8 and 8.8.4.4 

Warning message in the log file: 

WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.

You see this message when you connect with a standard OpenVPN server from Synology and is showed because of the way Synology implemented their OpenVPN server. 

Synology DNS server and dnsmasq

When stopping the DNS server running on the Synology NAS  I notice that port 53 is still open. 

Running netstat -anp  on the Synology NAS reveals dnsmasq to have port 53 open. 

Stopping the DCHP server in control panel stops dnsmasq from running on port 53. 

 

Synology best settings for Quick Connect

Use a public DNS server (For example Google DNS servers):

Control Panel, Network, General, Select Manually configure DNS server, Preferred DNS server: 8.8.8.8, Alternative DNS server: 8.8.4.4

Turn off IPv6:

Control Panel, Network, Network Interface, Select connected LAN interface, edit, IPv6, IPv6 setup off

Manual IP Address:

Control Panel, Network, Network Interface, Select connected LAN interface, edit,IPv4, use manual configuration. Don't fill in a DNS server. Fill in IP address, Subnet Mask, Gateway. If configurable uncheck jumbo frame option. 

Time:

Control Panel, Regional Options, Synchronize with NTP server: 

For example  Server address: pool.ntp.org 

Check correct local time. 

Synology mount volume as read-only

Always contact Synology support first for help. If you like to try on your own risk: 

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 check health info disks

Storage Manager, HDD/SDD

Select disk and expand information.

Check Status: Normal

Check S.M.A.R.T status: Normal 

Check Bad sector count: 0

Select disk and health info, overview

Disk Reconnection Count, Bad Sector Count and Disk Re-identification Count indicate the total quantity of events that have occurred on your disk or system.

Your data are still safely stored on the disk. Although these parameters provide early warning and information about disk health trends, they do not directly imply imminent disk failure.

Disk Reconnection Count display the sum of S.M.A.R.T. Attribute “UItraDMA CRC Error Count” and other interface issues detected by the system. If this parameter increases abruptly compared to general tendency, it may indicate that the disk or some hardware components are aging.

Select disk and health info, S.M.A.R.T test

Run Quick and Extended test. Check results. 

Select disk and health info, S.M.A.R.T info 

Use https://en.m.wikipedia.org/wiki/S.M.A.R.T. for reference 

check status: OK

Important attributes:

01 Read Error Rate:

(Vendor specific raw value.) Stores data related to the rate of hardware read errors that occurred when reading data from a disk surface. The raw value has different structure for different vendors and is often not meaningful as a decimal number.

If you see any non-zero raw values for ID 1 (for WD and Samsung disks) in the disk S.M.A.R.T. info, the disk is defective.

05 Reallocated Sectors Count : 0 

09 Power-on Hours:

Count of hours in power-on state. The raw value of this attribute shows total count of hours (or minutes, or seconds, depending on manufacturer) in power-on state.

By default, the total expected lifetime of a hard disk in perfect condition is defined as 5 years (running every day and night on all days). This is equal to 1825 days in 24/7 mode or 43800 hours.

10 Spin Retry Count: 0 

184 End-to-End error / IOEDC: 0

187 Reported Uncorrectable Errors: 0

188 Command Timeout: 0

196 Reallocation Event Count: 0

197 Current Pending Sector Count: 0

198 (Offline) Uncorrectable Sector Count: 0 

201 Soft Read Error Rate or TA Counter Detected: 

According to Synology Support:

If you see any non-zero raw values for ID 1 (for WD and Samsung disks) and ID 5/197/198 (for all disks) in the disk S.M.A.R.T. info, the disk is defective.

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 3