diff --git a/CHANGES.txt b/CHANGES.txt
index 20b5d3d..d3d9f99 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,11 +1,24 @@
-v1.1.15
-- Added support for M.2 drives on a PCI card (M2Dxx and E10G18-T1 and future models).
-- Improved flags/options checking and added usage help.
-- Can now download the latest script version for you (if you have user home service enabled in DSM).
+v2.2.18
+- Minor shell output formatting fix.
+
+v1.2.17
+- Added disable support memory compatibility option --ram or -r
+
+v1.2.16
+- Changed to show the script version, Synology model and DSM version on each run to make it easier to debug any user's issues.
+
+v1.2.15
+- Now finds your expansion units' model numbers and adds your drives to their db files.
+- Now adds your M.2 drives to your M.2 PCI card's db files (supports M2Dxx and E10M20-T1 and future models with similar model names).
+- Improved flags/options checking and added usage help (-h or --help) and version info (-v or --version).
+- Can now download the latest script version for you (if you have 'user home service' enabled in DSM).
- Now adds 'support_m2_pool="yes"' line for models that don't have support_m2_pool in synoinfo.conf
- To (hopefully) prevent losing your SSH created M2 volume when running this script on models that DSM 7.2 Beta does not list as supported for creating M2 volumes.
-- Changed Synology model detection to be more reliable (for models that came in different variations).
+- Added removal of " 00Y" from end of Samsung/Lenovo SSDs to fix issue #13.
+- Changed Synology NAS model detection to be more reliable (for models that came in different variations and report extra text after model). issue #2 and issue #10
- Changed checking drive_db_test_url setting to be more durable.
+- Fixed bug where removable drives were being added to the drive database.
+- Fixed bug where "M.2 volume support already enabled" message appeared when NAS had no M.2 drives.
v1.1.14
- Minor bug fix.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..bd4c6aa
--- /dev/null
+++ b/README.md
@@ -0,0 +1,86 @@
+# Synology HDD db
+
+
+
+
+### Description
+
+Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your M.2 card and Expansion Unit databases.
+
+The script works in DSM 7 and DSM 6.
+
+#### What the script does:
+
+* Gets the Synology NAS model and DSM version (so it knows which db files to edit).
+* Gets a list of the HDD, SSD, SAS and NVMe drives installed in your Synology NAS.
+* Gets each drive's model number and firmware version.
+* Backs up the database files if there is no backup already.
+* Checks if each drive is already in the Synology's compatible-drive database.
+* Adds any missing drives to the Synology's compatible-drive database.
+* Prevents DSM auto updating the drive database.
+* Optionally disable DSM's "support_disk_compatibility".
+* Optionally disable DSM's "support_memory_compatibility".
+* Checks that M.2 volume support is enabled (on supported models).
+* Makes DSM recheck disk compatibility so rebooting is not needed (DSM 7 only).
+* Reminds you that you may need to reboot the Synology after running the script (DSM 6 only).
+* Checks if there is a newer version of this script and offers to download it for you.
+ * The new version available messages time out so they don't prevent the script running if it is scheduled to run unattended.
+
+**Planned updates:**
+* Allow unsupported M.2 drives for use as volumes in DSM 7.2 (for models that supported M.2 volumes).
+
+### Download the script
+
+See How to download the script for the easiest way to download the script.
+
+### When to run the script
+
+You would need to re-run the script after a DSM update. If you have DSM set to auto update the best option is to run the script every time the Synology boots, and the best way to do that is to setup a scheduled task to run the the script at boot-up.
+
+**Note:** For DSM 6, after you first run the script you may need to reboot the Synology to see the effect of the changes.
+
+### Options when running the script
+
+There are optional flags you can use when running the script:
+* --showedits or -s to show you the changes it made to the Synology's compatible-drive database.
+* --noupdate or -n to prevent DSM updating the compatible drive databases.
+* --m2 or -m to prevent processing M.2 drives.
+* --force or -f to disable "support_disk_compatibility". This should only be needed if any of your drives weren't detected.
+ * If you run the script without --force or -f it will re-eanble "support_disk_compatibility".
+* --ram or -r to disable "support_memory_compatibility".
+ * If you run the script without --ram or -r it will re-eanble "support_memory_compatibility".
+
+

+
+### Scheduling the script in Synology's Task Scheduler
+
+See How to schedule a script in Synology Task Manager
+
+### Running the script via SSH
+
+You run the script in a shell with sudo or as root.
+
+```YAML
+sudo /path-to-script/syno_hdd_db.sh
+```
+
+**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
+
+
+
+If you run the script with the -showedits flag it will show you the changes it made to the Synology's compatible-drive database. Obviously this is only useful if you run the script in a shell.
+
+```YAML
+sudo /path-to-script/syno_hdd_db.sh -showedits
+```
+
+**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
+
+
+
+**Credits**
+
+- The idea for this script came from a comment made by Empyrealist on the Synology subreddit.
+- Thanks for the assistance from Alex_of_Chaos on the Synology subreddit.
+- Thanks to dwabraxus and aferende for help detecting connected expansion units.
+- Thanks to bartoque on the Synology subreddit for the tip on making the script download the latest release from github.
diff --git a/images/how_to_download.png b/images/how_to_download.png
new file mode 100644
index 0000000..c5f1510
Binary files /dev/null and b/images/how_to_download.png differ
diff --git a/images/syno_hdd_db1.png b/images/syno_hdd_db1.png
new file mode 100644
index 0000000..ec0884c
Binary files /dev/null and b/images/syno_hdd_db1.png differ
diff --git a/images/syno_hdd_db_help.png b/images/syno_hdd_db_help.png
new file mode 100644
index 0000000..4d2fdea
Binary files /dev/null and b/images/syno_hdd_db_help.png differ
diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh
index a17b6b2..2c6aa12 100644
--- a/syno_hdd_db.sh
+++ b/syno_hdd_db.sh
@@ -3,7 +3,7 @@
#--------------------------------------------------------------------------------------------------
# Github: https://github.com/007revad/Synology_HDD_db
# Script verified at https://www.shellcheck.net/
-# Tested on DSM 7.1.1 and DSM 6.2.4
+# Tested on DSM 7.2 beta, 7.1.1 and DSM 6.2.4
#
# Easiest solution:
# Edit /etc.defaults/synoinfo.conf and change support_disk_compatibility="yes" to "no" and reboot.
@@ -25,15 +25,15 @@
# TODO
# Bypass M.2 volume lock for unsupported M.2 drives.
#
-# Detect if expansion unit(s) connected and get model(s) and edit expansion unit db files.
-# Or add support for specifying user's expansion unit model(s) as arguments.
-# Or maybe use the shotgun approach and update all expansion unit db files.
-#
# Maybe also edit the other disk compatibility db in synoboot, used during boot time.
# It's also parsed and checked and probably in some cases it could be more critical to patch that one instead.
# DONE
-# Added support for M.2 drives on a PCI card (M2Dxx and E10G18-T1 and future models).
+# Added option to disable incompatible memory notifications.
+#
+# Now finds your expansion units' model numbers and adds your drives to their db files.
+#
+# Now adds your M.2 drives to your M.2 PCI cards db files (M2Dxx and E10M20-T1 and future models).
#
# Improved flags/options checking and added usage help.
#
@@ -47,6 +47,12 @@
#
# Changed checking drive_db_test_url setting to be more durable.
#
+# Added removal of " 00Y" from end of Samsung/Lenovo SSDs to fix issue #13.
+#
+# Fixed bug where removable drives were being detected and added to drive database.
+#
+# Fixed bug where "M.2 volume support already enabled" message appeared when NAS had no M.2 drives.
+#
#
# Added check that M.2 volume support is enabled (on supported models).
#
@@ -78,10 +84,11 @@
# Optionally disable "support_disk_compatibility".
-scriptver="v1.1.15"
+scriptver="v1.2.18"
script=Synology_HDD_db
repo="007revad/Synology_HDD_db"
+#echo -e "bash version: $(bash --version | head -1 | cut -d' ' -f4)\n" # debug
# Shell Colors
#Black='\e[0;30m'
@@ -118,18 +125,17 @@ exit 0
scriptversion(){
cat </dev/null; then
- # DSM 7 drive db files start with {"disk_compatbility_info":
- dbtype=7
-elif grep -F '{"success":1,"list":[' "$db1" >/dev/null; then
- # DSM 6 drive db files start with {"success":1,"list":[
- dbtype=6
-else
- echo -e "${Error}ERROR${Off} Unknown database type $(basename -- "${db1}")!"
- exit 7
-fi
-#echo "dbtype: $dbtype" # debug
+getdbtype(){
+ # Detect drive db type
+ if grep -F '{"disk_compatbility_info":' "$1" >/dev/null; then
+ # DSM 7 drive db files start with {"disk_compatbility_info":
+ dbtype=7
+ elif grep -F '{"success":1,"list":[' "$1" >/dev/null; then
+ # DSM 6 drive db files start with {"success":1,"list":[
+ dbtype=6
+ else
+ echo -e "${Error}ERROR${Off} Unknown database type $(basename -- "${1}")!" >&2
+ dbtype=1
+ fi
+ #echo "db type: $dbtype" >&2 # debug
+}
backupdb() {
# Backup database file if needed
if [[ ! -f "$1.bak" ]]; then
+ if [[ $(basename "$1") == "synoinfo.conf" ]]; then
+ echo "" >&2
+ fi
if cp "$1" "$1.bak"; then
- echo -e "\nBacked up $(basename -- "${1}") database.\n"
+ echo -e "Backed up $(basename -- "${1}")" >&2
else
- echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${1}")!"
+ echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${1}")!" >&2
return 1
fi
fi
@@ -459,9 +532,6 @@ backupdb() {
# Backup host database file if needed
backupdb "$db1" || exit 5
-# Backup synoinfo.conf if needed
-backupdb "$synoinfo" || exit 9
-
#------------------------------------------------------------------------------
# Edit db files
@@ -470,14 +540,17 @@ updatedb() {
hdmodel=$(printf "%s" "$1" | cut -d"," -f 1)
fwrev=$(printf "%s" "$1" | cut -d"," -f 2)
- #echo arg1 "$1" # debug
- #echo arg2 "$2" # debug
- #echo hdmodel "$hdmodel" # debug
- #echo fwrev "$fwrev" # debug
+ #echo arg1 "$1" >&2 # debug
+ #echo arg2 "$2" >&2 # debug
+ #echo hdmodel "$hdmodel" >&2 # debug
+ #echo fwrev "$fwrev" >&2 # debug
if grep "$hdmodel" "$2" >/dev/null; then
- echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}"
+ echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2
else
+ # Check if db file is new or old style
+ getdbtype "$2"
+
if [[ $dbtype -gt "6" ]];then
# Don't need to add firmware version?
fwstrng=\"$fwrev\"
@@ -503,7 +576,7 @@ updatedb() {
echo -e "\n${Error}ERROR 6${Off} Failed to update v7 $(basename -- "$2")${Off}"
exit 6
fi
- else
+ elif [[ $dbtype -eq "6" ]];then
# example:
# {"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]},
# Don't need to add firmware version?
@@ -512,9 +585,9 @@ updatedb() {
# {"success":1,"list":[
startstring="{\"success\":1,\"list\":\["
- #echo "$startstring" # debug
- #echo "$string" # debug
- #echo # debug
+ #echo "$startstring" >&2 # debug
+ #echo "$string" >&2 # debug
+ #echo >&2 # debug
# example:
# {"success":1,"list":[{"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]},
@@ -529,7 +602,7 @@ updatedb() {
fi
else
- echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}"
+ echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" >&2
exit 8
fi
fi
@@ -543,6 +616,22 @@ while [[ $num -lt "${#hdds[@]}" ]]; do
if [[ -f "$db2" ]]; then
updatedb "${hdds[$num]}" "$db2"
fi
+
+ #------------------------------------------------
+ # Expansion Units
+ num2="0"
+ while [[ $num2 -lt "${#eunits[@]}" ]]; do
+ eudb="${dbpath}${eunits[$num2],,}${version}.db"
+ if [[ -f "$eudb" ]];then
+ backupdb "$eudb" &&\
+ updatedb "${hdds[$num]}" "$eudb"
+ else
+ echo -e "${Error}ERROR 11${Off} $eudb not found!"
+ fi
+ num2=$((num2 +1))
+ done
+ #------------------------------------------------
+
num=$((num +1))
done
@@ -575,6 +664,9 @@ done
#------------------------------------------------------------------------------
# Edit /etc.defaults/synoinfo.conf
+# Backup synoinfo.conf if needed
+backupdb "$synoinfo" || exit 9
+
# Optionally disable "support_disk_compatibility"
sdc=support_disk_compatibility
setting="$(get_key_value $synoinfo $sdc)"
@@ -599,29 +691,58 @@ else
fi
-# Check m2 volume support enabled
-smp=support_m2_pool
-setting="$(get_key_value $synoinfo ${smp})"
-enabled=""
-if [[ ! $setting ]]; then
- # Add support_m2_pool"yes"
- echo 'support_m2_pool="yes"' >> "$synoinfo"
- enabled="yes"
-elif [[ $setting == "no" ]]; then
- # Change support_m2_pool"no" to "yes"
- sed -i "s/${smp}=\"no\"/${smp}=\"yes\"/" "$synoinfo"
- enabled="yes"
-elif [[ $setting == "yes" ]]; then
- echo -e "\nM.2 volume support already enabled."
+# Optionally disable "support_memory_compatibility"
+smc=support_memory_compatibility
+setting="$(get_key_value $synoinfo $smc)"
+if [[ $ram == "yes" ]]; then
+ if [[ $setting == "yes" ]]; then
+ # Disable support_memory_compatibility
+ sed -i "s/${smc}=\"yes\"/${smc}=\"no\"/" "$synoinfo"
+ setting="$(get_key_value "$synoinfo" $smc)"
+ if [[ $setting == "no" ]]; then
+ echo -e "\nDisabled support memory compatibility."
+ fi
+ fi
+else
+ if [[ $setting == "no" ]]; then
+ # Enable support_memory_compatibility
+ sed -i "s/${smc}=\"no\"/${smc}=\"yes\"/" "$synoinfo"
+ setting="$(get_key_value "$synoinfo" $smc)"
+ if [[ $setting == "yes" ]]; then
+ echo -e "\nRe-enabled support memory compatibility."
+ fi
+ fi
fi
-# Check if we enabled m2 volume support
-setting="$(get_key_value $synoinfo ${smp})"
-if [[ $enabled == "yes" ]]; then
- if [[ $setting == "yes" ]]; then
- echo -e "\nEnabled M.2 volume support."
- else
- echo -e "${Error}ERROR${Off} Failed to enable m2 volume support!"
+
+# Enable m2 volume support
+if [[ $m2 != "no" ]]; then
+ if [[ $m2exists == "yes" ]]; then
+ # Check if m2 volume support is enabled
+ smp=support_m2_pool
+ setting="$(get_key_value $synoinfo ${smp})"
+ enabled=""
+ if [[ ! $setting ]]; then
+ # Add support_m2_pool"yes"
+ echo 'support_m2_pool="yes"' >> "$synoinfo"
+ enabled="yes"
+ elif [[ $setting == "no" ]]; then
+ # Change support_m2_pool"no" to "yes"
+ sed -i "s/${smp}=\"no\"/${smp}=\"yes\"/" "$synoinfo"
+ enabled="yes"
+ elif [[ $setting == "yes" ]]; then
+ echo -e "\nM.2 volume support already enabled."
+ fi
+
+ # Check if we enabled m2 volume support
+ setting="$(get_key_value $synoinfo ${smp})"
+ if [[ $enabled == "yes" ]]; then
+ if [[ $setting == "yes" ]]; then
+ echo -e "\nEnabled M.2 volume support."
+ else
+ echo -e "\n${Error}ERROR${Off} Failed to enable m2 volume support!"
+ fi
+ fi
fi
fi
@@ -647,7 +768,7 @@ if [[ $nodbupdate == "yes" ]]; then
if [[ $url == "127.0.0.1" ]]; then
echo -e "\nDisabled drive db auto updates."
else
- echo -e "${Error}ERROR${Off} Failed to disable drive db auto updates!"
+ echo -e "\n${Error}ERROR${Off} Failed to disable drive db auto updates!"
fi
fi
else
@@ -673,6 +794,7 @@ fi
# Show the changes
if [[ ${showedits,,} == "yes" ]]; then
+ getdbtype "$db1"
if [[ $dbtype -gt "6" ]];then
# Show last 12 lines per drive + 4
lines=$(((db1Edits *12) +4))
@@ -683,7 +805,7 @@ if [[ ${showedits,,} == "yes" ]]; then
echo -e "\nChanges to ${Cyan}$(basename -- "$db2")${Off}"
jq . "$db2" | tail -n "$lines"
fi
- else
+ elif [[ $dbtype -eq "6" ]];then
# Show first 8 lines per drive + 2
lines=$(((db1Edits *8) +2))
if [[ $db1Edits -gt "0" ]]; then