UID / GID Auto Map
JuiceFS supports POSIX extended ACL, you can manage permissions by directory or file granularity, just like a local file system.
Simply put, users having the same name will have their UID / GID mapped to the same internal ID in JuiceFS metadata server for the files they own. The internal ID will be automatically converted to the matched UID / GID when JuiceFS is mounted in a host.
By default, JuiceFS will map user and group names to a reserved segment for internal ID. Avoid using UID > 10000 to reduce the chance of collision.
To disable this auto map feature, contact JuiceFS team to schedule this change, after UID/GID auto map is disabled, you may need to run chown
on all affected files.
Example
Create user juicefs
with UID 1001
on an Ubuntu host X, mount JuiceFS to /jfs
and create a new directory juicefs@ubuntu
.
[ubuntu]$ useradd -m -G sudo -u 1001 juicefs
[ubuntu]$ id juicefs
uid=1001(juicefs) gid=1001(juicefs) groups=1001(juicefs),27(sudo)
[ubuntu]$ su juicefs
[ubuntu]$ mkdir /jfs/juicefs@ubuntu
Create user with the same name juicefs
with UID 2002
on another CentOS host Y, mount JuiceFS to /jfs
and create a directory juicefs@centos
[centos]$ useradd -m -G wheel -u 2002 juicefs
[centos]$ id juicefs
uid=2002(juicefs) gid=2002(juicefs) groups=2002(juicefs),10(wheel)
[centos]$ su juicefs
[centos]$ mkdir /jfs/juicefs@centos
When listing the owner of the file with ls -l
, both hosts show juicefs
as expected.
[ubuntu]$ ls -l /jfs
drwxr-xr-x 2 juicefs juicefs 4096 Aug 22 13:02 juicefs@centos
drwxrwxr-x 3 juicefs juicefs 8192 Aug 22 12:35 juicefs@ubuntu
[centos]$ ls -l /jfs
drwxr-xr-x. 2 juicefs juicefs 4096 Aug 22 13:02 juicefs@centos
drwxrwxr-x. 3 juicefs juicefs 8192 Aug 22 12:35 juicefs@ubuntu
Check UID/GID
The numeric value of UID
and GID
can be inspected with ls -n
The output shows that the directory juicefs@centos
owned by UID 2002
in CentOS, is mapped to UID 1001
in Ubuntu:
[ubuntu]$ ls -n /jfs
drwxr-xr-x 2 1001 1001 4096 Aug 22 13:02 juicefs@centos
drwxrwxr-x 3 1001 1001 8192 Aug 22 12:35 juicefs@ubuntu
While the directory juicefs@ubuntu
owned by UID 1001
in Ubuntu is mapped to UID 2002
in CentOS:
[centos]$ ls -n /jfs
drwxr-xr-x. 2 2002 2002 4096 Aug 22 13:02 juicefs@centos
drwxrwxr-x. 3 2002 2002 8192 Aug 22 12:35 juicefs@ubuntu
When JuiceFS is mounted, a hash mapping from user and group names to internal ID will be created. If the internal ID of a file entry is found in the mapping, it will be converted to the corresponding user or group. If not, use the internal ID.
In this example, if juicefs
user is deleted, the internal ID can be observed after remounting the file system:
$ userdel juicefs
$ umount /jfs
$ juicefs mount $VOL_NAME /jfs
$ ls -l /jfs
drwxr-xr-x. 2 27055 27055 4096 Aug 22 13:02 juicefs@centos
drwxrwxr-x. 3 27055 27055 8192 Aug 22 12:35 juicefs@ubuntu