rockyliang
V2EX  ›  macOS

为什么 mac 系统使用 du 命令统计根目录的大小,结果比电脑硬盘的大小还要大

  •  
  •   rockyliang · Oct 31, 2021 · 2814 views
    This topic created in 1833 days ago, the information mentioned may be changed or developed.

    我的 macbook 硬盘是 256GB ,我使用sudo du -sh /命令统计根目录的大小,结果显示是 331GB ,比硬盘大小还要大,有人知道是什么原因吗?

    注:电脑没有连接任何外部存储设备

    5 replies  •  2021-10-31 18:46:16 +08:00
    celeron533
    celeron533
    Oct 31, 2021
    1
    符号连接重复统计了???
    moult
    moult
    Oct 31, 2021 via iPhone
    2
    apfs 同一个文件的多份拷贝,只占用一份容量。
    12101111
    12101111
    Oct 31, 2021❤️2
    3
    @celeron533 符号链接只是一个包含指向目标的文件, 大小也是本身的大小

    du 会自动对硬链接(相同 inode 的文件)做去重 ( 见 https://www.freebsd.org/cgi/man.cgi?du ) 但是 apfs 是一个 cow 文件系统,支持 block 级别的共享, du 是无法知道这部分重复的
    tsui
    tsui
    Oct 31, 2021
    4
    Sparse Bundle 会影响计算,1G 的 Sparse Bundle 可能占不了几十兆实际磁盘空间
    rockyliang
    rockyliang
    OP
    Oct 31, 2021
    5
    @12101111 确实如此,我复制了一个文件,du 统计出来的文件夹大小变大了,但磁盘工具里显示的已使用空间并没有变大
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   721 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 22:12 · PVG 06:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.