Search code examples
androidlinuxfilesystemsinode

Android filesystem and inodes


I have recently learned about Unix inodes and their purpose. In particular, I learned that an.inode is unique across a filesystem.

My question is: if a user inserts a Micro SD card into their Android device, does that card become part of the existing filesystem or does it become a separate filesystem?

or, to put it another way: can inodes be duplicated across the internal and external storages?

Many thanks, P


Solution

  • Micro SD cards usually use FAT32, a file system which store no inodes. The Linux kernel is creating a random inode number that is different from other ones when a new file is accessed.

    On a FAT32 file system, a pathname is enough to uniquely identify a file, unlike with other file systems where a file can have any number of pathnames including none at all.

    These FAT32 fake inode numbers are dropped:

    • when the file system is unmounted
    • when the OS reboots
    • when the fixed size cache where they are stored is full

    Should you want a reliable way to identify files on FAT32, don't use their inodes.

    I would suggest to use a hash of their pathname, combined with their size if you want to be really sure to avoid collision.