Browse Source

Merge branch 'develop' of https://github.com/007revad/Synology_HDD_db into develop

develop
007revad 1 week ago
parent
commit
95a448dd76
  1. 110
      .gitattributes
  2. 3
      .github/FUNDING.yml
  3. 136
      2025_plus_models.md
  4. 297
      CHANGES.txt
  5. 239
      README.md
  6. BIN
      bin/dhm_tool
  7. 12
      bin/dhm_tool.txt
  8. BIN
      bin/dtc
  9. 8
      bin/dtc_info.txt
  10. 2
      bin/dtc_source.txt
  11. BIN
      images/ihm.png
  12. BIN
      images/schedule3-2.png
  13. BIN
      images/syno_hdd_db_help2.png
  14. BIN
      images/unknown.png
  15. BIN
      images/update-now-disabled.png
  16. BIN
      images/update-now-working.png
  17. BIN
      images/vendor_ids.png
  18. 183
      my-other-scripts.md
  19. 2743
      syno_hdd_db.sh
  20. 411
      syno_hdd_shutdown.sh
  21. 24
      syno_hdd_vendor_ids.txt

110
.gitattributes

@ -0,0 +1,110 @@
# Common settings that generally should always be used with your language specific settings
# Auto detect text files and perform LF normalization
* text=auto
#
# The above will handle all files NOT found below
#
# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.epub diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text diff=markdown
*.mdx text diff=markdown
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.tab text
*.tsv text
*.txt text eol=lf
*.sql text
*.csv text eol=crlf
# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
*.eps binary
# SVG treated as text by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.ksh text eol=lf
*.py text eol=lf
*.php text eol=lf
*.sh text eol=lf
*.zsh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Visual Dialog Script
*.dsc text eol=crlf
*.dsp text eol=crlf
# Config files
*.ini text eol=crlf
*.conf text eol=lf
# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text
# Archives
*.7z binary
*.bz binary
*.bz2 binary
*.bzip2 binary
*.gz binary
*.lz binary
*.lzma binary
*.rar binary
*.tar binary
*.taz binary
*.tbz binary
*.tbz2 binary
*.tgz binary
*.tlz binary
*.txz binary
*.xz binary
*.Z binary
*.zip binary
*.zst binary
# Text files where line endings should be preserved
*.patch -text
#
# Exclude files from exporting
#
.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore
.github/ export-ignore
images/ export-ignore

3
.github/FUNDING.yml

@ -0,0 +1,3 @@
github: 007revad
buy_me_a_coffee: 007revad
custom: ["https://www.paypal.me/007revad"]

136
2025_plus_models.md

@ -0,0 +1,136 @@
## 2025 series or later Plus models
### UPDATE 7 Oct 2025
**DSM 7.3** has removed the many of the restrictions that were in DSM 7.2.2 for 2025 Plus models.
See https://kb.synology.com/en-global/DSM/tutorial/Drive_compatibility_policies
The restrictions that remain in DSM 7.3 for 2025 Plus models are:
1. You cannot create a cache or volume on 3rd party NVMe drives.
2. You still see lots of warnings in storage manager when using unverified 3rd party drives.
Both 1 and 2 can be solved with [Synology HDD db](https://github.com/007revad/Synology_HDD_db)
<br>
### Unverified 3rd party drive limitations and unofficial solutions for DSM 7.2.2
| Action | Works | Result | Solution |
|--------|--------------|--------|----------|
| Setup the NAS with Synology drives | yes | | |
| Setup the NAS with 3rd party SSDs | yes | Lots of warnings | Remove warnings with [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Setup the NAS with unverified 3rd party HDDs | **No!** | | See <a href="#setting-up-a-new-2025-or-later-plus-model-with-only-unverified-hdds">Setup with unverifed HDDs</a> |
| Migrate unverified 3rd party drives from other Synology | yes | Lots of warnings | Remove warnings with [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Migrate unverified 3rd party drives and NVMe cache from other Synology | yes | Lots of warnings | Remove warnings with [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Replace migrated 3rd party drives with 3rd party drives | **No!** | | Use [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Gradually replace migrated 3rd party drives with Synology drives | yes | Lots of warnings until all 3rd party drives replaced | Use [Synology HDD db](https://github.com/007revad/Synology_HDD_db) See [Migration and Drive Replacement](https://github.com/007revad/Synology_HDD_db/discussions/468#discussioncomment-13086639) |
| Expand migrated 3rd party storage pool with 3rd party drives | **No!** | | Use [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Use 3rd party drive as hot spare | **No!** | | Use [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Create a cache with 3rd party SSDs | **No!** | | Use [Synology HDD db](https://github.com/007revad/Synology_HDD_db) |
| Delete and create storage pool on migrated 3rd party drives | **No!** | | See <a href="#deleting-and-recreating-your-storage-pool-on-unverified-hdds">Recreating storage pool</a> |
<br>
### Setting up a new 2025 or later plus model with only unverified HDDs in DSM 7.2.2
Credit to Alex_of_Chaos on reddit
DSM won't install on a 2025 or later series plus model if you only have unverified HDDs. But we can get around that.
1. Start telnet by entering `http://<NAS-IP>:5000/webman/start_telnet.cgi` into your browser's address bar.
- Replace `<NAS-IP>` with the IP address of the Synology NAS.
2. Open a telnet client (powershell, PuTTY etc) on your computer and connect to the Synology with 'telnet <NAS-IP>`.
- Replace `<NAS-IP>` with the IP address of the Synology NAS.
3. Log into telnet with:
- `root` for the login
- `101-0101` for the password
4. Execute the following command: (using a while loop in case DSM is running in a VM)
```
while true; do touch /tmp/installable_check_pass; sleep 1; done
```
5. Refresh the web installation page and install DSM.
6. Then in the telnet window, or via SSH, execute the following command:
```
/usr/syno/bin/synosetkeyvalue /etc.defaults/synoinfo.conf support_disk_compatibility no
```
7. If Storage Manager is already open close then open it, or refresh the web page. If refreshing the page or restarting Storage Manager is not working, try restarting your Synology NAS.
8. You can now create your storage pool from Storage Manager.
<br>
### Deleting and recreating your storage pool on unverified HDDs in DSM 7.2.2
You can't download Synology HDD db to a volume because you've just deleted your storage pool. So you'd first need to download Synology HDD db to a system folder and run it from there.
You can do this via SSH or via a scheduled task.
#### Via SSH
1. Create and cd to /opt
```
sudo mkdir /opt && sudo chmod 775 /opt
```
2. Create /opt
```
sudo mkdir -m775 /opt
```
2. cd to /opt
```
cd /opt || (echo "Failed to CD to /opt"; exit 1)
```
3. Download syno_hdd_db.sh to /opt
```
sudo curl -O "https://raw.githubusercontent.com/007revad/Synology_HDD_db/refs/heads/main/syno_hdd_db.sh"
```
4. Download syno_hdd_vendor_ids.txt to /opt
```
sudo curl -O "https://raw.githubusercontent.com/007revad/Synology_HDD_db/refs/heads/main/syno_hdd_vendor_ids.txt"
```
5. Then set permissions on /opt/syno_hdd_db.sh
```
sudo chmod 750 /opt/syno_hdd_db.sh
```
6. Finally run syno_hdd_db. You don't need any options at this point.
```
sudo -s /opt/syno_hdd_db.sh
```
8. If Storage Manager is already open close then open it, or refresh the web page.
9. You can now create your storage pool from Storage Manager.
#### Via a scheduled task
First setup email notifications (if you haven't already):
1. Go to **Control Panel** > **Notification** > **Email** > click **Setup**.
Then create the scheduled task:
1. Go to **Control Panel** > **Task Scheduler** > click **Create** > **Scheduled Task** > **User-defined script**.
2. Enter a task name.
3. Select **root** as the user (The script needs to run as root).
4. Untick **Enable**.
5. Click **Task Settings**.
6. Tick **Send run details by email** and enter your email address.
7. In the box under **User-defined script** paste the following:
```
mkdir -m775 /opt
cd /opt || (echo "Failed to CD to /opt"; exit 1)
curl -O "https://raw.githubusercontent.com/007revad/Synology_HDD_db/refs/heads/main/syno_hdd_db.sh"
curl -O "https://raw.githubusercontent.com/007revad/Synology_HDD_db/refs/heads/main/syno_hdd_vendor_ids.txt"
chmod 750 /opt/syno_hdd_db.sh
/opt/syno_hdd_db.sh -e
```
8. Click **OK** > **OK** > type your password > **Submit** to save the scheduled task.
9. Now select the scheduld task and click **Run** > **OK**.
10. Check your emails to make sure the scheduled task ran without any error.
11. If Storage Manager is already open close then open it, or refresh the web page.
12. You can now create your storage pool from Storage Manager.

297
CHANGES.txt

@ -1,3 +1,298 @@
v3.6.124
- Bug fix for script trying to set write_mostly on SATA M.2 drives. Issue #567
- Bug fix for script trying to use nvme command to get SATA M.2 drives' vendor id. Issue #567
v3.6.123
- Bug fix for WD Ultrastar drives that have "WDC " before the model name. Issue #559
v3.6.122
- Bug fix for drive models with multiple consecutive spaces in model name. Issue #559
- Bug fix for nvme drives with multiple consecutive spaces in firmware version.
- Bug fix for options not working. Issue #559 and #563
v3.6.121
- Added --reboot option to reboot the NAS after a DSM update where the build number has changed.
- Only needed if NVMe volume or PCIe card need a 2nd reboot after DSM update.
- Note: This version of the script needs to run once to create the file that tracks the DSM build number.
v3.6.119
- Bug fix for "cat: /sys/block//sys/block/sata1/device/vendor: No such file or directory" errors. Issue #554
v3.6.118
- Changed to enable creating M.2 storage pool and volume in Storage Manager after making DSM check disk compatibility. Issue #441
- Added SSD TRIM warning of possible data loss if non-Synology SSDs or NVMes are in RAID 5, 6 or SHR with more than 3 drives.
- See https://kb.synology.com/en-global/DSM/tutorial/Why_is_SSD_TRIM_available_only_for_SSDs_in_the_compatibility_list
v3.6.116
- Moved the "Warn if script located on NVMe volume" code to after the "check for new script version code. Issue #540
- Bug fix for incorrectly warning that the script is located on an NVMe volume when it is on a SHR HDD volume that has, or had, different HDD sizes. Issue #540
v3.6.115
- Added syno_hdd_shutdown.sh to the auto update code.
- Now if script is located on an NVMe volume it warns you and exits. Previously it just warned you and continued.
- Bug fix for DSM 7.3 not disabling compatible drive database auto update.
- Bug fix for script thinking it's on an NVMe volume if the HDD volume it's on has a NVMe cache.
v3.6.113
- Added check that DSM 7.3 db file was successfully compacted.
- Added drive's firmware version to messages.
- Improved checking if drive and firmware version were successfully added to db file.
- Bug fix for adding duplicate drive if 2 or more of the same drive model had different firmware versions.
- Also removes duplicate drive entries if they exist (before correctly editing the file).
- Bug fix adding size_gb to to drive firmware version entries instead of just the "default" key section.
v3.6.112
- Bug fix for DSM 7.3 and later where new database files have a space after each : and ,
v3.6.111
- Added support for M.2 volumes for NVMe drives in PCIe adaptor cards for DSM 7.1.1
v3.6.110
- Bug fix for not finding SAS expansion units. Issue #413
v3.6.109
- Added -I, --ihm option to update IronWolf Health Management to 2.5.1 to support recent model IronWolf and IronWolf Pro drives.
- For NAS with x86_64 CPUs only.
- Installs IronWolf Health Management on '22 series and newer models that don't have IronWolf Health Management (untested).
v3.5.108
- Prevent error message if /tmpRoot exists but does not contain /usr/syno/bin/synosetkeyvalue and /etc.defaults/synoinfo.conf. Issue #411
v3.5.107
- Bug fix for firmware version as "Found]" in db files. Issue #407
v3.5.106
- Bug fix for when script is not located on a volume. Issue #397
v3.5.105
- Bug fix for drives that return "HCST <model>" as the model, like HGST drives do. Issue #389
v3.5.104
- Some disks will be blocked in special scenarios. PR #387
v3.5.103
- Bug fix getting size of large drives. Issue #368
- Run the script once with the --restore option to undue the previous changes then run the script as normal.
v3.5.102
- Changed to use a faster method of detecting if an expansion unit is connected, for models with the syno_slot_mapping command.
- Changed so XPE users using the hdddb addon don't need to reboot.
v3.5.101
- Changed to support "--restore --ssd=restore" to restore write_mostly when restoring all other changes. Issue #340
- When using --restore you can also use --ssd=restore, -e or --email
v3.5.98
- Changed to automatically download and install dtc if all of the following 4 conditions are met:
1. dtc is not already installed.
2. /bin/dtc or dtc are not in the same folder as the script.
3. The script needs dtc.
4. The script is running from task scheduler.
- Bug fix for "Enable write_mostly on slow internal drives so DSM runs from the fast internal drive(s)." Issue #340
- Improved output to make it clear which drive(s) have most_writely set.
v3.5.97
- Changed silently skip empty .db.new files with showing an error. Issue #175
- Changed to warn if db file is 0 bytes.
v3.5.96
- Added option to set write_mostly for your internal HDDs so DSM will normally read from your faster internal SSD(s).
- It can automatically set DSM to read from your internal SSDs.
- Or you can tell the script which internal drive(s) DSM should read from.
Thanks to Xeroxxx for the writemostly suggestion and their writeup here:
https://www.techspark.de/speed-up-synology-dsm-with-hdd-ssd/
v3.5.94
- Updated to support newer drive db versions.
- Synology added size_gb in a recent host v7 version (in SynoOfflinePack 764).
- Synology added barebone_installable_v2 in the latest host v7 version (in SynoOfflinePack 787).
- Bug fix when restoring where memcheck service was only re-enabled on DVA models.
- Changed to add leading 0 to short vids reported by drive.
- Sets 2 vids in case DSM uses the short one (e.g. 0x05dc=brand and 0x5dc=brand).
Note: You may need to run syno_hdd_db without the -n or --noupdate option, then update the drive database from
"Storage Manager > HDD/SSD > Settings > Advanced > Update Now" then run syno_hdd_db with your preferred options.
v3.5.93
- Bug fix for false "Failed to delete tmp files" log entries when script updates itself. Issue #312
- Bug first appeared in v3.1.64
v3.5.92
- Changed to support M.2 SATA SSDs in M2D18 or M2D17.
- Change -s, --show option to show changes for each different drive model.
v3.5.91
- Changed to not exit if no SATA or SAS drives found. Issue #303
- Now only exits if no SATA, SAS or NVMe drives found.
v3.5.90
- Changed to enable creating storage pools/volumes on NVMe drives in a PCIe M.2 adaptor in DSM 7.2
- Previously only supported DSM 7.2.1
- Changed to enable creating storage pools/volumes on NVMe drives in a PCIe M.2 adaptor even if PCIe M.2 adaptor not found.
- This may allow creating NVMe volumes on 3rd party PCIe M.2 adaptors.
- Bug fix for when there's multiple expansion unit models only the last expansion unit was processed. Issue #288
- Bug fix for when there's multiple M2 adaptor card models only the last M2 card was processed.
- Bug fix for incorrectly matching model name variations as well as the exact model name.
- e.g. RX1217 matched RX1217, RX1217rp and RX1217sas.
v3.5.89
- Bug fix for -s, --showedits option with multiple of the same drive model but with different firmware versions. Issue #276
v3.5.88
- Changed how memory compatibility is disabled for older models. Issue #272
v3.4.87
- Fix Invalid json format syslog output #270
v3.4.86
- Hard coded /usr/syno/bin/<command> for Synology commands (to prevent $PATH issues). #249
v3.4.84
- Bug fix when script updates itself and user ran the script from ./scriptname.sh
v3.4.83
- Fix for drives that exist in the drive database already but have "compatibility not_support".
- Affected drives were showing as "Incompatible" in storage manager.
- Need to use the -i or --incompatible option.
v3.4.82
- Fix for drives that exist in the drive database already but have "compatibility unverified". Issue #224
- Affected drives were showing as "Unverified" in storage manager.
v3.4.81
- Bug fix for false "This script is NOT running on a Synology NAS!" if uname is installed from Entware. Issue #218
v3.4.80
- Bug fix for chmod failed on changes.txt
- Improved help message.
v3.4.78
- Added check that script is running on Synology NAS.
v3.4.77
- Include smart_test_ignore and smart_attr_ignore in db files.
- Now saves changes.txt as <script-filename>_changes.txt when updating the script.
- To not overwrite changes.txt if my other scripts are in the same folder.
- Bug fix for detecting if script is located on M.2 drive.
- Bug fix for error when -s or --showedits option was used. Issue #200
- Minor bug fix.
v3.3.73
- Bug fix for vendor id.
v3.3.72
- Bug fix for enabling creating storage pools in Storage Manager for M.2 drives in PCIe adaptor cards.
- Bug fix for not copying syno_hdd_db_vendors.txt to script location when script updates itself.
- Bug fix for checking if script located on NVMe drive.
v3.3.70
- Now enables creating storage pools in Storage Manager for M.2 drives in PCIe adaptor cards:
- E10M20-T1, M2D20, M2D18 and M2D17.
- DSM 7.2.1 and above only.
- Script needs to run after each boot.
- Added new vendor ids for Apacer, aigo, Lexar and Transcend NVMe drives.
- Now includes syno_hdd_vendor.txt so users can add their NVMe drive's vendor id.
- syno_hdd_vendor.txt needs to be in the same folder as syno_hdd_db.sh
- Now warns if script is located on an M.2 volume.
v3.2.69
- Added KIOXIA vendor id.
- Bug fix for wrong version number, which caused an update loop.
v3.2.68
- Updated so E10M20-T1, M2D20, M2D18 and M2D17 now work in models that use device tree and are using:
- DSM 7.2 Update 2 and 3, 7.2.1, 7.2.1 Update 1, 2 and 3. Issue #132, #148
- Now edits model.dtb instead of downloading a pre-edited version.
- Improvements to --restore option.
- Fix for Unknown vendor causing "Unsupported firmware version" warning. Issue #161
- Now supports NVMe drives that show as Unknown brand in storage manager: Issue #161
- ADATA, Corsair, Gigabyte, HS/MAXIO, MSI, Netac, Phison, PNY
- SK Hynix, Solidigm, SPCC/Lexar, TEAMGROUP, UMIS, ZHITAI
- Fixed bug where memory was shown in MB but with GB unit.
- Removed -i, --immutable option.
- Minor bug fixes.
v3.1.65
- Bug fix for NVMe drives with / in the model name for non-device tree Synology models. Issue #154
v3.1.64
- Added -e --email option to disable coloured output to make task scheduler emails easier to read.
- Bug fix for script not updating itself if .sh file had been renamed.
- Bug fix for missing executable permissions if .sh file had been renamed.
- Bug fix to prevent update loop if script's .tar.gz file already exists in /tmp.
- Bug fix to prevent update failing if script's temp folder already exists in /tmp.
- Now only copies CHANGES.txt to script location if script is located on a volume, to prevent putting CHANGES.txt on system partition (/usr/bin, /usr/sbin, /root etc.)
v3.1.63
- Added support to disable unsupported memory warnings on DVA models. #136
v3.1.62
- Fixed bug where newly connected expansion units weren't found until up to 24 hours later. Issue #124
v3.1.61
- Added enabling E10M20-T1, M2D20 and M2D18 for DS1821+, DS1621+ and DS1520+.
- Added enabling M2D18 for RS822RP+, RS822+, RS1221RP+ and RS1221+ for older DSM versions.
- Fixed enabling E10M20-T1, M2D20 and M2D18 cards in models that don't officially support them.
- Fixed bugs where the calculated amount of installed memory could be incorrect:
- If last memory socket was empty an invalid unit of bytes could be used. Issue #106
- When dmidecode returned MB for one ram module and GB for another ram module. Issue #107
- Fixed bug displaying the max memory setting if total installed memory was less than the max memory. Issue #107
- Fixed bug where sata1 drive firmware version was wrong if there was a sata10 drive.
v3.0.56
- Minor bug fix for checking amount of installed memory.
v3.0.55
- Now enables any installed Synology M.2 PCIe cards for models that don't officially support them.
- You can use a M2D20, M2D18, M2D17 or E10M20-T1 on any model with a PCIe slot (not Mini PCIe).
- Now the script reloads itself after updating.
- Added -i, --immutable option to enable immutable snapshots on models older than '20 series running DSM 7.2.
- Added -w, --wdda option to disable WDDA (to prevent warnings when WD drives have been running more than 3 years).
- Added "You may need to reboot" message when NVMe drives were detected.
- Added --autoupdate=[age] option to auto update synology_hdd_db x days after new version released.
- Autoupdate logs update success or errors to DSM system log.
- Changed help to show -r, --ram also sets max memory to the amount of installed memory.
- Changed the "No M.2 cards found" to "No M.2 PCIe cards found" to make it clearer.
- Changed to skip checking the amount of installed memory in DSM 6 (because it was never working in DSM 6).
- Fixed HDD/SSD firmware versions always being 4 characters long (for DSM 7.2 and 6.2.4 Update 7).
- Fixed detecting amount of installed memory (for DSM 7.2 which now reports GB instead of MB).
- Fixed USB drives sometimes being detected as internal drives (for DSM 7.2).
- Fixed error if /run/synostorage/disks/nvme0n1/m2_pool_support doesn't exist yet (for DSM 7.2).
- Fixed drive db update still being disabled in /etc/synoinfo.conf after script run without -n or --noupdate option.
- Fixed drive db update still being disabled in /etc/synoinfo.conf after script run with --restore option.
- Fixed permissions on restored files being incorrect after script run with --restore option.
- Fixed permissions on backup files.
v2.2.47
- Updated reboot info in readme.
- Added reboot message for DSM 7.
- Bug fix for issue #77 (escape slashes in drive model name).
- Added error sound.
v2.2.45
- Minor bug fix.
v2.2.44
- Added --restore info to --help
- Updated restore option to download the latest db files from Synology.
- Now warns you if you try to run it in sh with "sh scriptname.sh"
v2.2.43
- Fixed DSM 6 bug where the drives were being duplicated in the .db files each time the script was run.
- Fixed DSM 6 bug where the .db files were being duplicated as .dbr each time the db files were edited.
v2.2.42
- Fixed bug where expansion units ending in RP or II were not detected.
- Added a --restore option to undo all changes made by the script.
- Now looks for and edits both v7 and non-v7 db files to solve issue #11 for RS '21 models running DSM 6.2.4. This will also ensure the script still works if:
- Synology append different numbers to the db file names in DSM 8 etc.
- The detected NAS model name does not match the .db files' model name.
- Now backs up the .db.new files (as well as the .db files).
- Now shows max memory in GB instead of MB.
- Now shows status of "Support disk compatibility" setting even if it wasn't changed.
- Now shows status of "Support memory compatibility" setting even if it wasn't changed.
v2.1.38
- Improved shell output when editing max memory setting.
- Changed method of checking if drive is a USB drive to prevent ignoring internal drives on RS models.
@ -15,7 +310,7 @@ v2.0.35
- Now allows creating M.2 storage pool and volume all from Storage Manager.
v1.3.34
- Now always shows your drive entries in the host db file if -s or --showedits used instead of only db file was edited during that run.
- Now always shows your drive entries in the host db file if -s or --showedits used instead of only if db file was edited during that run.
- Changed to show usage if invalid long option used instead of continuing.
v1.3.33

239
README.md

@ -1,14 +1,23 @@
# Synology HDD db
<a href="https://github.com/007revad/Synology_HDD_db/releases"><img src="https://img.shields.io/github/release/007revad/Synology_HDD_db.svg"></a>
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2F007revad%2FSynology_HDD_db&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
![Badge](https://hitscounter.dev/api/hit?url=https%3A%2F%2Fgithub.com%2F007revad%2FSynology_HDD_db&label=Visitors&icon=github&color=%23198754&message=&style=flat&tz=Australia%2FSydney)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/007revad)
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/007revad)
<!-- [![committers.top badge](https://user-badge.committers.top/australia/007revad.svg)](https://user-badge.committers.top/australia/007revad) -->
<!-- [![committers.top badge](https://user-badge.committers.top/australia_public/007revad.svg)](https://user-badge.committers.top/australia_public/007revad) -->
<!-- [![committers.top badge](https://user-badge.committers.top/australia_private/007revad.svg)](https://user-badge.committers.top/australia_private/007revad) -->
<!-- [![Github Releases](https://img.shields.io/github/downloads/007revad/synology_hdd_db/total.svg)](https://github.com/007revad/Synology_HDD_db/releases) -->
### 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.
Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your Synology M.2 PCIe card and Expansion Unit databases.
The script works in DSM 7 and DSM 6.
The script works in DSM 7, including DSM 7.1, 7.2 and 7.3, and DSM 6.
It also has a restore option to undo all the changes made by the script.
Also works for 2025 series or later Plus models. See [2025_plus_models.md](https://github.com/007revad/Synology_HDD_db/blob/main/2025_plus_models.md)
#### What the script does:
@ -18,75 +27,243 @@ #### What the script does:
* 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 prevents DSM auto updating the drive database.
* Optionally disable DSM's "support_disk_compatibility".
* Optionally disable DSM's "support_memory_compatibility" to prevent <a href=images/ram_wanring.png/>non-Synology memory notifications</a>.
* Optionally disable DSM's "support_memory_compatibility" to prevent <a href=images/ram_warning.png/>non-Synology memory notifications</a>.
* Optionally edits max supported memory to match the amount of memory installed, if installed memory is greater than the current max memory setting.
* DSM only uses the max memory setting when calculating the reserved RAM area size for SSD caches.
* Optionally set write_mostly for your internal HDDs so DSM will normally read from your faster internal SSD(s).
* It can automatically set DSM to read from your internal SSDs.
* Or you can tell the script which internal drive(s) DSM should read from.
* Optionally disables Western Digital Device Analytics (aka WDDA) to prevent DSM showing a [warning for WD drives that are 3 years old](https://arstechnica.com/gadgets/2023/06/clearly-predatory-western-digital-sparks-panic-anger-for-age-shaming-hdds).
* DSM 7.2.1 already has WDDA disabled.
* Makes DSM allow you to enable SSD TRIM on 3rd party SSDs and NVMes. Don't use the `-f` or --force` option if you want to enable SSD TRIM.
* Do ***NOT*** use TRIM on SSDs in RAID 5, RAID 6 or SHR with 3 or more SSDs unless you are certain your SSDs use TRIM [Method 1 mentioned here](https://kb.synology.com/en-global/DSM/tutorial/Why_is_SSD_TRIM_available_only_for_SSDs_in_the_compatibility_list).
* Enabling TRIM on SSDs that use TRIM [Method 2](https://kb.synology.com/en-global/DSM/tutorial/Why_is_SSD_TRIM_available_only_for_SSDs_in_the_compatibility_list) ***can result in data loss*** in RAID 5, RAID 6 and SHR with 3 or more drives.
* Enables M2D20, M2D18, M2D17 and E10M20-T1 if present on Synology NAS that don't officially support them.
* Newer NAS models may also need [Synology_enable_M2_card](https://github.com/007revad/Synology_enable_M2_card)
* Checks that M.2 volume support is enabled (on models that have M.2 slots or PCIe slots).
* Enables creating M.2 storage pools and volumes from within Storage Manager.
* 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).
* Enables creating M.2 storage pools and volumes from within Storage Manager in DSM 7.2 and later **(newer models only?)**.
* Including M.2 drives in PCIe adaptor cards like M2D20, M2D18, M2D17 and E10M20-T1 for DSM 7.2 and above **(schedule the script to run boot)**.
* Optionally update IronWolf Health Monitor to v2.5.1 to support recent model IronWolf and IronWolf Pro drives. **(NAS with x86_64 CPUs only)**.
* Also installs IronWolf Health Management on '22 series and newer models that don't have IronWolf Health Management **(untested)**.
* Makes DSM recheck disk compatibility so rebooting is not needed if you don't have M.2 drives (DSM 7 only).
* **If you have M.2 drives you may need to reboot.**
* Reminds you that you may need to reboot the Synology after running the script.
* 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.
### Download the script
See <a href=images/how_to_download.png/>How to download the script</a> for the easiest way to download the script.
1. Download the latest version _Source code (zip)_ from https://github.com/007revad/Synology_HDD_db/releases
2. Save the download zip file to a folder on the Synology.
- Do ***NOT*** save the script to a M.2 volume. After a DSM or Storage Manager update the M.2 volume won't be available until after the script has run.
3. Unzip the zip file.
Or via SSH as your regular user:
```
cd $HOME
wget https://github.com/007revad/Synology_HDD_db/archive/refs/heads/main.zip -O syno_hdd_db.zip
7z x syno_hdd_db.zip
cd Synology_HDD_db-main && ls -ali
```
### Required files
The following files from the downloaded zip file must be in the same folder:
1. syno_hdd_db.sh
2. syno_hdd_vendor_ids.txt
3. dtc or the bin folder containing dtc (only required if you have a E10M20-T1, M2D20 or M2D18 in a NAS that does not support them).
### 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.
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 <a href=how_to_schedule.md/>setup a scheduled task</a> 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.
**Note:** 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
### Options when running the script <a name="options"></a>
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".
```YAML
-s, --showedits Show edits made to <model>_host db and db.new file(s)
-n, --noupdate Prevent DSM updating the compatible drive databases
-r, --ram Disable memory compatibility checking (DSM 7.x only)
and sets max memory to the amount of installed memory
-f, --force Force DSM to not check drive compatibility
Do not use this option unless absolutely needed
-i, --incompatible Change incompatible drives to supported
Do not use this option unless absolutely needed
-w, --wdda Disable WD Device Analytics to prevent DSM showing
a false warning for WD drives that are 3 years old
DSM 7.2.1 and later already has WDDA disabled
-p, --pcie Enable creating volumes on M2 in unknown PCIe adaptor
-e, --email Disable colored text in output scheduler emails
-S, --ssd=DRIVE Enable write_mostly on internal HDDs so DSM primarily
reads from internal SSDs or your specified drives
-S automatically sets internal SSDs as DSM preferred
--ssd=DRIVE requires the fast drive(s) as argument,
or restore as the argument to reset drives to default
--ssd=sata1 or --ssd=sata1,sata2 or --ssd=sda etc
--ssd=restore
--restore Undo all changes made by the script (except -S --ssd)
To restore all changes including write_mostly use
--restore --ssd=restore
--autoupdate=AGE Auto update script (useful when script is scheduled)
AGE is how many days old a release must be before
auto-updating. AGE must be a number: 0 or greater
-I, --ihm Update IronWolf Health Management to 2.5.1 to support
recent model IronWolf and IronWolf Pro drives.
For NAS with x86_64 CPUs only.
Also installs IHM on '22 series and newer models (untested)
--reboot Reboot after a DSM update when build number has changed
Only works if script is running from a boot-up schedule
Only needed if NVMe volume or PCIe card need a 2nd
reboot after DSM update
-h, --help Show this help message
-v, --version Show the script version
```
<p align="leftr"><img src="images/syno_hdd_db_help.png"></p>
**Notes:**
- The -f or --force option is only needed if for some reason your drives still show as unsupported in storage manager.
- Only use this option as last resort.
- Using this option will prevent data deduplication from being available, and prevent firmware updates on Synology brand drives.
- If you have some Synology drives and want to update their firmware run the script **without** --noupdate or -n then do the drive database update from Storage Manager and finally run the script again with your preferred options.
### Scheduling the script in Synology's Task Scheduler
See <a href=how_to_schedule.md/>How to schedule a script in Synology Task Manager</a>
See <a href=how_to_schedule.md/>How to schedule a script in Synology Task Scheduler</a>
### Running the script via SSH
You run the script in a shell with sudo -i or as root.
[How to enable SSH and login to DSM via SSH](https://kb.synology.com/en-global/DSM/tutorial/How_to_login_to_DSM_with_root_permission_via_SSH_Telnet)
You run the script in a shell with sudo -s or as root.
```YAML
sudo -i /path-to-script/syno_hdd_db.sh -nr
sudo -s /path-to-script/syno_hdd_db.sh -nr
```
**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
<p align="leftr"><img src="images/syno_hdd_db1.png"></p>
<p align="left"><img src="images/syno_hdd_db1.png"></p>
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.
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 -i /path-to-script/syno_hdd_db.sh -nr -showedits
sudo -s /path-to-script/syno_hdd_db.sh -nr --showedits
```
**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
<p align="leftr"><img src="images/syno_hdd_db.png"></p>
<p align="left"><img src="images/syno_hdd_db.png"></p>
### Troubleshooting
| Issue | Cause | Solution |
|-------|-------|----------|
| /usr/bin/env: ‘bash\r’: No such file or directory | File has Mac line endings! | [Download latest zip file](https://github.com/007revad/Synology_HDD_db/releases) |
| Cursor sits there doing nothing | File has Windows line endings! | [Download latest zip file](https://github.com/007revad/Synology_HDD_db/releases) |
| syntax error near unexpected token | You downloaded the webpage! | [Download latest zip file](https://github.com/007revad/Synology_HDD_db/releases) |
If you get a "No such file or directory" error check the following:
1. Make sure you downloaded the zip or rar file to a folder on your Synology (not on your computer).
2. Make sure you unpacked the zip or rar file that you downloaded and are trying to run the syno_hdd_db.sh file.
3. If the path to the script contains any spaces you need to enclose the path/scriptname in double quotes:
```YAML
sudo -s "/volume1/my scripts/syno_hdd_db.sh -n"
```
4. Set the script file as executable:
```YAML
sudo chmod +x "/volume1/scripts/syno_hdd_db.sh"
```
### vendor_ids.txt
You only need to edit syno_hdd_vendor_ids.txt if the script warns you about a missing vendor id.
If DSM doesn't know the brand of your NVMe drives they will show up in Storage Manager as Unknown brand, and Unrecognised firmware version.
<p align="left"><img src="images/unknown.png"></p>
In this case the script will show you the vendor ID and advise you to add it to the syno_hdd_vendor_ids.txt file.
<p align="left"><img src="images/vendor_ids.png"></p>
### Ironwolf Health
Ironwolf Health working with the latest version of Ironwolf Health Monitor.
<p align="left"><img src="images/ihm.png"></p>
<br>
**Credits**
### 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.
- Thanks to bartoque on the Synology subreddit for the tip on making the script download the latest release from GitHub.
- Thanks to nicolerenee for pointing out the easiest way to enable creating M.2 storage pools and volumes in Storage Manager.
- Thanks to Xeroxxx for the writemostly suggestion and their writeup here: https://www.techspark.de/speed-up-synology-dsm-with-hdd-ssd/
**Donators**
### Donators
- A big thank you to Gummibando on reddit for their donation.
Thank you to the PayPal and Buy Me a Coffee donators, GitHub sponsors and hardware donators
| | | | |
|--------------------|--------------------|----------------------|----------------------|
| | | | David Koch |
| EVOX S.R.L.S | Adam | Danny Schoonderwoert | Andrew Ward |
| nickcolea | Bruno | eColombel | LordGardenGnome |
| Dennis Struck | matthewslack | Adrien | Florian Hinhamer |
| Patrick Witon | Sonwoa1 | apbirch67 | Tim |
| Robert | Moritz Bloser | Jason Huang | James Welsh |
| robinhood1995 | Paul Fiorento | Gwystyl | Matt Hann |
| Robert Šega | Marco Brenke | Martinus Humblet | Dirk Köhler |
| KryoFlux GmbH | Frederic Gobry | bizIT Hirschberg | Alexander Ziemann |
| Chris Black Media | Brent Bertram | Carsten Schmidt | Christopher Nichols |
| Roland Thätig | Sebastian Brandt | HFB2022 | jtrouzes |
| stove | Simon Küest | Oliver Weber | Kevin Randino |
| Alex Tripp | Peter Kleissner | Dominic Lee | Daniel Boecker |
| Pat A Phillips | Craikeybaby | Jason DeCorte | Salovaara Antti Sakari |
| Jérôme MORIN | Sven Bauer | Fabien Vallet | Fabio Petgola |
| lonestar6262 | Netchoice | Fabio Cecchinato | Jacek |
| Dugan Audio LLC | MikeSx | Toregev | M. Verhoef |
| Philipp Ehmeier | Adrian Playle | Daniel Meda | Richard Wilhelm |
| Mika255 | Ralf Edelwein | Martin | Alexander Habisreitinger |
| jrn | Marcus Wojtusik | Will (war59312) | Christopher Maglio |
| Flow | Jake Morrison | tsnyder | zhangchi198 |
| leadadri | Gary Plumbridge | frogger1805 | ctrlaltdelete |
| CannotTouch | Kevin Staude | Alistair Hathaway | 8347 |
| BrattishPlaque | Chris Bunnell | dansimau | Bsih |
| Tim Trace | Michel VIEUX-PERNON | R De Jong | Rick |
| Klaus-Dieter Fahlbusch | Amarand Agasi | someone61986 | Alexander Machatschek |
| Yeong​Nuno | Joe | Torben Schreiter | Anthony McMurray |
| Abhishek | Steven Haskell | Malte Müller | Aaron Thomas |
| DENNIS BRAZIL | kunvanimals | Arnaud Costermans | dealchecker |
| Michael Carras | Alan | speedyyyyyy | Jordi Chavarria Fibla |
| Qwerty.xyz | Max | Mark Rohde | Someone |
| vaadmin | Sebastiaan Mulder | Nico Stark | Oleksandr Antonishak |
| Marcel Siemienowski | Dave Smart | dweagle79 | lingyinsam |
| Vojtech Filkorn | Craig Sadler | Po-Chia Chen | Jean-François Fruhauf |
| Sven 'ctraltdelete' | Thomas Horn | Christian | Simon Azzouni |
| Lee Booy | Bünyamin Olgun | Hartmut Heinbach | Alexander Gundermann |
| Björn Schöninger | Nico Scherer | Patrick Hoekstra | Alex Joyce |
| Marcus Ackermann | Lorenz Schmid | enil-kil | Xaver Zöllner |
| Jan Bublitz | Darren O'Connor | Charles Young | J Davis |
| Jürg Baiker | Joshua Gillispie | bizIT Hirschberg | Jordan Crawford |
| Tyler Teal | Voluntary Commerce LLC | Ez Hosting | Alec Wilhere |
| Reece Lyne | Enric Escudé Santana | Yunhao Zhang | Matthias Gerhardt |
| Darryl Harper | Mikescher | Matthias Pfaff | cpharada |
| Neil Tapp | zen1605 | Kleissner Investments | Angel Scandinavia |
| B Collins | Peter jackson | Mir Hekmat | Andrew Tapp |
| Peter Weißflog | Joseph Skup | Dirk Kurfuerst | Gareth Locke |
| Rory de Ruijter | Nathan O'Farrell | Harry Bos | Mark-Philipp Wolfger |
| Filip Kraus | John Pham | Alejandro Bribian Rix | Daniel Hofer |
| Bogdan-Stefan Rotariu | Kevin Boatswain | anschluss-org | Yemeth |
| Patrick Thomas | Manuel Marquez Corral | Evrard Franck | Chad Palmer |
| 侯​永政 | CHEN​HAN-YING | Eric Wells | Massimiliano Pesce |
| JasonEMartin | Gerrit Klussmann | Alain Aube | Robert Kraut |
| Charles-Edouard Poisnel | Oliver Busch | anonymous donors | private sponsors |

BIN
bin/dhm_tool

Binary file not shown.

12
bin/dhm_tool.txt

@ -0,0 +1,12 @@
stx_ihm from QNAP firmware, renamed dhm_tool for Synology DSM
SeaDragon_DHMr - Seagate drive utilities
Copyright (c) 2017-2021 Seagate Technology LLC and/or its Affiliates, All Rights Reserved
SeaDragon_DHMr Version: 2.5.1-2_2_3 X86_64
Build Date: Oct 3 2022
MD5 cf67c1d5006913297f85ca7f9d1795ba
SHA-1 163b384afabc491c97f3aa4ee7916601a9a680dd
SHA-256 86dd0e3c5ded507d23dfeb2ca04a2e086c97a86e2ab96dc6fdeab686a8202795
SHA-384 3d806909d445605787ceb155bc1555e01d02efe324378c9c71e6b53d91bba6bf8dbadef38dd882b43caf8dbd93eaff6c
SHA-512 a2d87d91fd4cc298708946c9a611027dce290ba17a48c65e712b5d7e72ba04c6b5303c90efeb178a8fc690241b405691a15cc88200ab3b28319198df6bd6ad16

BIN
bin/dtc

Binary file not shown.

8
bin/dtc_info.txt

@ -0,0 +1,8 @@
MD5 01381dabbe86e13a2f4a8017b5552918
SHA-1 f24a4c06b4865a5948eddc2f43fcdb7700398c7d
SHA-256 14f7f87a5822050eab7c30a064912a6efe99f49bf6b896bbb38c2ba003803e78
Vhash 4885c57da971db5c59998566ee02855f
SSDEEP 1536:ZJ048w/2Iaosz0SlWcCyeyudm5gupvatDVF4Utc3Lyk+pboAZ4NMMy6MajiRTrbc:0hfosz0j0ehm57vaTDc3Lmo/iRTrM4q
TLSH T13EE33D02F3648C7DD4F85B34469A82B7A7B4F8455232171F7B4097192F86F688F2A9E3
https://www.virustotal.com/gui/file/14f7f87a5822050eab7c30a064912a6efe99f49bf6b896bbb38c2ba003803e78/detection

2
bin/dtc_source.txt

@ -0,0 +1,2 @@
dtc-1.6.1 source code - Author David Gibson
https://git.kernel.org/pub/scm/utils/dtc/dtc.git

BIN
images/ihm.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
images/schedule3-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/syno_hdd_db_help2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/unknown.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
images/update-now-disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/update-now-working.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
images/vendor_ids.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

183
my-other-scripts.md

@ -0,0 +1,183 @@
## All my scripts, tools and guides
<img src="https://hitscounter.dev/api/hit?url=https%3A%2F%2F007revad.github.io%2F&label=Visitors&icon=github&color=%23198754&message=&style=flat&tz=UTC">
#### Contents
- [Plex](#plex)
- [Synology docker](#synology-docker)
- [Synology recovery](#synology-recovery)
- [Other Synology scripts](#other-synology-scripts)
- [Synology hardware restrictions](#synology-hardware-restrictions)
- [2025 plus models](#2025-plus-models)
- [How To Guides](#how-to-guides)
- [Synology dev](#synology-dev)
***
### Plex
- **<a href="https://github.com/007revad/Synology_Plex_Backup">Synology_Plex_Backup</a>**
- A script to backup Plex to a tgz file foror DSM 7 and DSM 6.
- Works for Plex Synology package and Plex in docker.
- **<a href="https://github.com/007revad/Asustor_Plex_Backup">Asustor_Plex_Backup</a>**
- Backup your Asustor's Plex Media Server settings and database.
- **<a href="https://github.com/007revad/Linux_Plex_Backup">Linux_Plex_Backup</a>**
- Backup your Linux Plex Media Server's settings and database.
- **<a href="https://github.com/007revad/Plex_Server_Sync">Plex_Server_Sync</a>**
- Sync your main Plex server database & metadata to a backup Plex server.
- Works for Synology, Asustor, Linux and supports Plex package or Plex in docker.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology docker
- **<a href="https://github.com/007revad/Synology_Docker_Export">Synology_Docker_export</a>**
- Export all Synology Container Manager or Docker containers' settings as json files to your docker shared folder.
- **<a href="https://github.com/007revad/Synology_ContainerManager_IPv6">Synology_ContainerManager_IPv6</a>**
- Enable IPv6 for Container Manager's bridge network.
- **<a href="https://github.com/007revad/ContainerManager_for_all_armv8">ContainerManager_for_all_armv8</a>**
- Script to install Container Manager on a RS819, DS119j, DS418, DS418j, DS218, DS218play or DS118.
- **<a href="https://github.com/007revad/Docker_Autocompose">Docker_Autocompose</a>**
- Create .yml files from your docker existing containers.
- **<a href="https://github.com/007revad/Synology_docker_cleanup">Synology_docker_cleanup</a>**
- Remove orphan docker btrfs subvolumes and images in Synology DSM 7 and DSM 6.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology recovery
- **<a href="https://github.com/007revad/Synology_DSM_reinstall">Synology_DSM_reinstall</a>**
- Easily re-install the same DSM version without losing any data or settings.
- **<a href="https://github.com/007revad/Synology_Recover_Data">Synology_Recover_Data</a>**
- A script to make it easy to recover your data from your Synology's drives using a computer.
- **<a href="https://github.com/007revad/Synology_clear_drive_error">Synology clear drive error</a>**
- Clear drive critical errors so DSM will let you use the drive.
- **<a href="https://github.com/007revad/Synology_DSM_Telnet_Password">Synology_DSM_Telnet_Password</a>**
- Synology DSM Recovery Telnet Password of the Day generator.
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno_DSM_Extractor_GUI</a>**
- Windows GUI for extracting Synology DSM 7 pat files and spk package files.
- **<a href="https://github.com/007revad/Synoboot_backup">Synoboot_backup</a>**
- Back up synoboot after each DSM update so you can recover from a corrupt USBDOM.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Other Synology scripts
- **<a href="https://github.com/007revad/Synology_app_mover">Synology_app_mover</a>**
- Easily move Synology packages from one volume to another volume.
- **<a href="https://github.com/007revad/Video_Station_for_DSM_722">Video_Station_for_DSM_722</a>**
- Script to install Video Station in DSM 7.2.2
- **<a href="https://github.com/007revad/SS_Motion_Detection">SS_Motion_Detection</a>**
- Installs previous Surveillance Station and Advanced Media Extensions versions so motion detection and HEVC are supported.
- **<a href="https://github.com/007revad/Synology_Config_Backup">Synology_Config_Backup</a>**
- Backup and export your Synology DSM configuration.
- **<a href="https://github.com/007revad/Synology_CPU_temperature">Synology_CPU_temperature</a>**
- Get and log Synology NAS CPU temperature via SSH.
- **<a href="https://github.com/007revad/Synology_SMART_info">Synology_SMART_info</a>**
- Show Synology smart test progress or smart health and attributes.
- **<a href="https://github.com/007revad/Synology_Cleanup_Coredumps">Synology_Cleanup_Coredumps</a>**
- Cleanup memory core dumps from crashed processes.
- **<a href="https://github.com/007revad/Synology_toggle_reset_button">Synology_toggle_reset_button</a>**
- Script to disable or enable the reset button and show current setting.
- **<a href="https://github.com/007revad/Synology_Download_Station_Chrome_Extension">Synology_Download_Station_Chrome_Extension</a>**
- Download Station Chrome Extension.
- **<a href="https://github.com/007revad/Seagate_lowCurrentSpinup">Seagate_lowCurrentSpinup</a>**
- This script avoids the need to buy and install a higher wattage power supply when using multiple large Seagate SATA HDDs.
- **<a href="https://github.com/007revad/Synology_created_date">Synology_created_date</a>**
- Script to show you the created year and month of your Synology NAS or expansion unit.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology hardware restrictions
- **<a href="https://github.com/007revad/Synology_HDD_db">Synology_HDD_db</a>**
- Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your Synology M.2 PCIe card and Expansion Unit databases.
- **<a href="https://github.com/007revad/Synology_enable_M2_volume">Synology_enable_M2_volume</a>**
- Enable creating volumes with non-Synology M.2 drives.
- Enable Health Info for non-Synology NVMe drives (not in DSM 7.2.1 or later).
- **<a href="https://github.com/007revad/Synology_M2_volume">Synology_M2_volume</a>**
- Easily create an M.2 volume on Synology NAS.
- **<a href="https://github.com/007revad/Synology_enable_M2_card">Synology_enable_M2_card</a>**
- Enable Synology M.2 PCIe cards in Synology NAS that don't officially support them.
- **<a href="https://github.com/007revad/Synology_enable_eunit">Synology_enable_eunit</a>**
- Enable an unsupported Synology eSATA Expansion Unit models.
- **<a href="https://github.com/007revad/Synology_enable_Deduplication">Synology_enable_Deduplication</a>**
- Enable deduplication with non-Synology SSDs and unsupported NAS models.
- **<a href="https://github.com/007revad/Synology_SHR_switch">Synology_SHR_switch</a>**
- Easily switch between SHR and RAID Groups, or enable RAID F1.
- **<a href="https://github.com/007revad/Synology_enable_sequential_IO">Synology_enable_sequential_IO</a>**
- Enables sequential I/O for your SSD caches, like DSM 6 had.
- **<a href="https://github.com/007revad/Synology_Information_Wiki">Synology_Information_Wiki</a>**
- Information about Synology hardware.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### 2025 plus models
- **<a href="https://github.com/007revad/Transcode_for_x25">Transcode_for_x25</a>**
- Installs the modules needed for Plex or Jellyfin hardware transcoding in DS425+ and DS225+.
- **<a href="https://github.com/007revad/Synology_HDD_db/blob/main/2025_plus_models.md">2025 series or later Plus models</a>**
- Unverified 3rd party drive limitations and unofficial solutions.
- **<a href="https://github.com/007revad/Synology_HDD_db/blob/main/2025_plus_models.md#setting-up-a-new-2025-or-later-plus-model-with-only-unverified-hdds">Setup with only 3rd party drives</a>**
- Setting up a new 2025 or later plus model with only unverified HDDs.
- **<a href="https://github.com/007revad/Synology_HDD_db/blob/main/2025_plus_models.md#deleting-and-recreating-your-storage-pool-on-unverified-hdds">Recreating storage pool on migrated drives</a>**
- Deleting and recreating your storage pool on unverified HDDs.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### How To Guides
- **<a href="https://github.com/007revad/Synology_SSH_key_setup">Synology_SSH_key_setup</a>**
- How to setup SSH key authentication for your Synology.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology dev
- **<a href="https://github.com/007revad/Download_Synology_Archive">Download_Synology_Archive</a>**
- Download all or part of the Synology archive.
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno_DSM_Extractor_GUI</a>**
- Windows GUI for extracting Synology DSM 7 pat files and spk package files.
- **<a href="https://github.com/007revad/ScriptNotify">ScriptNotify</a>**
- DSM 7 package to allow your scripts to send DSM notifications.
- **<a href="https://github.com/007revad/DTC_GUI_for_Windows">DTC_GUI_for_Windows</a>**
- GUI for DTC.exe for Windows.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)

2743
syno_hdd_db.sh

File diff suppressed because it is too large

411
syno_hdd_shutdown.sh

@ -0,0 +1,411 @@
#!/usr/bin/env bash
# shellcheck disable=SC2002,2207
#------------------------------------------------------------------------------------
# Companion script for syno_hdd_db
# Schedule companion script to run as root at shut-down
#
# https://www.synology-forum.de/threads/neue-version-7-3-2-86009.140586/post-1265124
#------------------------------------------------------------------------------------
# TODO
# Check running on DSM version that needs it
# What to do if @database is on the NVMe volume?
scriptver="v1.0.0"
script=Synology_HDD_shutdown
#repo="007revad/Synology_HDD_db"
scriptname=syno_hdd_shutdown
ding(){
printf \\a
}
# Save options used for getopt
args=("$@")
if [[ $1 == "--trace" ]] || [[ $1 == "-t" ]]; then
trace="yes"
fi
# Check script is running as root
if [[ $( whoami ) != "root" ]]; then
ding
echo -e "ERROR This script must be run as sudo or root!"
exit 1 # Not running as sudo or root
fi
# Get NAS model
model=$(cat /proc/sys/kernel/syno_hw_version)
#modelname="$model"
# Show script version
#echo -e "$script $scriptver\ngithub.com/$repo\n"
echo "$script $scriptver"
# Get DSM full version
productversion=$(synogetkeyvalue /etc.defaults/VERSION productversion)
buildphase=$(synogetkeyvalue /etc.defaults/VERSION buildphase)
buildnumber=$(synogetkeyvalue /etc.defaults/VERSION buildnumber)
smallfixnumber=$(synogetkeyvalue /etc.defaults/VERSION smallfixnumber)
# Get CPU arch and platform_name
arch="$(uname -m)"
platform_name=$(synogetkeyvalue /etc.defaults/synoinfo.conf platform_name)
# Show DSM full version and model
if [[ $buildphase == GM ]]; then buildphase=""; fi
if [[ $smallfixnumber -gt "0" ]]; then smallfix="-$smallfixnumber"; fi
echo "$model DSM $productversion-$buildnumber$smallfix $buildphase"
# Show CPU arch and platform_name
echo "CPU $platform_name $arch"
# Show options used
if [[ ${#args[@]} -gt "0" ]]; then
echo -e "Using options: ${args[*]}\n"
else
echo ""
fi
# Check Synology has synonvme
if ! which synonvme >/dev/null; then
ding
echo "${model} does not have synonvme!"
exit 2 # NAS model does support NVMe
fi
# Check Synology has libsynonvme.so.1
if [[ ! -e /usr/lib/libsynonvme.so ]]; then
ding
echo "${model} does not have libsynonvme.so.1!"
exit 2 # NAS model does support NVMe
fi
#set -x
# Get script location
# https://stackoverflow.com/questions/59895/
source=${BASH_SOURCE[0]}
while [ -L "$source" ]; do # Resolve $source until the file is no longer a symlink
scriptpath=$( cd -P "$( dirname "$source" )" >/dev/null 2>&1 && pwd )
source=$(readlink "$source")
# If $source was a relative symlink, we need to resolve it
# relative to the path where the symlink file was located
[[ $source != /* ]] && source=$scriptpath/$source
done
scriptpath=$( cd -P "$( dirname "$source" )" >/dev/null 2>&1 && pwd )
scriptfile=$( basename -- "$source" )
echo "Running from: ${scriptpath}/$scriptfile"
# Warn if script located on M.2 drive
scriptvol=$(echo "$scriptpath" | cut -d"/" -f2)
vg=$(lvdisplay | grep /volume_"${scriptvol#volume}" | cut -d"/" -f3)
md=$(pvdisplay | grep -B 1 -E '[ ]'"$vg" | grep /dev/ | cut -d"/" -f3)
if cat /proc/mdstat | grep "$md" | grep nvme >/dev/null; then
ding
echo -e "WARNING Don't store this script on an NVMe volume!"
exit 3 # Script is stored on NVMe volume
fi
shutdown_log="${scriptpath}/${scriptname}.log"
# Delete old shutdown_log
if [[ -f "$shutdown_log" ]]; then
rm "$shutdown_log"
fi
progbar(){
# $1 is pid of process
# $2 is string to echo
string="$2"
local dots
local progress
dots=""
while [[ -d /proc/$1 ]]; do
dots="${dots}."
progress="$dots"
if [[ ${#dots} -gt "10" ]]; then
dots=""
progress=" "
fi
echo -ne " ${2}$progress\r"; /usr/bin/sleep 0.3
done
}
progstatus(){
# $1 is return status of process
# $2 is string to echo
# $3 line number function was called from
local tracestring
local pad
tracestring="${FUNCNAME[0]} called from ${FUNCNAME[1]} $3"
pad=$(printf -- ' %.0s' {1..80})
[ "$trace" == "yes" ] && printf '%.*s' 80 "${tracestring}${pad}" && echo ""
if [[ $1 == "0" ]]; then
echo -e "$2 "
else
ding
echo -e "Line ${LINENO}: ERROR $2 failed!"
echo "$tracestring ($scriptver)"
if [[ $exitonerror != "no" ]]; then
exit 1 # Skip exit if exitonerror != no
fi
fi
exitonerror=""
#echo "return: $1" # debug
}
package_status(){
# $1 is package name
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
# local code
synopkg status "${1}" >/dev/null
code="$?"
# DSM 7.2 0 = started, 17 = stopped, 255 = not_installed, 150 = broken
# DSM 6 to 7.1 0 = started, 3 = stopped, 4 = not_installed, 150 = broken
if [[ $code == "0" ]]; then
#echo "$1 is started" # debug
return 0
elif [[ $code == "17" ]] || [[ $code == "3" ]]; then
#echo "$1 is stopped" # debug
return 1
elif [[ $code == "255" ]] || [[ $code == "4" ]]; then
#echo "$1 is not installed" # debug
return 255
elif [[ $code == "150" ]]; then
#echo "$1 is broken" # debug
return 150
else
return "$code"
fi
}
package_is_running(){
# $1 is package name
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
synopkg is_onoff "${1}" >/dev/null
code="$?"
return "$code"
}
wait_status(){
# Wait for package to finish stopping or starting
# $1 is package
# $2 is start or stop
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
local num
if [[ $2 == "start" ]]; then
state="0"
elif [[ $2 == "stop" ]]; then
state="1"
fi
if [[ $state == "0" ]] || [[ $state == "1" ]]; then
num="0"
package_status "$1"
while [[ $? != "$state" ]]; do
sleep 1
num=$((num +1))
if [[ $num -gt "20" ]]; then
break
fi
package_status "$1"
done
fi
}
package_stop(){
# $1 is package name
# $2 is package display name
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
# Docker can take 12 minutes to stop 70 containers
timeout 30m synopkg stop "$1" >/dev/null &
pid=$!
string="Stopping ${2}"
progbar "$pid" "$string"
wait "$pid"
progstatus "$?" "$string" "line ${LINENO}"
# Allow package processes to finish stopping
wait_status "$1" stop &
pid=$!
string="Waiting for ${2} to stop"
progbar "$pid" "$string"
wait "$pid"
progstatus "$?" "$string" "line ${LINENO}"
}
stop_packages(){
# Check package is running
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
if package_is_running "$pkg"; then
# Stop package
package_stop "$pkg" "$pkg_name"
# Check package stopped
if package_is_running "$pkg"; then
#stop_pkg_fail="yes"
ding
echo -e "Line ${LINENO}: ERROR Failed to stop ${pkg_name}!"
# echo "${pkg_name} status $code"
#process_error="yes"
return 1
else
echo "$pkg" >> "$shutdown_log"
#stop_pkg_fail=""
fi
if [[ $pkg == "ContainerManager" ]] || [[ $pkg == "Docker" ]]; then
# Stop containerd-shim
killall containerd-shim >/dev/null 2>&1
fi
# else
# skip_start="yes"
fi
}
skip_dev_tools(){
# $1 is $package
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
local skip1
local skip2
skip1="$(synogetkeyvalue "/var/packages/${package}/INFO" startable)"
skip2="$(synogetkeyvalue "/var/packages/${package}/INFO" ctl_stop)"
if [[ $skip1 == "no" ]] || [[ $skip2 == "no" ]]; then
return 0
else
return 1
fi
}
# Get list of volumes with shared folders
readarray -t shares_array < <(synoshare --enum | tail -n +5)
for share in "${shares_array[@]}"; do
#echo "share: $share" # debug ################################################
if [[ $buildnumber -gt "64570" ]]; then
# DSM 7.2.1 and later
# synoshare --get-real-path is case insensitive
path="$(synoshare --get-real-path "$share" | cut -d"/" -f2)"
else
# DSM 7.2 and earlier
# synoshare --getmap is case insensitive
path="$(synoshare --getmap "$share" | grep volume | cut -d"[" -f2 | cut -d"]" -f1)"
# I could also have used:
# web_pkg_path=$(/usr/syno/sbin/synoshare --get "$share" | tr '[]' '\n' | sed -n "9p")
fi
# Ignore external USB and eSATA volumes
if echo "$path" | grep -q -E 'volume[0-9]'; then
volumes_array+=("$path")
fi
done
#echo -e "\nvolumes_array:" # debug ##################
#for v in "${volumes_array[@]}"; do echo "$v"; done # debug ##################
#echo -e "\n" # debug ##################
# Sort array to remove duplicates
IFS=$'\n'
volumes_array_sorted=($(sort -u <<<"${volumes_array[*]}"))
unset IFS
#echo -e "\nvolumes_array_sorted:" # debug ###########
#for v in "${volumes_array_sorted[@]}"; do echo "$v"; done # debug ###########
#echo -e "\n" # debug ###########
#exit
# Check there is an NVMe volume
nvme_vols=()
for vol in "${volumes_array_sorted[@]}"; do
#echo "$vol" # debug #########################################################
vg=$(lvdisplay | grep /volume_"${vol#volume}" | cut -d"/" -f3)
md=$(pvdisplay | grep -B 1 -E '[ ]'"$vg" | grep /dev/ | cut -d"/" -f3)
if cat /proc/mdstat | grep "$md" | grep nvme >/dev/null; then
nvme_vols_qty=$((nvme_vols_qty +1))
nvme_vols+=("$vol")
fi
done
if [[ $nvme_vols_qty -lt "0" ]]; then
ding
echo -e "No NVMe volumes found."
exit 4 # Script not needed
fi
#echo "nvme_vols_qty $nvme_vols_qty" # debug ######################
#for v in "${nvme_vols[@]}"; do echo "$v"; done # debug ######################
#echo "" # debug ######################
#exit
# Get list of packages installed on NVMe volume
if ! cd /var/packages; then
ding
echo -e "Failed to cd to /var/packages!"
exit 5 # Failed to cd to /var/packages
fi
declare -A package_names
declare -A package_names_rev
#package_infos=( )
while IFS= read -r -d '' link && IFS= read -r -d '' target; do
if [[ ${link##*/} == "target" ]] && echo "$target" | grep -q 'volume'; then
# Check symlink target exists
if [[ -a "/var/packages${link#.}" ]] ; then
# Skip broken packages with no INFO file
package="$(printf %s "$link" | cut -d'/' -f2 )"
if [[ -f "/var/packages/${package}/INFO" ]]; then
package_volume="$(printf %s "$target" | cut -d'/' -f1,2 )"
#echo "package_volume: $package_volume" # debug ###############################
# Check if package is on NVMe volume
# shellcheck disable=SC2076
if [[ "/${nvme_vols[*]}" =~ "$package_volume" ]]; then
package_name="$(synogetkeyvalue "/var/packages/${package}/INFO" displayname)"
if [[ -z "$package_name" ]]; then
package_name="$(synogetkeyvalue "/var/packages/${package}/INFO" package)"
fi
#echo "package_name: $package_name" # debug ###############################
# Skip packages that are dev tools with no data
if ! skip_dev_tools "$package"; then
#package_infos+=("${package_volume}|${package_name}")
package_names["${package_name}"]="${package}"
package_names_rev["${package}"]="${package_name}"
fi
fi
fi
fi
fi
done < <(find . -maxdepth 2 -type l -printf '%p\0%l\0')
#echo -e "\npackage_infos:"
#for p in "${package_infos[@]}"; do echo "$p"; done
#echo -e "\npackage_names:"
#for p in "${package_names[@]}"; do echo "$p"; done
#echo -e "\npackage_names_rev:"
#for p in "${package_names_rev[@]}"; do echo "$p"; done
# Loop through pkgs_sorted array and process package
for pkg in "${package_names[@]}"; do
pkg_name="${package_names_rev["$pkg"]}"
#process_error=""
stop_packages
#echo "stop_package: $pkg" # debug ############################################
done

24
syno_hdd_vendor_ids.txt

@ -0,0 +1,24 @@
# You can add your drive's vendor id and vendor name here.
#
# Only edit this file if the script warns you about a missing vendor id.
0x025e="Solidigm"
0x05dc="Lexar"
0x0ed1="aigo"
0x10ec="TEAMGROUP"
0x137e="Patriot"
0x1458="Gigabyte"
0x1462="MSI"
0x196e="PNY"
0x1987="Phison"
0x1b1c="Corsair"
0x1bdc="Apacer"
0x1c5c="SK Hynix"
0x1cc4="UMIS"
0x1cfa="Corsair"
0x1d79="Transcend"
0x1dbe="ADATA"
0x1e0f="KIOXIA"
0x1e49="ZHITAI"
0x1e4b="FIKWOT"
0x1f40="Netac"
Loading…
Cancel
Save