Wednesday, May 1, 2024
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 3996  / 3 Years ago, sat, august 21, 2021, 2:27:38

I've an external 500GB HDD connected to my Laptop which runs Ubuntu 12.04. I've formatted the external drive with one ext4 partition which spans the entire disk.



My problem is that the disk makes noise every second, because writes occur to it. I'm not actively writing any file to the disk or use the disk otherwise. It's just mounted and should be idle.



Using iotop, I can see that with the disk plugged in, some jbd2 process writes to the disk. This jbd2 process does not do anything if the disk is not plugged in. The noise also immediately stops if I unmont the drive, but keep it plugged in.



iotop:



Total DISK READ:       0.00 B/s | Total DISK WRITE:    1838.15 K/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
3727 be/3 root 0.00 B/s 0.00 B/s 0.00 % 0.15 % [jbd2/sdb1-8]
1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init
2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]
3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0]
...


First of all, the noise drives me crazy. I work in a quiet environment and this allbeit very low noise is so disturbing somehow.



Second, I think that these continuous writes to the disk might cause it's lifetime to degrade. This would be especially important for SSD drives, where the noise isn't present, but the same behavior can be observed. Moreover, I think that writes to the disk should not be necessary, since no user process is accessing the disk and the operating system surely does not need to access an external HDD for its operation.



What causes these write accesses and how to stop them?


More From » partitioning

 Answers
1

From the man mke2fs page and this link it appears that the defaults for formatting an ext4 filesystem are very lazy and leave a lot of the writing work to be finished after the drive is mounted for the first time, and every subsequent time until the work is finished. Most annoyingly, it will very slowly write to the drive every few seconds until it's done.



This could be especially bad for a flash drive (card/USB drive) that could have an extremely large block / page size, so writing just a few bytes actually writes to 256k, 512k, or a meg or more. And some flash drives could have an extremely low 1000 write cycles (or maybe 5000 or 10,000, possibly 100,000). Much lower than a hard drive, and even a hard drive would probably benefit more from doing all the writes at once, then being able to sit idle when it really should be idle. And I'm not sure how long it will keep slowly writing to the drive, some people say it could be a few minutes, or a few days. This seems like the worst way to "format" a flash drive.



Excerpt from the man page:



-E extended-options
Set extended options for the filesystem. Extended options are
comma separated, and may take an argument using the equals ('=')
sign... The following extended options are supported:
...
lazy_itable_init[= <0 to disable, 1 to enable>]
If enabled and the uninit_bg feature is enabled, the inode
table will not be fully initialized by mke2fs. This speeds
up filesystem initialization noticeably, but it requires the
kernel to finish initializing the filesystem in the back‐
ground when the filesystem is first mounted. If the option
value is omitted, it defaults to 1 to enable lazy inode table
zeroing.

lazy_journal_init[= <0 to disable, 1 to enable>]
If enabled, the journal inode will not be fully zeroed out by
mke2fs. This speeds up filesystem initialization noticeably,
but carries some small risk if the system crashes before the
journal has been overwritten entirely one time. If the
option value is omitted, it defaults to 1 to enable lazy
journal inode zeroing.


So, if you can initially format (or re-format) the filesystem, this should eliminate the lazy slow format and get it all done at once:



mkfs -t ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/sdxN

[#27578] Sunday, August 22, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emuralm

Total Points: 290
Total Questions: 111
Total Answers: 117

Location: China
Member since Thu, Sep 1, 2022
2 Years ago
;