ファイルシステムをマウントしてユーザーIDをマッピングする方法は?

ファイルシステムをマウントしてユーザーIDをマッピングする方法は?

ext4パーティションを正常にマウントできます。問題は、パーティション内のすべてのファイルがユーザーID 1000を持つユーザーの所有であることです。あるコンピュータでは、私のユーザーIDは1000ですが、別のコンピュータでは1010です。私のユーザー名は両方のコンピュータで同じですが、ファイルシステムがユーザー名ではなくユーザーIDを保存していることに気づきました。

次の方法でファイルの所有権を変更できます。

find /mnt/example -exec chown -h 1010 {} \;

ただし、この外付けドライブを別のコンピュータにマウントするときは、ファイルの所有権をもう1000に変更する必要があります。

私が望むのは、mount実際にファイルを変更する必要がないようにユーザーID 1000を1010にマップするオプションを提供することです。これを行う方法はありますか?

ベストアンサー1

見てファイルシステムバインディングパック。 binfsは、既存のファイルシステム上のファイル権限、ファイル所有権などのさまざまな操作を実行できるFUSEファイルシステムです。

あなたは特に探しています- マップオプションファイルシステムバインディング:

--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. 

したがって、ユーザーIDが1001のファイルをユーザーIDが1234のファイル/mnt/wrongにマップするには、/mnt/correct次のコマンドを実行します。

sudo bindfs --map=1001/1234 /mnt/wrong /mnt/correct

おすすめ記事