kopia/kopia · error
windows GetCapacity
Error message
windows GetCapacity
What it means
On Windows, GetCapacity converts fs.RootPath to a UTF-16 pointer via windows.UTF16PtrFromString and calls windows.GetDiskFreeSpaceEx; failure of either is wrapped as "windows GetCapacity". This reports that Windows could not resolve the path or query free disk space for the volume containing the storage root.
Solutions
- Verify the drive letter / UNC path in RootPath is valid and accessible (run dir <path> in cmd)
- Check disk connectivity and remap disconnected network drives
- Normalize the path to a Windows-style absolute path before configuring storage
- Ensure the path string contains only characters valid for windows.UTF16PtrFromString (no embedded NULs, no wildcards)
Example fix
// before
st, err := fs.New(ctx, fs Options{Path: "/mnt/data"})
// after
st, err := fs.New(ctx, fs Options{Path: `D:\Backups\kopia`}) // valid Windows path
if err != nil {
log.Fatal(err)
} Defensive patterns
Strategy: validation
Validate before calling
func validWindowsPath(p string) error {
if p == "" || strings.ContainsAny(p, "*?\x00") {
return fmt.Errorf("invalid Windows path: %q", p)
}
if _, err := os.Stat(p); err != nil {
return err
}
return nil
} Try / catch
cap, err := st.GetCapacity(ctx)
if err != nil && strings.Contains(err.Error(), "windows GetCapacity") {
// check drive mapping / path validity before retrying
} Prevention
- Use Windows-native absolute paths or proper UNC paths (\\\\server\\share)
- Confirm drives are mapped at process start (logon scripts may not map for services)
- Avoid embedded NULs and wildcard characters in configured paths
- Verify free-space queries with dir before configuring the storage
When it happens
Trigger: Calling GetCapacity when fs.RootPath is an invalid Windows path (illegal characters like : * ?, empty string), points to a non-existent/unmapped drive letter, or the volume is unavailable (disconnected network drive).
Common situations: Path using forward slashes or UNC path misformatted; USB/network drive disconnected; drive letter changed after the storage was opened; path exceeding MAX_PATH limitations.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- can't get local fs entry
- can't re-create top-level directory
- entry not found
- entry not found : parent is not a directory
- error resolving config file path
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/db6a52aa1f3fbe00.
Report an issue: GitHub.
Appendix: source
Thrown at repo/blob/filesystem/filesystem_storage_capacity_windows.go:19
//go:build windows
package filesystem
import (
"context"
"github.com/pkg/errors"
"golang.org/x/sys/windows"
"github.com/kopia/kopia/repo/blob"
)
func (fs *fsStorage) GetCapacity(_ context.Context) (blob.Capacity, error) {
var c blob.Capacity
pathPtr, err := windows.UTF16PtrFromString(fs.RootPath)
if err != nil {
return blob.Capacity{}, errors.Wrap(err, "windows GetCapacity")
}
err = windows.GetDiskFreeSpaceEx(pathPtr, nil, &c.SizeB, &c.FreeB)
if err != nil {
return blob.Capacity{}, errors.Wrap(err, "windows GetCapacity")
}
return c, nil
}
View on GitHub (pinned to 82495e54b5)