Western Digital 2.5 4 TB USB 3.0 hdd
Raspberry pi 3 with Raspbian Buster / samba version 4.9.5-Debian
Fire TV 4k with Kodi 18.5
Long post warning, there is a TLDR at the bottom!
I always used a raspberry pi (since rpi1 days), to stream media files to kodi without a problem (files around 3 to 18 Mbps of video bitrate). The rpi3 runs smb, pymedusa and transmission-daemon. The problem started out nowhere, with no apparent changes to my setup.
Around 3 weeks ago, I started to get random buffering problems (around 5-10 seconds) when watching video on Kodi, any type of file, small 500-800 MB files (3mbps bitrate) files or big 15 GB files with higher bitrate. I never had this problem before. This happens sometimes only
I first assumed it could be a Kodi problem, so I started messing with buffering settings with no luck (Never had to do this). I also updated to latest version.
I had installed an old FireTV that I have meaning to upgrade to latest one (4k) for a while, So I did that and installed and configured Kodi from scratch. Same problem
I also tried to stream 2 small files at the same time, one using kodi on the firetv, one using vlc on a windows 10 laptop, they both buffered at exact same time.
So I moved to network problems, I did some speed tests:
IPERF Fire TV 4k (Wireless) <---- ~130 Mbps ----> win10 desktop (Wired)
IPERF Fire TV 4k (Wireless) <---- ~95 Mbps ----> rpi3 (Wired)
IPERF Win10 Desktop (Wired) <---- ~95 Mbps ----> rpi3 (Wired)
SMB/CIFS File Transfer Tests:
Fire TV 4k (Wireless) <---- ~65 Mbps--------rpi3 (Wired)
Fire TV 4k (Wireless) <---- ~104 Mbps------Win10 Desktop (Wired)
Win10 Desktop (Wired) <---- ~85 Mbps-----rpi3 (Wired)
Win10 Laptop (Wireless) <---- ~85 Mbps----rpi3 (Wired)
So everything in the network looks good , keep in mind I get buffering problems trying to stream a small 2-3 Mbps video bitrate file (Around 500-800 MB in size).
So I copied some of the video files to my Desktop PC and shared them via smb/cifs in windows 10, added the share in kodi, and buffering problems disappeared, any type of file streamed perfectly. So this led me to believe the problem was the raspberry pi itself.
So the first thing I did was turn off transmission, pymedusa, etc except samba, the problem persisted. I also was doing some testing with docker and unifi controller container and also homeassistant with it, I stopped everything.
At the time I was running raspbian stretch, and I think the problem started after doing an apt update; apt dist-upgrade, and rebooting some time later.
I backed up everything, grabbed a new sd card and installed latest raspbian buster on it, configured the external ext4 drive mount and samba only. The problem persisted: random buffering on any type of file. I also configured NFS on the pi and kodi and the problem was the same.
I used another new sd card and installed latest openmediavault raspberry pi version on it, and setup the samba share. The problem persisted.
So I went back the sd card with the new buster install on it, and started doing some more testing:
-Started bmon on the raspberry pi and started playing a small file on the FireTV/Kodi, I could see the sudden drop on speed on the graph when the 5-10 seconds buffering started.
-Started playing a small file on the FireTV/Kodi and also at the same time started a throttled (So I don’t use up all the bandwidth) smb copy using robocopy, from the raspberry pi to my desktop pc. When buffering started, I could see the speed drop on bmon on the pi, and also in the copy I was doing to my wired desktop (was also looking at Ethernet graph on the desktop).
-Copied a video file to the internal sd card of the pi, and started again playing a file on the FireTV from the usb hard drive, and at the same time started a copy from the internal sd to my desktop pc. When the buffering started I could see the drop in speed in the stream, but not in the copy to the desktop.
So, I guess it’s a problem reading from the usb hdd and not the Ethernet port of the raspberry pi.
I plugged a 32gb flash drive , formatted as ext4 , moved some files there and shared them via samba, and I played the files from it perfectly, no buffering, no slowdown, anything.
So I’m 99% sure it’s a problem with usb hard drive
I ran fsck on the disk, smarttools, everything I could think, and it reports no errors:
Code: Select all
pi@raspberrypi3:~ $ sudo smartctl -a /dev/sdc -d sat smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.75-v7+] (local build) Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Western Digital Elements / My Passport (USB, AF) Device Model: WDC WD40NMZW-11GX6S1 Serial Number: WD-WX41D38KZPD2 LU WWN Device Id: 5 0014ee 00482c3cf Firmware Version: 01.01A01 User Capacity: 4,000,787,030,016 bytes [4.00 TB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 5400 rpm Form Factor: 2.5 inches Device is: In smartctl database [for details use: -P show] ATA Version is: ACS-3 (minor revision not indicated) SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Mon Dec 9 12:43:38 2019 -03 SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x00) Offline data collection activity was never started. Auto Offline Data Collection: Disabled. Self-test execution status: ( 0) The previous self-test routine completed without error or no self-test has ever been run. Total time to complete Offline data collection: (19440) seconds. Offline data collection capabilities: (0x1b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. SMART capabilities: (0x0003) Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01) Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 700) minutes. SCT capabilities: (0x30b5) SCT Status supported. SCT Feature Control supported. SCT Data Table supported. SMART Attributes Data Structure revision number: 16 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 0 3 Spin_Up_Time 0x0027 253 253 021 Pre-fail Always - 3316 4 Start_Stop_Count 0x0032 099 099 000 Old_age Always - 1750 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0 9 Power_On_Hours 0x0032 083 083 000 Old_age Always - 12430 10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0 11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 137 192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 127 193 Load_Cycle_Count 0x0032 097 097 000 Old_age Always - 311218 194 Temperature_Celsius 0x0022 102 096 000 Old_age Always - 50 196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0030 100 253 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0 200 Multi_Zone_Error_Rate 0x0008 100 253 000 Old_age Offline - 0 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t] Selective Self-tests/Logging not supported
I also ran “dstat -D sdb” when the buffering happens, you can see the slowdown on the read column:
Note: at the time I ran this, sdb was 4tb usb drive
I ran hdparm on the 4tb disk and the 32gb usb drive, with similar results:
Western Digital 4TB 2.5 Hard Drive:
Code: Select all
pi@raspberrypi3:~ $ sudo hdparm -tT /dev/sdc /dev/sdc: Timing cached reads: 1362 MB in 2.00 seconds = 680.98 MB/sec Timing buffered disk reads: 80 MB in 3.03 seconds = 26.44 MB/sec
Samsung 32 GB usb flash drive:
Code: Select all
pi@raspberrypi3:~ $ sudo hdparm -tT /dev/sdb /dev/sdb: Timing cached reads: 1264 MB in 2.00 seconds = 631.71 MB/sec SG_IO: bad/missing sense data, sb: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Timing buffered disk reads: 82 MB in 3.04 seconds = 26.96 MB/sec
Dmesg HDD output (caching mode page error seems to be normal after googling it):
I have no idea what to do next, or what could be causing the random slowdown reading from the hard drive. Physical problem with the drive?, but it seems there is no problem with it.
TLDR: Having problems reading files over network, it randomly slowdowns and causes buffering on the media player, after months of everything working perfectly it suddenly happened. I think it’s a problem with USB Hard Drive itself, I plugged a flash drive, shared it and it didn’t present any problems. But is seems the hard drive is in perfect condition.