Sub topic 13
Legacy DBFS mounts
This chapter assumes you know what DBFS is, how dbfs:/ paths look, and how to run dbutils commands in a notebook. You will learn what a mount is, how to recognize one in old code, and what replaces it.
What a mount is
A mount attaches a cloud storage location to a path under /mnt in DBFS. Once mounted, code can read the bucket or container through that short path instead of a full cloud URI.
# Legacy pattern: mount an S3 bucket (requires an instance profile on the cluster)
dbutils.fs.mount("s3a://my-company-raw", "/mnt/raw")
display(dbutils.fs.ls("/mnt/raw"))
df = spark.read.csv("/mnt/raw/sales.csv", header=True)The source URI depends on the cloud. S3 uses s3a://, Azure Data Lake Storage uses abfss://, and so on. Credentials are passed through the extra_configs argument or come from the cluster configuration.
Why mounts are legacy
Mounts have problems that Unity Catalog volumes were built to fix:
- A mount is visible to every user in the workspace. Anyone who can run code can read it, whatever their own permissions on the storage.
- Credentials are set up once, by whoever creates the mount. They are shared, not per user.
- The mount lives in one workspace. Another workspace must define its own mount, and the two definitions can drift apart.
- Mounts bypass Unity Catalog governance. No grants, lineage or audit entries apply at the file level.
- Mounts are not supported on some Unity Catalog compute, such as standard (shared) access mode clusters.
Recognizing and inspecting mounts
In old notebooks, any path that starts with /mnt/ or dbfs:/mnt/ goes through a mount. Use these commands to see what exists:
for m in dbutils.fs.mounts():
print(m.mountPoint, "->", m.source)
# After another user changes a mount, refresh this cluster's cache
dbutils.fs.refreshMounts()
# Remove a mount you no longer need
dbutils.fs.unmount("/mnt/raw")Unmounting removes only the pointer. It does not delete data in the cloud storage.
What replaces a mount
An external volume points at a path in cloud storage, but access goes through Unity Catalog. The storage location must first be covered by an external location, which holds the credential.
CREATE EXTERNAL VOLUME main.default.raw_files
LOCATION 's3://my-company-raw/';The old mount path then maps to a volume path:
| Legacy | Replacement |
|---|---|
| `/mnt/raw/sales.csv` | `/Volumes/main/default/raw_files/sales.csv` |
| Shared workspace credential | Credential held by the external location |
| Access for everyone in the workspace | `READ VOLUME` and `WRITE VOLUME` grants |
Common errors
- Mount point already exists. Calling
mounton a path that is already mounted fails. Checkdbutils.fs.mounts()first, or unmount before you remount. - Stale mount on a running cluster. Another user changed the mount, but your cluster still sees the old definition. Run
dbutils.fs.refreshMounts(). - Mount commands fail on Unity Catalog compute. This is expected on compute that does not support mounts. Migrate to a volume instead of working around it.
Exercise
A notebook reads /mnt/raw/orders/2024.csv. Name two reasons to replace the mount with an external volume, and write the new path if the volume is main.sales.raw_files and the file layout stays the same.
Show answer
Any two of: mounts give every workspace user the same access, they use one shared credential, they bypass Unity Catalog governance, and they are unsupported on some Unity Catalog compute. The new path is /Volumes/main/sales/raw_files/orders/2024.csv.