This is actually not really a problem for most of the users as they only format filesystem once and use it afterwards. But for users who need to do repeated testing on multiple drives, this could be really helpful as it can save you a lot of time.
One way to make format faster is to modify the
bytes-per-inode value. By specifying higher value for this parameter, less inode will be created. As such, this is probably not suitable for all the situation but it is suitable if your filesystem only need to store virtual machine image which each file is big in size but the number of files in the filesystem is less.
bytes-per-inode |
Time |
Free inode |
16384 (default) |
1m29.712s |
30490613 |
32768 |
48.809s |
15245301 |
65536 |
23.675s |
7622645 |
131072 |
14.793s |
3811317 |
As you can see, the lesser inode need to be created, your format can be done faster. Command to do this:
mkfs -t ext4 -i 131072 /dev/sdb1
Another way is to use lazy_itable_init when formatting filesystem. This is actually the fastest way because inode table is not fully initialized when you do the formatting, instead, it is initialized when it is mounted. So this again might not be suitable if you are doing some IO test as you never know how this initialization process will affect your real IO performance. So the time taken is -- only 3.785s.
Command to do this
mkfs -t ext4 -E lazy_itable_init=1 /dev/sdb1
Notes:
time command was used to capture the elpased time
Disk size is 500GB