All Products
Search
Document Center

:How do I mount a bucket to an ECS instance as a non-root user by using ossfs

Last Updated:Jul 28, 2023

Overview

This topic describes how to mount a bucket to an ECS instance as the www user by using ossfs.

Details

Perform the following steps as the www user to mount a bucket:

  1. Install ossfs and create the /etc/passwd-ossfs file. For more information, see Installation.

  2. Run the following command to modify the permissions on the configuration file:

    chmod 640 passwd-ossfs

  3. Run the following command to obtain the installation path of ossfs:

    which ossfs

  4. Run the following command to obtain the UID and GID of the www user.

    Note

    This topic uses the www user as an example. If the user does not exist, run the useradd command to create the user.

    id www

  5. Run the following command to modify the owner and owner group of the configuration file:

    chown -R www:root passwd-ossfs

  6. Run the following commands in sequence to create a mount directory.

    Note

    This topic uses the test1 directory as an example.

    su - www
    mkdir test1

  7. Run the following command to mount a bucket:

    /usr/local/bin/ossfs $Bucket test1 -ourl=$URL -ouid=$UID -ogid=$GID -o passwd_file=$File -odefault_permission=750
    Note
    • $URL indicates the endpoint of the bucket.

    • $File indicates the path of the passwd-ossfs file, such as /etc/passwd-ossfs.

    • $UID and $GID are the UID and GID recorded in Step 4.

  8. Run the following command to confirm that the bucket is mounted:

    ls -l test1

  9. Unmount the directory:

    • Run the following command as the root user to unmount the directory:

      umount /test1

    • Run the following command as a non-root user to unmount the directory:

      fusermount -u /test1

References

  • For more information about ossfs, see Overview.

  • For more information about FAQ about ossfs, see FAQ.

Applicable scope

  • OSS