Suppose I have an image home.img of a home partition of another linux machine (B). On that machine there is a users userB and there is a special group, groupB. Consider for example a file fileB in the home partition of machine B. Suppose it is owned by userB and groupA.

Now if I mount (via mount home.img /mnt/homeB -o ro) the img file on another linux machine A (logged in as userA), fileB is now owned by userA.

Is it possible to modify the mount options such that the owner, groups and permissions are shown on machine A, as it would be shown directly on machine B (for example that fileB is owned by userB and not by userA)? Do I have to create a dummy userB and groupB on machine A?

  • 1
    See if bindfs meet your needs. – enzotib Aug 19 '12 at 12:58
  • 1
    @enzotib bindfs does some translation of permissions, but it doesn't do arbitrary translations of users, which I think student wants. Bindfs only translates one user and one group. – Gilles 'SO- stop being evil' Aug 19 '12 at 22:18
  • @Gilles Yes, that's what I want. – student Aug 20 '12 at 6:59

The problem you're running into is that userB on machineB has the same UID number as userA on machineA.

Linux filesystems store ownership by UID number, not name. So if the file is owned by a user with UID number of 1000, then whenever that filesystem is mounted on another machine, the file will appear to be owned by whatever user has a UID number of 1000.
Now in theory a filesystem could store file ownership by user name instead, but I do not think any do.

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.