#Volume Fork
Volume Fork creates a new Volume from an existing Volume using JuiceFS Copy-on-Write (COW) clone.
Why Use Fork?#
- Fast Clone: Create a new Volume quickly without copying all data blocks
- Storage Efficient: Source and fork share unchanged data blocks
- Write Isolation: Writes to the fork do not affect the source Volume
- Great for Branching: Create per-task or per-experiment data branches
How Fork Works#
API#
- Endpoint:
POST /api/v1/sandboxvolumes/{id}/fork - Path Parameter:
idis the source Volume ID - Request Body: Optional, used to override inherited configuration from the source Volume
- Success Response:
201 Created, returns the newSandboxVolumeincludingsource_volume_id - Common Errors:
400(invalidaccess_mode),404(source Volume not found or not visible to your team)
Optional Request Fields#
| Field | Type | Description |
|---|---|---|
access_mode | enum | Access mode for the forked Volume. If omitted, defaults to RWO |
cache_size | string | Cache size for the forked Volume. If omitted, inherits from source Volume |
buffer_size | string | Buffer size for the forked Volume. If omitted, inherits from source Volume |
prefetch | integer | Number of blocks to prefetch. If omitted, inherits from source Volume |
writeback | boolean | Enable or disable write-back cache. If omitted, inherits from source Volume |
Fork a Volume#
goforked, err := client.ForkVolume(ctx, volume.ID, &apispec.ForkVolumeRequest{ AccessMode: apispec.NewOptVolumeAccessMode(apispec.VolumeAccessModeRWO), CacheSize: apispec.NewOptString("2G"), BufferSize: apispec.NewOptString("64M"), Prefetch: apispec.NewOptInt(10), Writeback: apispec.NewOptBool(false), }) if err != nil { panic(err) } fmt.Printf("Forked Volume: %s ", forked.ID) if sourceVolumeID, ok := forked.SourceVolumeID.Get(); ok { fmt.Printf("Source Volume: %s ", sourceVolumeID) } else { fmt.Println("Source Volume: <nil>") }
Verify Isolation#
- Mount both the source and the forked Volume to a Sandbox at different paths.
- Modify a file only in the forked Volume.
- Read the same file from the source Volume and verify it is unchanged.
ℹ
Fork uses COW at the filesystem metadata layer, so unchanged data is shared while changed data is isolated.
ℹ
Fork does not require the source Volume to be mounted.
Next Steps#
Self Hosted
Deploy Sandbox0 on your own infrastructure
Snapshots
Create and restore volume snapshots
Volume Overview
Volume lifecycle and configuration