I formatted an external hard drive with an ext4 partition and subsequently mounted it. So that I could use the new partition, I did: sudo chown me:me /mount/directory to change the file owner and group from root to me, which worked fine.

This change is persistant, so I wonder where this information is stored. If I detach the hard drive then mount it to a different directory, I'm still set as the file owner and group, so the information can't be stored in the mount directory's inode.

So does the whole partition have its own inode where this sort of information is stored, and if so, is there a way to view it? Or is there perhaps another place where the information gets stored?


There's no difference between an external drive and an internal drive in terms of the filesystem stored on it. The owner & group of the filesystem's root directory are stored in its root directory, the same way your root filesystem's owner & group are stored.

A corollary of this is that because UIDs and GIDs are stored only numerically, if you mount an external drive on a system with different users in /etc/passwd, you'll see that the owner & group have changed to whatever that UID & GID map to on the other system. (e.g. if on your system user me is UID 1000, and you mount the drive on a system where UID 1000 is rms, you'll see the directory owned by rms.)

On the other hand, if you use a filesystem that doesn't store UID/GID information (like FAT), then the UID/GID of every file on the filesystem is taken from the parameters you gave to the mount command (either directly or through /etc/fstab).

A second corollary is that it doesn't matter what owner or permissions /mount/directory had on your root filesystem. Once a filesystem is mounted there, that filesystem's permissions are the ones that matter. That's why I like to chmod a-rwx /mount/directory before mounting the filesystem. It prevents me from accidentally writing to /mount/directory when the filesystem is not mounted there.

  • 1
    Once upon a time Solaris 1.x had a bug where the ownership of the mount point filtered through. The symptom was that users got permission errors when they tried to access the filesystem, but you couldn't see any incorrect permissions, because ls showed the permissions in the mounted filesystem. – Barmar Jun 11 '14 at 19:02
  • +1 for the chmod technique I hadn't thought of - in addition to being correct otherwise. – Joe Jun 14 '14 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.