Mkfs command hangs while creating a new filesystem.

本文介绍了解决在Red Hat Enterprise Linux (RHEL) 6和7上使用mkfs.xfs和mkfs.ext4命令创建LVM卷文件系统时出现的挂起问题。通过使用-K选项禁用块丢弃,可以避免由于不支持的存储设备导致的系统调用ioctl()失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://access.redhat.com/solutions/727333

 SOLUTION 已验证 - 已更新 2019年四月25日07:19 - 

English 

环境

  • Red Hat Enterprise Linux (RHEL) 6
  • Red Hat Enterprise Linux (RHEL) 7

问题

  • Both the mkfs.xfs and the mkfs.ext4 command stall on the ioctl() system call while trying to create a new file system on an lvm volume.
  • The machine appears to hang, and does not respond

决议

In order to create the filesystem use the -K option with mkfs command. It will disables the block discard at creating time. More information on mkfs man page:

Raw

        -K     Keep,  do  not  attempt  to discard blocks at mkfs time
                      (discarding blocks initially is useful on  solid  state
                      devices and sparse / thin-provisioned storage).

Example:

Raw

# mkfs.ext4 -K </dev/mapper/path_to_lvm_volume>   # For ext4 filesystem
# mkfs.xfs -K </dev/mapper/path_to_lvm_volume>      # For XFS filesystem

根源

The mkfs command issues a block discard command on the disk, but the underlying storage device cannot handle it.

诊断步骤

Collect the strace logs for mkfs command:

Raw

       # strace -f -tt -y -T -v -x -o /tmp/mkfs.out -s 4096  <mkfs command>

The strace logs for mkfs.xfs or mkfs.ext4 command shows that the command is hanging after issuing the ioctl 0x1277:

Raw

        $ tail  -2  mkfs.txt 
        1538  08:59:41.724086 write(1, "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08", 13) = 13 <0.000053>
        1538  08:59:41.724209 ioctl(3, 0x1277           <-------- hung after this
        [...]

From the kernel source, 0x1277 ioctl corresponds to BLKDISCARD:

Raw

        include/linux/fs.h:
        ------------------
        344 #define BLKDISCARD _IO(0x12,119)
        [...]

The mkfs command was issuing a block discard command to the disk but the disk device did not support the command, which caused the IO errors observed in first snip, which were then being logged.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值