All Products
Search
Document Center

:What do I do if the mount command hangs when I attach local disks to a CentOS 7 instance during disk initialization?

Last Updated:Sep 18, 2024

This topic describes the issue that the mount command hangs when you attach local disks to a CentOS 7 instance during disk initialization. This topic also describes the possible causes of and solutions to the issue.

Problem description

When you initialize local disks for a CentOS 7 instance by using the ext4 file system, the mount command that you run to attach the local disks hangs. Then, you run the ps command and find that the mount process enters the D state (sleep state).

Possible causes

This issue is caused by lazy initialization that is enabled by default for Linux 2.6.37 and later. You can run the uname -r command to query the kernel version that you are running. The kernel version of CentOS 7 is 3.10, which means that lazy initialization is enabled in CentOS 7 by default.

The first time you mount an ext4 file system, you must initialize the inode table. Since lazy initialization is enabled in CentOS 7 by default, the inode table is not immediately initialized when you initialize disks by using ext4. Instead, the table is initialized when you run the mount command to attach the disks. In kernel version 3.10, the mount command involves acquiring the I/O lock. When large-capacity local disks are initialized, the system may need to randomly write data to the disks. During this process, if the I/O lock is held by lazy initialization for a long period of time, it may cause the mount command to hang. This is because the mount command needs to wait for the lazy initialization process to complete before it can continue.

Note
  • In 4.X kernel versions, this issue is resolved because the locking mechanism is optimized.

  • For more information about local disks, see Local disks.

Solutions

Solution 1: Disable lazy initialization

Run the following command during disk initialization to disable lazy initialization:

mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0

If you disable lazy initialization when you initialize disks that are large in size, the initialization process also takes time. For example, it takes about 4.5 to 5 hours to initialize 32 local disks when you attach the disks to an instance of the ecs.d3s.16xlarge instance type.

For more information about disk initialization, see Overview.

Solution 2: Initialize disks by using the XFS file system

By default, CentOS 7 uses the ext4 file system. We recommend that you initialize disks by using the XFS file system. For more information about disk initialization, see Overview.

XFS is faster than ext4 in attaching disks during disk initialization. This is because XFS dynamically allocates inodes as needed, while ext4 pre-allocates all inodes at file system creation. For example, it takes only several minutes to initialize 32 local disks when you attach the disks to an instance of the ecs.d3s.16xlarge instance type.

Important

By default, CentOS 7 uses the ext4 file system. To avoid compatibility issues, we recommend that you test whether you can use the XFS file system in your environment before you proceed.