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?

  • 1
    – Anthon
    Commented Oct 1, 2014 at 18:29
  • 2
    I search for this question a year and a half later, found this, wanted to upvote, only to discover that I asked this question myself!
    – Flimm
    Commented Mar 31, 2016 at 9:13
  • You can still make it a favourite, even if you can't upvote :-O
    – Anthon
    Commented Mar 31, 2016 at 9:19

3 Answers 3


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
  • I'm getting fuse: unknown option `--map=1004/1002' on my Ubuntu 12.04.5 LTS server. I wonder if my version of bindfs or fuse is outdated...
    – Zero3
    Commented Dec 7, 2015 at 17:33
  • You have to change 1004/1002 to your user IDs. You can find them using id -u username. Commented Aug 26, 2022 at 9:58

If you have a kernel >5.12 and on a supported filesystem (ext4 should be fine, but BTRFS support wasn't added until 5.15), you can use the idmapping in mounts feature. You will need to use the mount-idmapped program until you have a util-linux new enough to support the X-mount.idmap feature for mount.

A simple example is: Using mount-idmapped When on the machine where your uid is 1010, you could use the following command: mount-idmapped --map-mount b:1000:1010:1 /mnt/example /mnt/example

There are some caveats, like you can't map two host uids to the same target uid. So bindfs is a more general solution, but this should work for your use case.


You can use bindfs. It can bind the filesystem to some other mountpoint with different uid/gid. However I think I would just change the uid so it is the same on both systems.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .