2

I would be formatting a newish large capacity 4 TB hdd in few hours. From what little I understand, I could just format it and it will look to be formatted.

If I format it in real-time then it would probably take a long time, 10000 rpm x 4 GB DDR3 RAM. Hence Linux came up with the concept of ext4lazyinit.

I'm running Debian GNU/Linux 'Stretch' and have kernel 4.9 .

[$] uname -a

Linux debian 4.9.0-1-amd64 #1 SMP Debian 4.9.2-2 (2017-01-12) x86_64 GNU/Linux

[$] lsb_release -a

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.0 (stretch)
Release:    9.0
Codename:   stretch    

Now, according to the wiki it says and I quote -

If enabled and the uninit_bg feature is enabled, the inode table will not be fully initialized by mke2fs. This speeds up file system initialization noticeably, but it requires the kernel to finish initializing the file system in the background when the file system is first mounted. If the option value is omitted, it defaults to 1 to enable lazy inode table zeroing. - Thomas Kenn

Now is there a way to know if the above feature is enabled in my kernel or not ?

Update -

there is a /boot/config-4.9.0-1-amd64 . The file is 7865 lines long according to -

[$] cat /boot/config-4.9.0-1-amd64 | tail -n 1

  7865  CONFIG_SBITMAP=y

Trying to grep doesn't lead anywhere -

[$] cat /boot/config-4.9.0-1-amd64 | grep LAZY

OR even ext4 for that manner -

[$] cat /boot/config-4.9.0-1-amd64 | grep EXT4

  6895  CONFIG_EXT4_FS=m
  6896  CONFIG_EXT4_USE_FOR_EXT2=y
  6897  CONFIG_EXT4_FS_POSIX_ACL=y
  6898  CONFIG_EXT4_FS_SECURITY=y
  6899  CONFIG_EXT4_ENCRYPTION=y
  6900  CONFIG_EXT4_FS_ENCRYPTION=y
  6901  # CONFIG_EXT4_DEBUG is not set

Any ideas anybody ?

5
  • Ext4 formatting of large harddrives is much faster, it was one of the improvements of the ext4. But even with ext3 hadn't been it so long.
    – peterh
    Jan 29, 2017 at 18:49
  • lazy_itable_init is turned on by default if the kernel you are running supports automatic background initialization of the inode table ( 2.6.37+ ). Jan 29, 2017 at 18:55
  • @don_crissti while I know that, is there a command or something to check the values to see, know that's it turned on ?
    – shirish
    Jan 29, 2017 at 18:57
  • @don_crissti I am not dis-believing you or anything, but there should be a way to find these things, isn't there ?
    – shirish
    Jan 29, 2017 at 19:31
  • 1
    Find what ? Unless you used mkfs with -E lazy_itable_init=0 it is enabled by default. You don't have to believe me, see for yourself: mke2fs: Enable lazy_itable_init on newer kernel by default And by the way - this doesn't format faster - it just lets you use the fs while it continues formatting in the background after the 1st mount... Jan 29, 2017 at 19:47

2 Answers 2

1

Google for its kernel compilation string (or check this in the "make menuconfig" of the kernel source). It surely starts with CONFIG_EXT4_FS_ . These kernel compilation flags of your actually running kernel are can be provided in /proc/config.gz (but doing this is also a kernel compile flag, thus it may or may not be enabled on your system), or by your distribution in /boot/config-your-kernel-version (your distrib may or may not provide this).

As I can remember, it is an old (at least 5 years) feature, thus your kernel probably supports it.

Online ext4 resizement doesn't work with some highly finetuned mke4fs configurations (sorry I forgot exactly what - some of the ext4 fs flags makes it impossible).

3
  • I did try using a search-engine and I don't wanna make a custom kernel, I just want to know if there is a way to know it's enabled or not. Also thre is no /proc/config.gz on my /proc directory.
    – shirish
    Jan 29, 2017 at 19:01
  • @shirish Then check in /proc/config.gz or in /boot/config-x.y.z, as I wrote.
    – peterh
    Jan 29, 2017 at 19:03
  • I have updated/added new info. maybe that gives more light.
    – shirish
    Jan 29, 2017 at 19:47
0

I've been working on a bug related to this ext4 feature. So far as I can tell from the kernel source (linux 4.15.x) there is no feature called 'uninit_bg'. It looks like it's just baked in to the ext4 filesystem, although the key feature in question is called 'lazy_itable_init'. There's be a few changes in this code and perhaps the comments + docs need to catch up with reality.

When using mkfs you can add the -E lazy_itable_init=0 option as other people has said - I don't think this attribute gets stored in the filesystem's metadata - the kernel thread for handling the lazy init is triggered or not dependent upon whether lazy_itable_init is set, but once all block groups on the FS have the ITABLE_ZEROED flag set then the filesystem is initialised and that's that - i.e. the method of initialisation stops being of any relevance.

1
  • uninit_bg is not a kernel configuration item, but a filesystem feature. See tune2fs -l /dev/<device containing the filesystem> | grep "Filesystem features".
    – telcoM
    Jan 21, 2021 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .