Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
Ariake265
V2EX  ›  Linux

有生之年终于把 ext4 的 inode 干爆了,请教几个问题

  •  
  •   Ariake265 · Dec 28, 2023 · 4608 views
    This topic created in 865 days ago, the information mentioned may be changed or developed.

    一个 3T 大小的硬盘(不是挂载到根目录),最近要下载一个 500G 左右的数据集,大概 37w 张 JPEG 图片。寻思挂了个 Aria2 慢慢下就行了,但结果今天一看提示磁盘没有空间。df -h /data 一看空间不是还剩很多吗,转念一想应该是 inode 索引被干爆了。

    现在已经在把下载好的文件导出备份了,准备重新格式化一下这个硬盘,有几个问题想要请教:

    1. 当时这个硬盘是打算存自己的一些数据(电影啥的),就听了 Reddit 上老哥的意见,用 mkfs.ext4 -T largefile4 -m 0 格式化的。是不是 largefile4 为大文件设计而降低了 inode 的数量上限?默认设置能不能解决 inode 不够的问题?
    2. 用其他文件系统,不考虑 zfs 和 btrfs 这种比较复杂的文件系统的话,像 xfs 这样的文件系统会不会比 ext4 的支持更好?
    21 replies    2023-12-29 23:47:22 +08:00
    dog82
        2
    dog82  
       Dec 28, 2023
    我还以为说的是 extjs 呢
    hefish
        3
    hefish  
       Dec 28, 2023
    我是跑 docker ,把 ext4 撑死了,后来所有系统都换成了 xfs 。
    lsylsy2
        4
    lsylsy2  
       Dec 28, 2023
    https://wiki.archlinux.org/title/ext4

    To specify a different bytes-per-inode ratio, you can use the -T usage-type option which hints at the expected usage of the filesystem using types defined in /etc/mke2fs.conf. Among those types are the bigger largefile and largefile4 which offer more relevant ratios of one inode every 1 MiB and 4 MiB respectively. It can be used as such:

    确实是 largefile4 的问题。
    billccn
        5
    billccn  
       Dec 28, 2023
    推荐 largefile 就是减少每单位空间分配的 inode 数量来减少额外开销,毕竟储存各种分配表都需要按照最大 inode 数量来规划空间。Btrfs 等文件系统用树代替了表,所以不受这个问题干扰。Btrfs 有一个可以把 Ext 直接转换的工具,你可以试试。
    Ariake265
        6
    Ariake265  
    OP
       Dec 28, 2023
    @lsylsy2 @billccn 感谢,以后还是不折腾 ext4 的各种参数了😂
    F7TsdQL45E0jmoiG
        7
    F7TsdQL45E0jmoiG  
       Dec 28, 2023
    xfs 可以
    OysterQAQ
        8
    OysterQAQ  
       Dec 28, 2023
    小文件使用 seaweedfs ,从应用层解决问题
    june4
        9
    june4  
       Dec 28, 2023
    3t 的盘,被区区 37w 个文件把 inode 耗尽了?默认设置应该都能有过亿个 inode 了吧?
    可以用 df -i 看一下是不是 inode 的问题
    luxor
        10
    luxor  
       Dec 28, 2023
    mkfs.ext4 -N 可以指定 inode 最大数量
    google2023
        11
    google2023  
       Dec 28, 2023
    @june4 赞同!我觉得楼主的问题不太可能是 ext4 文件系统的原因
    lsylsy2
        12
    lsylsy2  
       Dec 28, 2023
    @june4
    @google2023
    OP 设置了 largefile4 ,也就是 4M 才给一个 inode ,也就是全盘 75w ,乱七八糟文件夹什么的吃掉一半,37w 文件吃掉还是很正常的
    009694
        13
    009694  
       Dec 28, 2023 via iPhone
    largefile4 每 4MB 预留一个 inode 。 也就是说你的所有文件平均大小不足 4MB 的话, 就会出现 inode 不足的情况
    BeautifulSoap
        14
    BeautifulSoap  
       Dec 28, 2023 via Android
    largefile 。。。。这参数我只有在我 nas 的硬盘上格式化时才会用。。。因为 nas 里存的文件平均都是几十 mb ,几 gb
    des
        15
    des  
       Dec 28, 2023 via iPhone
    seaweedfs +1 ,小文件要复制也麻烦
    Ariake265
        16
    Ariake265  
    OP
       Dec 28, 2023
    @lsylsy2 对的,每两三个图片上面都顶着两个目录,平摊下来一个图片也就 2M ,largefile4 真的吃不消了
    Ariake265
        17
    Ariake265  
    OP
       Dec 28, 2023
    @BeautifulSoap 哈哈本来这块硬盘我就是当 NAS 硬盘在用的,在下载这个数据集的时候没多想,没想到就出问题了
    hhhh115
        18
    hhhh115  
       Dec 28, 2023
    @dog82 #2 +1 ,想起被 ext 支配的恐惧😂
    ice000
        19
    ice000  
       Dec 28, 2023
    有些 Android 版本编译和 xfs 有冲突,报 node 长度过长 ,也是没办法
    kenneth104
        20
    kenneth104  
       Dec 28, 2023
    用 xfs 就行了,最容易过渡
    google2023
        21
    google2023  
       Dec 29, 2023
    @lsylsy2 看了半天才明白,谢谢!
    奇怪 OP 为什么要设这个参数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1009 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 93ms · UTC 19:17 · PVG 03:17 · LAX 12:17 · JFK 15:17
    ♥ Do have faith in what you're doing.