I recently purchased a Western Digital My Passport Ultra (1TB, USB 3.0) external hard disk as I was running out of space to save my files. Although I dual-boot a GNU/Linux distribution (which is the awesome Fedora 21 nowadays) with Windows 8.1, and almost all of my friends rely on the Windows operating system, I took the decision to format it into ‘Ext4’ anyway, despite having the obvious drawback to which I am bound (that would be sharing data of course  ).

To be honest, I never had used a native GNU/Linux file system on a large USB hard disk before, thus, after creating an ‘Ext4’ file system on the 1TB USB drive, I made an interesting (and irritating) observation. What happened was that, after formatting the drive into ‘Ext4’, whenever I mounted the USB disk, even when I was not using it, the LED starts to indicate (by blinking) a mild disk activity.

I ignored it the first time, but every time I mounted the drive, it happened again and again. And on all these instances the LED kept blinking non-stop for minutes and the only way stop it was to detach the USB disk from the computer. So in an attempt to isolate its cause, I used the ‘iotop‘ utility (it’s a tool that sorts & lists processes by their disk I/O consumption). And as soon as I opened it, ‘iotop’ listed a process called ‘ext4lazyinit’ that was consuming a mild I/O bandwidth (about 11-13 Mb/s) out of my WD USB hard disk.

'ext4lazyinit' running from the background (on Fedora 21, Gnome)

Due to its name and since it was a newly formatted file system, I suspected that it probably had something to do with the ‘Ext4’ file system. A little Googling conformed my suspicion, it was indeed an ‘Ext4’ related process, finishing things up from the background.

What is it really?

You see, when creating a file system in GNU/Linux, a special kind of index gets created called ‘index node’, without which a file system cannot hold data. However, creating an ‘index node’ when formatting a large partition (1 TB in this instance) could take a while and therefore can delay the formatting process.

So as a fix, when formatting a drive, ‘Ext4’ creates a basic ‘index node’ only, one that is just enough to mount the file system and get things going. And as soon as the file system gets mounted, ‘Ext4’ silently creates the rest of the ‘index node’ using ‘ext4lazyinit’. By default it is supposed to write to the disk using about 16 Mb/s (though here it was between 11-14 Mb/s).

For newer hard drives this is a reasonably small percentage of their total write speed (about 11% for my WD My Passport Ultra series), thus the users can carry on their tasks without significant delays. If this process gets interrupted, then it ‘Ext4’ will carry it on the next time it is mounted. This will happen on and on, until the whole ‘index node’ is created. So in theory, there is nothing to worry about.

But personally, I like to keep things simple, and the sooner a job is finished, the better. And also, power failures do occur from time to time where I live, and who knows, they could corrupt the ‘index node’. Nonetheless, if you are interested, then there is a fix, though for it to work, you need to re-format the file system, and that is going to destroy the data on it (obviously).

If you cannot afford that (say that you have already filled it up and don’t have anywhere else to backup the data), then the best solution is to just let ‘ext4lazyinit’ do its thing, and it will finish things up, eventually. But if you are okay with formatting the drive, then you can follow the below procedure to force ‘Ext4’ to create the whole ‘index node’ while formatting the drive (or individual partitions, mine only contains a single partition) and that will be the end of it.

Assuming that you know how to find the path of the partition that should be re-formatted (if you don’t, then use the sudo blkid command and carefully have a look to find it. Be careful, though, if you enter a wrong partition path, then you will lose its data in a short while!!), enter the below command to re-format it (again remember, this will destroy all of its data):

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

Note: ‘/dev/sdc1‘ is the partition path, make sure to replace it accordingly.

If you want to enter a volume label (it’s the name that will be used while displaying the mounted drive), use the below command instead:

sudo mkfs -t ext4 -L my_passport -E lazy_itable_init=0,lazy_journal_init=0 /dev/sdc1

Note: Here too replace the label ‘my_passport‘, and the partition path ‘/dev/sdc1‘, accordingly (if you have more than one partition, then re-format them all with ‘lazy_itable…’ and ‘lazy_journal…’ options set to zero).

The time it takes for the ‘index node’ to be fully initialized, depends on the size and the read/write speed of your drive, but since unlike above, here ‘Ext4” will be operating at the full performance capacity of your hard drive, thus it should not take a long time to complete (my 1 TB WD My Passport Ultra USB hard drive took about two and half minutes). While all this is happening, ‘Ext4’ will give you a report of the ongoing ‘index node’ initialization process, as shown below.

'Ext4' writing the whole 'inode index' (on Fedora 21, Gnome)

Once everything is finished, you can remove and reattach the USB hard disk and the newly created partition will be mounted automatically. And from now on, at idle, the LED should not indicate any ‘suspicious’ activity.

Zero disk read & write usage after re-formatting with 'lazyinit' disabled (Fedora 21, Gnome)

Well, that’s it, good luck!.

Source: https://www.hecticgeek.com/2015/01/ext4-external-hard-disk-busy-at-idle-fix/

分类: Linux

0 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据