I can successfully mount an ext4 partition, the problem is that all the files on the partition are owned by the user with userid 1000. On one machine, my userid is 1000, but on another it's 1010. My username is the same on both machines, but I realise that the filesystem stores userids, not usernames.I could correct the file ownership with something like the following:find /mnt/example -exec chown -h 1010 {} \;But then I would have to correct the file ownerships again back to 1000 when I mount this external drive on another machine.What I would like is to give mount an option saying map userid 1000 to 1010, so that I don't have to actually modify any files. Is there a way to do this?
How can I mount a filesystem, mapping userids?
mount;ext4
Take a look at the bindfs package. bindfs is a FUSE filesystem that allows for various manipulations of file permissions, file ownership etc. on top of existing file systems.You are looking specifically for the --map option of bindfs:--map=user1/user2:@group1/@group2:..., -o map=...    Given a mapping user1/user2, all files owned by user1 are shown as owned by user2. When user2 creates files, they are chowned to user1 in the underlying directory. When files are chowned to user2, they are chowned to user1 in the underlying directory. Works similarly for groups.    A single user or group may appear no more than once on the left and once on the right of a slash in the list of mappings. Currently, the options --force-user, --force-group, --mirror, --create-for-*, --chown-* and --chgrp-* override the corresponding behavior of this option.    Requires mounting as root. So to map your files with user id 1001 in /mnt/wrong to /mnt/correct with user id 1234, run this command:sudo bindfs --map=1001/1234 /mnt/wrong /mnt/correct