Kubo CLI: Uniformistic CID generation for a directory on Windows and Linux

I use the same (latest) version of Kubo on Linux and Windows to share a directory containing a bunch of files. I noticed that even if the same chunking and hashing algorithms are used, the Kubo backend produces different CIDs when I run ipfs add command with the same options, but on Linux, and then on Windows. From the same drive, on the same machine.

Does anyone know if it’s possible to generate the same CID for a directory containing the same data, first from Linux and then from Windows? It could be very useful for an ‘impostor node’ installed on the multiboot machine, sharing most of the settings.

Hi @twdragon,

Yes, it is possible to generate the same CID for identical directory data across Linux and Windows, but you need to make sure that all metadata and filesystem differences are normalized. The CID mismatch usually happens because of:

  • Different file ordering

  • Line ending differences (CRLF vs LF)

  • File permission bits

  • Timestamps (mtime)

  • OS-specific filesystem metadata

Things you can try:

  1. Use the same exact flags on both systems:

    ipfs add -r --cid-version=1 --chunker=size-262144 --raw-leaves --preserve-mode=false --preserve-mtime=false
    
  2. Normalize line endings before adding files:

    • Convert all files to LF line endings on both systems.
  3. Archive first, then add:

    • Create a tar archive of the directory and add that instead, this often ensures consistent ordering and metadata handling.

If you’re exploring tools, tutorials, and technical walkthroughs, you can also visit for related resources and guides.

Hope this helps, consistent CIDs across platforms are definitely achievable with the right setup!