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.
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.
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.
Well, that’s it, good luck!.
Hey nice article! I do have Western Digital Passport Ultra 1 TB, i was thinking to format it to ext4, now i changed my mind, have you tried formatting it with any other filesystem like XFS or JFS? I think there won’t be any issue like this in other filesystem.
Hi Shankar,
No I haven’t considered reformatting into a different file system. ‘Ext4’ is a robust file system, plus, I can convert it into ‘Btrfs’ in the future, without having to lose any data as well.
But as I pointed out in the article, if the drive is still empty, then you can reformat it into ‘Ext4’ using the special arguments that I pointed out in the article, and this ‘issue’ will be fixed permanently.
Done! Thanks for the info! I have formatted to ext4 with your command and the LED blink is stopped! It’s working as normal as it should. One doubt is, after unmounting or safely removing the drive in Ubuntu. The LED is still glowing, i think this is an indication of the power suppy as i checked it was not mounted, what you think? I wanted to ask you if this fix has any impact on the performance of ext4 file system on my hard drive because i don’t want to lose any advantage ext4 offers against NTFS, which has fragmentation issue!
This has no performance issue whatsoever!. In fact, if there ever was one (due to the default formatting options, which was the cause of the LED blinking in the first place), now it’s fixed!.
About the LED glowing: Well, I’ve only used it under Fedora 21 so far, and as soon as I safely remove it, the LED goes back to a long blinking state, which indicates now you can safely remove it from the USB port. This doesn’t happen when you unmount it, because safely removing it (which invokes cutting the power to it) and unmounting it are two different things.
Ok! The reason for LED blinking before was Index Node and with your command, Index Node has completed right after formatting the drive. Am i correct?
I have tried both Safely Remove and Unmount in Ubuntu and i am getting long blinking state for both! No drive activity so i think it’s just LED Activity! LOL! 🙂
If it’s long blinking activity, then you should be fine. The ‘unmount’ option on Ubuntu could be the same as safely remove (since we’re talking about a menu option on a GUI and that menu name can mean anything), but the ‘unmount’ I was speaking was the act of unmountting a file system using the command-line.
Is there a software in ubuntu which can format the hard drive without using terminal. I want to format my hard drive to ext4 bcz its fast and support otg.
Yes there is one, it’s called ‘Disks’, but I don’t think it’ll format the drive with this method…
I successfully format my pendrive using ur above method. Now i am not able to access my pd.When ever i tried to copy anything to drive ,it says permission denied…. Please help..
Hi Ankit,
When your drive get mounted, open it in your File Manager and copy its mounted location (once you’re in the mounted location, press ‘Ctrl’ + ‘l’ keys in the file manager, it’ll give you the current location).
For the sake of this example, let’s call the mount location is : ‘/run/media/ankit/my_passport’. Then the command to get write access is the below one:
sudo setfacl -m user:my_user_name:rwx /run/media/ankit/my_passport
Make sure to replace ‘my_user_name’ with your user name and the drive’s mounted path accordingly. If you do this correctly, it should be mounted for you with read/write permissions. If you run into any issue (which you shouldn’t), just ask me…
Thanks for replying bro…
1)I have finally formated my western digital hard drive with your above method. I used below comment for write access.
Sudo chmod -R 777 /media/ankit/monster
And it works .Now i am confused which will be best .(i want read & write access in all PCs)
2) I noticed a very strange thing .After formatting wd hard disk it shows 50.1 gb used.how is possible.I have not copied anything in it.
3)Is there a way to read and write data in ext4 formatted hd in wiñdows 7.
Hi Ankit,
Well, answering your questions…
1). Yes, if you want the drive to be mounted with read/write access on any ‘Linux’ computer under any user name, then yes, you’ve done the correct thing. The command I gave you is the most secure one, but it won’t be much useful under your requirements.
2). It’s not strange at all. You see, when creating a file system, the file system preserves a space for its own use (such as for the ‘inodes’ & the ‘journal’ etc. They’re necessary features of a modern file system and unfortunately they take a reasonable amount of space as well). Now I don’t remember exactly how much the ‘ext4’ file system preserved when I formatted the 1TB WD drive, and I certainly cannot re-format it now 🙂 .
However, I have a 80GB drive which I use as a temporary storage unit. I re-formatted it, and then took a note of the percentage of the reserved space by the ‘ext4’ file system, and then multiplied it with actual capacity of my 1TB WB drive and it showed that the total reserved space for a drive of that size should be set around 50.0916 GB… which is roughly 50.1GB. So your readings are accurate. No need to fear.
P.S: No need to just take my word for it, here’s the screenshot of the newly formatted 80GB drive. You can do the math 🙂 …
https://www.hecticgeek.com/wp-content/uploads/2015/08/80GB-newly-formatted-disks-space-usage.png
3). There are tools that can read/write mount ‘ext4’ file systems, but I highly recommend that you mount your drive read only mode as they can easily corrupt the data if mounted with write access.
That said, if you want to use the drive to be used with read/write access on Windows and ‘Linux’ then the best solution is to format it into NTFS.
Thanks for prompt reply sir……
You’re welcome 🙂 .
Is there a way to revoke any ACL in effect for a drive so access is put back to default?
Thanks.
Bro…do u know any way by which we can connect ext4 hard drive to Android device .I format my hard disk to this format thinking Android supports ext file format by default but it didn’t. It shows damaged sd card message.
I’m no Android expert Ankit, sorry about that …
Thanks man I’m seeing this ext4lazyinit on a server, and I need to use that new drive to receive data asap so I’m using your mkfs format command to create the full index inode first… and it’s just done as i’m typing this, a few mins for 1TB. Thanks again!
You’re welcome George.
Dear, thanks for your help.
You know if you can make without losing data?
Regards!
Hi Ernesto,
Unfortunately, to ‘fix’ this issue means that you have to lose the data. There is no other way around it.
Hello Gayan. Thanks for your answer.
I’m trying to work with my Raspberry, hopefully prove me.
Regards!
You’re welcome 🙂 .
Hi,
Thank you very much for this good article. It’s simple, wel described and really helpful!
Jean
You’re welcome Jean 🙂 .
Thanks a lot. This definitively solved the ‘problem’.
Explanation+solution=great post!
Regards.
You’re welcome 🙂 .
Great article!
It works on my 2TB Seagate hard disk, but it will use a huge amount of memory while creating index nodes. (eat up 12GB RAM and 60MB swap)
sudo mkfs.ext4 -m 0 -L 2TB -E lazy_itable_init=0,lazy_journal_init=0 /dev/sdb1
It ate 12 GB RAM! Man that’s crazy!, that’s probably a bug. Glad you found the article useful anyway.
Thanks for this post. Informative.
You’re welcome.
Hi, as the rest, I would like to thank you for the guide. I used iotop command on mine and speed was considerably slower than what you mention (around 5,9 – 7,8 MB/s), being the case usb3 I thought it was abismal for a new hard drive. Anyway, my question is, if a leave it creating the index node as it is right now (I mean, if I don’t reformat and follow your guide, and don’t interrupt after mounting), it won’t do it again in the future when new files are created on the hard drive? Thanks in advance
I’m didn’t clearly understand the question. However, even if you don’t follow the guide and do not re-format your drive, you have nothing to worry about. The creation of ‘index node’ will be carried out (until it reaches its completion) by the file system utility, automatically.
“In order to ‘force’ ext4lazyinit to finish the thing it does with maximum priority, you need to mount the filesystem with ‘init_itable=0’. By default it is 10 (for detail please see link below)” — https://superuser.com/questions/784606/forcing-ext4lazyinit-to-finish-its-thing
Just FYI 🙂
Hey Thanks,
An “iostat -x 3” in Linux Mint 19.3 showed me that my (old and slow) Hitachi 750G Laptop internal Sata2 was continually busy writing 2MB/s.
Your cli tip above fixed this now.
So thanks again, and a special thanks to duckduckgo for helping me find your article.
🙂
You’re welcome
Thank you for posting this. I’ve setup a NAS using a Raspberry Pi Zero W and a 5TB hard drive. I had formatted the hard drive in the usual manner and then installed hdparm to make my disk spin down after a period of inactivity…but it went for days and I couldn’t get it to be quiet. Every time I tried to stop it spinning it started up again within a second or so.
Then I saw this arcticle. I reformatted using your instruction and it was all done within 30 mins. Since then the disk sleeps when there is no activity. Well worth deleting all my data and starting again. Now I can sleep too LOL! Thanks
You are true hero! I really hate those hidden background activities..