Help Center> Object Storage Service> obsfs> Operation Guide> Mounting a Parallel File System
Updated on 2024-03-29 GMT+08:00

Mounting a Parallel File System

To use obsfs to manage your objects in OBS, you need to mount an OBS parallel file system locally. After the parallel file system is mounted, working on the mount directory is working on the parallel file system. For example, you can upload an object to OBS simply by saving it to the mount directory.

Traffic consumed by parallel file systems after they are mounted to ECSs through obsfs is measured as OBS traffic.

Constraints

  • obsfs supports mounting of parallel file systems but not OBS buckets.
  • The local directory that the parallel file system is mounted to does not need to be empty, but any files in that directory will be unavailable when the parallel file system is mounted. However, they will still be there when the parallel file system is unmounted later. To avoid any confusion this might cause, mount your parallel file system to an empty directory.
  • Files or folders in the mount directory do not support hard links.
  • There can be no more than 45 directory levels.
  • If a parallel file system is manually mounted by running a command, it needs to be mounted again every time the Linux is restarted.
  • The actual size and used space of a parallel file system vary with your actual usage.

    You can configure auto mounting of a parallel file system upon startup. For details, see Mounting a Parallel File System Automatically upon Startup.

  • A parallel file system can be mounted to multiple ECSs, but you need to prevent multiple ECSs from concurrently writing the same file.
  • Bucket policies and IAM policies at the bucket level are applied to the obsfs mounting mode, while those at the directory level are not.

Prerequisites

  • You have obtained obsfs by referring to Downloading and Installing obsfs.
  • obsfs has been initialized by referring to Initializing obsfs.
  • There is a mount directory in the local file system.

    You can run the mkdir command to create a directory for mounting a parallel file system. For example, to create a directory named mountpoint, the command is:

    mkdir mountpoint
  • The system time has been calibrated.

    If there is a huge time offset between the system and the storage server, the request authentication will fail.

Mounting a Parallel File System Manually

  1. Open the CLI.
  2. Run the cd command to go to the directory where obsfs is located.
  3. Run the mount command in the following format:

    ./obsfs Parallel file system name Local mount directory -o url=Region endpoint address -o passwd_file=Key file path -o big_writes -o max_write=131072 -o use_ino Mount parameters 
    • Parallel file system name: name of the parallel file system you want to mount.

      A specific directory in a parallel file system can be mounted locally. If you mount just a directory, you can access only this directory in the parallel file system after entering the local mount directory. The mount command is as follows:

      ./obsfs Parallel file system name:/Directory name Local mount directory -o url=Region endpoint address -o passwd_file=Key file path -o big_writes -o max_write=131072 -o use_ino Mount parameters

    • Local mount directory: the absolute or relative path of the directory on which a parallel file system is to be mounted.
    • Region endpoint address: Obtain the endpoint address according to the region where the mounted parallel file system resides. For details, see Regions and Endpoints.
    • Mount parameters:

      Mount parameters, excepting passwd_file and use_ino, are optional. Select proper parameters according to your actual needs. The format is as follows: -o Parameter=Value. If you do not need to specify a parameter value, use only -o Parameter. Table 1 lists OBS mount parameters and their descriptions.

      For details about obsfs mount parameter configurations, run the ./obsfs --help command to learn more.

      Table 1 obsfs mount parameters

      Parameter

      Value

      Description

      passwd_file

      Type: String

      Value: Set this parameter to the path of the access key file configured in Initializing obsfs.

      The access key file contains the AK and SK information required for access obsfs.

      use_ino

      Required

      If this parameter is specified, obsfs allocates the inode number.

      big_writes

      Not required

      After the configuration, the maximum size of the cache can be modified.

      max_write

      Type: Integer

      Recommended value: 128 KB

      This parameter is valid only when big_writes is configured. The default write size is 4 KB. The recommended value is 128 KB.

      nonempty

      Not required

      This parameter allows the mount point to be a non-empty directory.

      allow_other

      Not required

      This parameter allows other users to access the parallel file system.

      max_background

      Type: Integer

      Recommended value: 100

      You can use this parameter to set the maximum number of waiting requests in the background.

      use_path_request_style

      Not required

      Indicates the path-based access (legacy API). If this parameter is configured, you need to use the specified endpoint address to access OBS.

      NOTE:

      If the value of the URL in the command is an IP address, this parameter must be carried in the mount command. Otherwise, a domain name resolution error is reported.

      umask

      Not required

      This parameter masks the file permissions. The umask command is executed upon each access to the file system, and automatically configures the mask for new permissions.

      obsfslog

      Not required

      This parameter enables the loading of log configuration parameters from the configuration file, including the log mode and level. You can change the log level without restarting the process when this parameter is enabled.

      NOTE:

      The path of the configuration file is: /etc/obsfsconfig. If you want to use this parameter, you need to manually create the configuration file path on the local host and write the content by referring to the following example and comments.

      An example of the configuration file content:

      //Log mode. The value 0 indicates that the log mode is displayed on the client. If the value is 1, the log file is generated in the following path: /var/log/obsfs, which is named after the process ID. If the value is 2, the log is written into the system log.
      dbglogmode=1
      //Log level. The value can be dbg, info, warn, err, or crit. If the log level is set to dbg or info, service details, such as the bucket name and file name, will be printed.
      dbglevel=info

  4. Run the following command to view the result:

    df -h

    If the information similar to the following is displayed, the parallel file system is successfully mounted:

    Filesystem       Size         Used       Avail      Use%      Mounted on
    obsfs            256T         0          256T       0%        /path/to/mountpoint

    The actual size and used space of a parallel file system vary with your actual usage.

    If the preceding information is not displayed, the parallel file system fails to be mounted. In this case, you can add the following parameters to the command, so that the mount process and detailed debug logs are displayed in the command output:

    -d -d -f -o f2 -o curldbg

    Then you can locate the fault based on the error information. For details about troubleshooting of common faults, see Failures in Mounting a Parallel File System.

Command Example

In this example, the filesystem001 parallel file system and the access key file path /etc/passwd-obsfs in the CN-Hong Kong region are used as examples to describe how to mount an OBS parallel file system.

  • Mount the parallel file system filesystem001 to the mount point /mnt/mount_path/ and allow the directory to be non-empty.
    ./obsfs filesystem001 /mnt/mount_path/ -o url=obs.ap-southeast-1.myhuaweicloud.com -o passwd_file=/etc/passwd-obsfs -o big_writes -o max_write=131072 -o nonempty -o use_ino
  • Mount the parallel file system filesystem001 to the /mnt/mount_path/ directory and set the write cache size.
    ./obsfs filesystem001 /mnt/mount_path/ -o url=obs.ap-southeast-1.myhuaweicloud.com -o passwd_file=/etc/passwd-obsfs -o big_writes -o max_write=131072 -o max_background=100 -o use_ino
  • Mount the filesystem001 parallel file system to the mount point /mnt/mount_path/ and allow other users to access the directory.
    ./obsfs filesystem001 /mnt/mount_path/ -o url=obs.ap-southeast-1.myhuaweicloud.com  -o passwd_file=/etc/passwd-obsfs -o big_writes -o max_write=131072 -o allow_other -o use_ino

If the value of this parameter is an IP address, add the -o use_path_request_style parameter to the mount command. Otherwise, a domain name resolution error is reported.

Mounting a Parallel File System Automatically upon Startup

The following uses CentOS 7 as an example to describe how to configure the parallel file system to automount at startup.

  1. Log in to the Linux server as user root.
  2. Run the following command to create a /home/startobsfs.sh script:

    vi /home/startobsfs.sh

  3. Press i to enter the editing mode, and write the following comments and mount commands to the /home/startobsfs.sh script.

    #!/bin/bash
    cd Absolute path of obsfs
    ./obsfs Parallel file system name Local mount directory -o url=Region endpoint address -o passwd_file=Key file path -o big_writes -o max_write=131072 -o use_ino Mount parameters

    For details about the mount command parameters, see 3 in section "Mounting a Parallel File System Manually."

  4. Press Esc and enter :wq to save and exit the script.
  5. Run the following command to grant the root user the permission to execute the script:

    chmod +x /home/startobsfs.sh

  6. Run the following command to grant the root user the permission to execute the rc.local file:

    chmod +x /etc/rc.d/rc.local

    The location of the rc.local file varies depending on the OS. In CentOS 7, the file is stored in /etc/rc.d/rc.local.

  7. Add the following command to the end of /etc/rc.d/rc.local, save the file, and exit:

    bash /home/startobsfs.sh

    If the /etc/rc.d/rc.local file contains an exit command, for example, exit 0, add the command prior to the exit command.

  8. Restart the server and verify the mounting.

    After the server is restarted, run the following command to check whether the parallel file system is successfully mounted:

    df -h

    If you no longer want the parallel file system to automount at startup, delete the script from rc.local.

Follow-up Procedure

Before adding, modifying, or deleting any parameters for a mounted parallel file system, you need to unmount the parallel file system and then mount it again. For details about how to unmount a parallel file system, see Unmounting a Parallel File System.