Cannot Delete VCN- Mount Target VNIC Still Attached

A mount target is an NFS endpoint that lives in a VCN subnet of your choice and provides network access for the file systems that it exports. Each mount target has a VNIC to enable network access. Mount target VNICs that remain in a VCN must be deleted before you can delete the VCN.

Deleting a mount target also deletes all of the exports of associated file systems that exist in its export set. Data in the file systems is not affected, but the file systems are no longer available through the deleted mount target. You can create new exports for the file system in a different mount target and subnet.

For more information, see Managing Mount Targets.

To resolve this issue using the Console
  1. Note the OCID in the error message you receive when you attempt to delete the VCN. Mount target OCIDs contain the identifier mounttarget. For example:

    ocid1.mounttarget.oc1.phx.examplemounttargetid
  2. Note the Compartment and Subnet information of the VCN you want to delete, and to assist navigation and choosing the correct mount target to delete.
  3. Delete the mount target using the following steps:

    1. Open the navigation menu and click Storage. Under File Storage, click Mount Targets.
    2. In the List Scope section, select a compartment.

    3. Find the mount target you want to delete.
    4.  Click the Actions menu (Actions Menu), and then click Delete.
    Caution

    Deleting the mount target also deletes all of its exports of associated file systems. File systems are no longer available through the deleted mount target.

    Tip

    In the Console, the mount target OCID can be seen in the mount target details page in the Mount Target Information tab. See Managing Mount Targets for more information about how to view the mount target details page. Be sure the mount target OCID seen on the details page matches the mount target OCID provided by the VCN delete process error message.
  4. Delete the VCN.
To resolve this issue using the API
  1. Note the OCID in the error message you receive when you attempt to delete the VCN. Mount target OCIDs contain the identifier mounttarget. For example:

    ocid1.mounttarget.oc1.phx.examplemounttargetid
  2. Delete the mount target using the following steps:

    1. Use DeleteMountTarget to delete the mount target. For example:

      DELETE /20171215/mountTargets/ocid1.mounttarget.oc1.phx.examplemounttargetid
      Host: filestorage.us-phoenix-1.oraclecloud.com
      <authorization and other headers
    2. You can use GetMountTarget to verify that the mount target has been deleted. For example:

      GET /20171215/mountTargets/ocid1.mounttarget.oc1.phx.examplemounttargetid?compartmentId=<compartmentId>
      Host: filestorage.us-phoenix-1.oraclecloud.com
      <authorization and other headers>

      The API should return Status 404 Not Found.

To resolve this issue using the CLI

For general information about using the CLI, see Command Line Interface (CLI).

  1. Note the OCID in the error message you receive when you attempt to delete the VCN. Mount target OCIDs contain the identifier mounttarget. For example:

    ocid1.mounttarget.oc1.phx.examplemounttargetid
  2. Delete the mount target using the following steps:

    1. Use oci fs mount-target delete to delete the mount target. For example:

      oci fs mount-target delete --mount-target-id ocid1.mounttarget.oc1.phx.examplemounttargetid
    2. You can use oci fs export get to verify that the mount target has been deleted. For example:

      oci fs export get --export-id ocid1.mounttarget.oc1.phx.examplemounttargetid

      The CLI should return a message indicating the mount target is not found. For example:

      {
          "code": "NotAuthorizedOrNotFound",
          "message": "Authorization failed or requested resource not found.",
          "opc-request-id": "<requestID>",
          "status": 404
      }

If you still can't delete the VCN, be sure there are no other resources remaining in the VCN that might prevent it. For more information, see Subnet or VCN Deletion.