[GH-ISSUE #368] get_size_gb() calculation error for 20GB HDDs #839

Closed
opened 2026-03-12 17:23:49 +03:00 by kerem · 2 comments
Owner

Originally created by @planetrocky on GitHub (Oct 19, 2024).
Original GitHub issue: https://github.com/007revad/Synology_HDD_db/issues/368

$ sudo synodisk --info /dev/sdia6  | grep 'Total capacity'
>> Total capacity: 18627.00 GB
$ sudo synodisk --info /dev/sdia6  | grep 'Total capacity' | awk '{print $4 * 1.0737}'
19999.8

syno_hdd_db.sh writes 19999 to the drive database:

{
    "disk_compatbility_info": {
        "HDD": {
            "default": {
                "size_gb":  19999
            }
        }
    }
}

GiB to GB:

2^30 / 1e9 = 1.073741824

$ sudo synodisk --info /dev/sdia6  | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}'
20000

Line 897 of syno_hdd_db.sh update get_size_gb() function for correct calculation. Tested with all my HDDs and SSDs (smallest 1GB, largest 20GB):

get_size_gb(){ 
    # $1 is /sys/block/sata1 or /sys/block/nvme0n1 etc
    local disk_size_gb
    disk_size_gb=$(synodisk --info /dev/"$(basename -- "$1")" | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}')
    echo "$disk_size_gb"
}
Originally created by @planetrocky on GitHub (Oct 19, 2024). Original GitHub issue: https://github.com/007revad/Synology_HDD_db/issues/368 ``` sh $ sudo synodisk --info /dev/sdia6 | grep 'Total capacity' >> Total capacity: 18627.00 GB $ sudo synodisk --info /dev/sdia6 | grep 'Total capacity' | awk '{print $4 * 1.0737}' 19999.8 ``` `syno_hdd_db.sh` writes *19999* to the drive database: ``` json { "disk_compatbility_info": { "HDD": { "default": { "size_gb": 19999 } } } } ``` GiB to GB: 2^30 / 1e9 = 1.073741824 ``` sh $ sudo synodisk --info /dev/sdia6 | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}' 20000 ``` Line 897 of `syno_hdd_db.sh` update `get_size_gb()` function for correct calculation. Tested with all my HDDs and SSDs (smallest 1GB, largest 20GB): ``` sh get_size_gb(){ # $1 is /sys/block/sata1 or /sys/block/nvme0n1 etc local disk_size_gb disk_size_gb=$(synodisk --info /dev/"$(basename -- "$1")" | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}') echo "$disk_size_gb" } ```
kerem closed this issue 2026-03-12 17:23:54 +03:00
Author
Owner

@planetrocky commented on GitHub (Oct 19, 2024):

#369

<!-- gh-comment-id:2424251897 --> @planetrocky commented on GitHub (Oct 19, 2024): #369
Author
Owner

@007revad commented on GitHub (Oct 19, 2024):

Thanks. I like when people find a bug and provide the solution :)

<!-- gh-comment-id:2424263599 --> @007revad commented on GitHub (Oct 19, 2024): Thanks. I like when people find a bug and provide the solution :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Synology_HDD_db#839
No description provided.