docker启动报错the backing xfs filesystem is formatted without d_type support

发布时间 2023-04-06 17:43:27作者: 滴滴滴

WARNING: overlay2: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior.
Reformat the filesystem with ftype=1 to enable d_type support.
Running without d_type support will not be supported in future releases.

 

问题分析
出现问题的docker配置存储驱动为overlay2,从报错上看,overlay2需要文件系统支持d_type,但出现问题的机器上配置的data-root目录采用的是xfs文件系统,默认并没有开启d_type,需要开启d_type的支持。

什么是d_type
d_type 是 Linux 内核的一个术语,表示 “目录条目类型”,而目录条目,其实是文件系统上目录信息的一个数据结构。d_type,就是这个数据结构的一个字段,这个字段用来表示文件的类型,是文件,还是管道,还是目录还是套接字等。

d_type 从 Linux 2.6 内核开始就已经支持了,只不过虽然 Linux 内核虽然支持,但有些文件系统实现了 d_type,而有些,没有实现,有些是选择性的实现,也就是需要用户自己用额外的参数来决定是否开启d_type的支持。

检查xfs文件系统是否支持d_type

[root@10-80-119-18 ~]# xfs_info /
meta-data=/dev/vda2              isize=256    agcount=9, agsize=2589248 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=20843184, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=5057, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
注意以上输出中的ftype字段,为0则表示不支持。

解决方案
指定docker的存储驱动类型为devicemapper,devicemapper不需要文件系统支持d_type,但docker官方目前推荐使用overlay2,因此不选择此方案。
重新格式化docker data-root目录所在的文件系统,xfs格式化时添加参数ftype=1,如下

mkfs.xfs -n ftype=1 /dev/mapper/vg_data-lv_data -f
这里采用第二种解决方案

重新启动docker,问题解决