My external HDD is written constantly, making constant noise

Hi,

I have an external HDD plugged in my raspberry, EXT4 formatted and mounted in /mnt.

The drive makes a constant 24/7 noise, I can hear very loudly the head of the drive writing, constantly. The IDLE Spindown is set to 5 minutes, but it doesn’t seem to work as it continues to make a lot of noise after 5 mins.

I have a lot of apps on my Raspberry, but normally none of them is supposed to use the disk constantly. But I guess one is doing it, I see no other explaination.

Is there a way to see which one of my apps is using my external HDD that much ?

Thanks in advance for any answer, have a great day.

well you could use htop so see which processes are running in generell. As well you could go to stop app by app and see how it behave.

Or iotop to see processes that do disk I/O explicitly:

apt install iotop
iotop -Po

Options -Po used to have a little cleaner content:
-P: Shows only processes instead of every thread of every process
-o: Shows only processes that actually do disk I/O

But it does not differentiate between disks.

Hi, thanks a lot for your advice for iotop.

I just installed it and tried to use the argument -Po as you said. It works correctly, but I would have some questions to make it display IO as I would like.
With just -Po, it shows IO but only at the moment when the command is executed. I would like it to refresh continuously, because sometimes I can see some apps writing but it’s very fast. I would like it to “log” the apps that are writing, instead of making them disappear from the list if they have finished to write.

Do you know how I could do that ?
Thanks in advance for any answer

iotop -aPo

-a: Accumulates reads and writes

Generally, all tools have a help command to show usage and options info:

iotop -h

-h or --help is understood by nearly all GNU/Linux/UNIX commands :slight_smile:.

Another good resource is the man pages. Debian has an online archive for them for all their packages: https://manpages.debian.org/iotop
Use this URL and append any console command instead of iotop and in 99% of cases you’ll get a nice complete man page :slight_smile:.

Thanks, I now get a clearer view of what my Raspberry does with my disks :

85 be/3 root 0.00 B 56.00 K 0.00 % 0.66 % [jbd2/mmcblk0p2-]
28798 be/4 ombi 0.00 B 8.00 K 0.00 % 0.00 % Ombi --storage /etc/Ombi/

Those are basically 99% of my IO on my disk. Ombi is not an issue, as /etc/Ombi is my internal SD card.

But the problem is my 1st line. What is jbd2/mmcblk0p2- ?
I searched a bit on it, and I stumbled upon this :
https://raspberrypi.stackexchange.com/questions/5516/why-raspbmc-constantly-writes-or-reads-from-external-disk
https://unix.stackexchange.com/questions/602560/find-out-the-cause-for-continous-disk-io-on-raspberry-pi-on-arch
https://www.linuxquestions.org/questions/linux-software-2/jbd2-sda1-8-what-exactly-is-this-process-that-keeps-running-every-few-seconds-788810/

That REALLY looks like my issue. But I couldn’t find a clear method on how to fix it

jbd2/mmcblk0p2 is the root filesystem’s cache sync. ext4 by default has a filesystem cache enabled, so when smaller writes are done, those are not done directly physically to the disk directly, but hold in cache until accumulated to a certain amount, at least a block size (4 KiB) or so. This is to reduce disk write overhead. When major writes are done from the cache, it means that the cache is working as intended and writes are mostly smaller ones, which is pretty normal in case of a database or when daemons are logging to files etc. The cache also reduces the frequency of writes by this.

So have a look at the other processes. Btw, using the arrow keys, you can sort the list in iotop differently. By default its sorted by current I/O, not accumulated writes.