Is there such a thing as a 'quick' format for ext4?

Solution 1:

Add the flag -E lazy_itable_init

Here's what the man page says:

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 background when the filesystem is first mounted. If the option value is omitted, it defaults to 1 to enable lazy inode table initialization.

Solution 2:

Strict answer

Solutions like -E lazy_itable_init don't change the result, only speed up the process. This is what was explicitly asked yet in many cases people need more.

Extra bonus

In most case you actually want some options that match your usage patterns and not only speed up filesystem creation but also allow faster usage and more usable space.

I just did a test. Even without using -E lazy_itable_init, the options below speed up creation time of a 2TB filesystem from 16 minutes 2 second to 1 minute 21 second (kernel 3.5.0 64bit on Intel i7 2.2GHz, 2TB disk on USB2 connection -- SATA would probably be faster).

For a filesystem that will hold large files, I use this combination:

mkfs.ext3 /dev/sdXX -O sparse_super,large_file -m 0 -T largefile4

where -T largefile4 picks options in /etc/mke2fs.conf which generally contain something like:

    inode_ratio = 4194304
    blocksize = -1

Do a man mke2fs for details on each of these options.

Here are relevant extracts:

               sparse_super
                      Create a filesystem with fewer superblock backup copies (saves space on large filesystems).

               large_file
                      Filesystem can contain files that are greater than 2GB.  (Modern kernels set this feature  automatically
                      when a file > 2GB is created.)

   -i bytes-per-inode
          Specify  the  bytes/inode ratio.  mke2fs creates an inode for every bytes-per-inode bytes of space on the disk.  The
          larger the bytes-per-inode ratio, the fewer inodes will be created.  This value generally shouldn't be smaller  than
          the blocksize of the filesystem, since in that case more inodes would be made than can ever be used.  Be warned that
          it is not possible to expand the number of inodes on a filesystem after it is created, so be  careful  deciding  the
          correct value for this parameter.

-m 0 only says not to reserve 5% for root, which is okay for a data (not boot/root) filesystem. 5% of a 2TB disk means 100Gb. That's a pretty significant difference.


Solution 3:

The default is a quick format; setting up the structures for a ext* volume takes much longer than for a NTFS volume, since there's more of them. You can reduce the number of superblocks, but even that only goes so far.


Solution 4:

If you'll be storing mostly larger files you can increase the number of bytes per inode, thus decreasing the number of inodes created. This can substantially speed up creation time.