Mounting File Systems on UNIX-Based Instances

Instance users of UNIX based operating systems, such as Linux and Oracle Solaris, can use OS commands to mount and access file systems.

Mount targets serve as network access points for file systems. After your mount target is assigned an IP address, you can use it together with the export path to mount the file system.

On the instance from which you want to mount the file system, you need to install an NFS client package and create a mount point. When you mount the file system, the mount point effectively represents the root directory of the File Storage file system, allowing you to write files to the file system from the instance.

Prerequisites

Note:

Only for NFSv4 Mounts in Oracle Linux instances – If you find that the file system owner is assigned as nobody instead of the actual user who mounts the file system, and if you have not set identity squash, you might need to edit the /etc/idmapd.conf file. In the file, set the DOMAIN entry to either localdomain or to the Active Directory domain name, if applicable. After the change, run service rpcidmapd restart to restart the rpcidmapd service.

Defining settings in the /etc/idmapd.conf file is specific to Oracle Linux, and there are other ways to configure the domain depending on the OS in use. Consult your operating system documentation.

For more conceptual information, refer to the File Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide.

Obtaining the Mount Target IP Address

To mount a file system, you need to know the private IP address of the mount target that has the export for the file system.

Using the Compute Web UI

  1. In the navigation menu, under File Storage, click Mount Target.

  2. Click the Mount Target name to see the details page.

    The IP address is displayed.

Using the OCI CLI

  1. Gather the information that you need to run the commands:

    • Mount target OCID (oci fs mount-target list)

  2. Run this command to get the mount target IP ID.

    Syntax:

    oci fs mount-target get 
    --mount-target-id mount_target_OCID

    Example:

    oci fs mount-target get 
    --mount-target-id ocid1.mounttarget.uniqueID
    {
      "data": {
        "availability-domain": "AD-1",
        "compartment-id": "ocid1.tenancy.uniqueID
        "defined-tags": {
          "Finance": {
            "CostCenter": "admin"
          }
        },
        "display-name": "mount-target01",
        "export-set-id": "ocid1.exportset.uniqueID",
        "freeform-tags": {},
        "id": "ocid1.mounttarget.uniqueID",
        "lifecycle-details": null,
        "lifecycle-state": "ACTIVE",
        "nsg-ids": [],
        "private-ip-ids": [
          "ocid1.privateip.uniqueID"
        ],
        "subnet-id": "ocid1.subnet.uniqueID",
        "time-created": "2021-09-01T18:45:25.251048+00:00"
      },
      "etag": "c2f84c0b-d0b5-422c-9761-9e43d7fc4214"
    }
  3. Run this command to get the mount target IP address.

    Syntax (entered on a single line):

    oci network private-ip get --private-ip-id mount_target_IP_OCID

    Example:

    oci network private-ip get  \
    --private-ip-id ocid1.….….….uniqueID{
      "data": {
        "availability-domain": "AD-1",
        "compartment-id": "ocid1.tenancy..….….….uniqueID",
        "defined-tags": {},
        "display-name": "privateip20210901184525",
        "freeform-tags": {},
        "hostname-label": null,
        "id": "ocid1.privateip.….….….uniqueID",
        "ip-address": "10.200.0.3",
        "is-primary": false,
        "subnet-id": "ocid1.subnet.….….….uniqueID",
        "time-created": "2021-09-01T18:45:25.406808+00:00",
        "vlan-id": null,
        "vnic-id": "ocid1.vnic.….….….uniqueID"
      },
      "etag": "c98377e4-ae89-46cf-9c61-52aea68a3476"
    }

Mounting a File System on Linux, Red Hat, or CentOS

  1. Log into the instance where you want to mount the file system.

    See Connecting to a Compute Instance.

    Example:

    ssh user@192.0.2.0
  2. Install the NFS client using this command:

    sudo yum install nfs-utils
  3. Create a directory that will be used as the mount point.

    Replace <yourmountpoint> with a directory name of your choice. Example: /mnt/mountpoint-A

    sudo mkdir -p <yourmountpoint>
  4. Mount the file system.

    Caution:

    Omitting the -o nosuid option can allow unprivileged users to escalate their permissions to 'root'. The nosuid option disables set-user-identifier or set-group-identifier bits within the mounted system, which are rarely used.

    Example:

    sudo mount -t nfs -o nfsvers=<version>,nosuid <10.x.x.x>:<fs-export-path>
                               <yourmountpoint>
    • Replace <version> with one of the following, based on the NFS protocol version you want to use:

      • 3,noacl

      • 4.0

      • 4.1

    • Replace <10.x.x.x> with the mount target's private IP address. See Obtaining the Mount Target IP Address.

    • Replace <fs-export-path> with the export path that was generated when the export was created. See Creating an Export for a File System.

    • Replace <yourmountpoint>with the full path to the local mount point.

  5. View the mounted file system.

    df -h
  6. Write a file to the file system.

    Replace <yourmountpoint> with the path to the local mount point and <filename>with your file name.

    sudo touch /mnt/<yourmountpoint>/<filename>
  7. Verify that you can access the file system and view the file.

    Replace yourmountpoint with the path to the local mount point.

    cd <yourmountpoint>
    ls
  8. Add the file system mount information to the appropriate mount file for your OS.

    So far, the file system is manually mounted to the client. If the client is rebooted, the file system won't automatically mount unless you add it to the mount file (for example the /etc/fstab or /etc/vfstab file).

Mounting a File System on Ubuntu or Debian

Operating Systems and versions of operating systems differ in the way software is added. Consult the documentation for our specific operating system for details.

  1. On the NFS client, open a command window, and install the NFS client using this command:

    sudo apt-get install nfs-common
  2. Create a directory that will be used as the mount point.

    Replace <yourmountpoint> with a directory name of your choice. Example: /mnt/mountpoint-A

    sudo mkdir -p <yourmountpoint>
  3. Mount the file system.

    Caution:

    Omitting the -o nosuid option might allow unprivileged users to escalate their permissions to 'root'. The nosuid option disables set-user-identifier or set-group-identifier bits within the mounted system, which are rarely used.

    Example:

    sudo mount -t nfs -o nfsvers=<version>,nosuid <10.x.x.x>:<fs-export-path>
                               <yourmountpoint>
    • Replace <version> with one of the following, based on the NFS protocol version you want to use:

      • 3,noacl

      • 4.0

      • 4.1

    • Replace <10.x.x.x> with the mount target's private IP address. See Obtaining the Mount Target IP Address.

    • Replace <fs-export-path> with the export path that was generated when the export was created.

      See Creating an Export for a File System.

    • Replace <yourmountpoint>with the full path to the local mount point.

  4. View the file system.

    df -h
  5. Write a file to the file system.

    Replace <yourmountpoint> with the path to the local mount point and <filename>with your file name.

    sudo touch /mnt/<yourmountpoint>/<filename>
  6. Verify that you can access the file system and view the file.

    Replace yourmountpoint with the path to the local mount point.

    cd <yourmountpoint>
    ls
  7. Add the file system mount information to the appropriate mount file for your OS.

    So far, the file system is manually mounted to the client. If the client is rebooted, the file system won't automatically mount unless you add it to the mount file (for example the /etc/fstab or /etc/vfstab file).

Configuring a File System to Automatically Mount (Linux Instances)

On Linux instances, if you want to automatically mount exported file systems during an instance boot, you need to add the mount information in the /etc/fstab file.

  1. Log into the instance where you want the file system mounted.

    See Connecting to a Compute Instance.

  2. Create a mount point, if one has not been created.

    Example:

    mkdir /mnt/fs01
  3. Open the /etc/fstab file in an editor and add a line for the nfs file systems you want automatically mounted.

    This is an example of an /etc/fstab file entry.

    192.0.2.0:/export/3ywflz8hhqfde81miewqwjfd049zju69502t9ouo6shzidr4dndaz1hd6qfi /mnt/fs01 nfs nfsvers=4.1,nosuid,nofail 0 0

    The /etc/fstab file space-separated fields are specified with these entries:

    • Field 1: Device to mount. For network file systems, specify: <mount target IP> : <export_path>

      See Obtaining the Mount Target IP Address and Creating an Export for a File System.

    • Field 2: Full path of the mount point on the instance.

    • Field 3: File system type. In this case, specify nfs.

    • Field 4: NFS mount options separated with commas, such as:

      nfsvers=<version>,nosuid,nofail
      • nfsvers= where <version> is one of the following:

        • 3,noacl

        • 4.0

        • 4.1

      • nosuid – prevents unprivileged users from escalating their permissions to root.

      • nofail – Ensures that an unavailable file system does not cause the instance reboot process to fail.

      In this case, use the same options as described in Mounting a File System on Linux, Red Hat, or CentOS. Each option is separated by a comma (no spaces).

    • Field 5: Obsolete option for dump backups. Specify 0 (zero) for no dump backup.

    • Field 6: File system check (fsck) order. Specify 0 (zero) for no check.

  4. Use this command to mount the volumes that are in the /etc/fstab file:

    sudo mount -a

    If you get any error messages, fix the cause before proceeding.

  5. Verify that the file systems are mounted:

    mount | grep nfs
  6. To verify that the file system will automatically mount, reboot the instance.

    sudo reboot
    
  7. After the reboot, log into the instance and check to see if the nfs file system is mounted.

    mount | grep nfs