henrygd/beszel · error
failed to write embedded smartctl: %w
Error message
failed to write embedded smartctl: %w
What it means
Thrown by ensureEmbeddedSmartctl when os.WriteFile fails to write the embedded smartctl.exe binary into the temp directory. This wraps the OS write error (permission denied, disk full, path locked). The extracted executable is how the agent provides smartctl without a separate install.
Source
Thrown at agent/smart_windows.go:32
var embeddedSmartctl []byte
var (
smartctlOnce sync.Once
smartctlPath string
smartctlErr error
)
func ensureEmbeddedSmartctl() (string, error) {
smartctlOnce.Do(func() {
destDir := filepath.Join(os.TempDir(), "beszel", "smartmontools")
if err := os.MkdirAll(destDir, 0o755); err != nil {
smartctlErr = fmt.Errorf("failed to create smartctl directory: %w", err)
return
}
destPath := filepath.Join(destDir, "smartctl.exe")
if err := os.WriteFile(destPath, embeddedSmartctl, 0o755); err != nil {
smartctlErr = fmt.Errorf("failed to write embedded smartctl: %w", err)
return
}
smartctlPath = destPath
})
return smartctlPath, smartctlErr
}
View on GitHub (pinned to b38fb7dafa)
Solutions
- Delete a stale/locked smartctl.exe in %TEMP%\\beszel\\smartmontools and restart the agent
- Check the wrapped %w OS error for the exact cause (access denied vs disk full)
- Exclude the path from antivirus real-time scanning or quarantine rules
- Ensure the agent user has write+execute permission on the temp directory
Example fix
// before
if err := os.WriteFile(destPath, embeddedSmartctl, 0o755); err != nil {
return fmt.Errorf("failed to write embedded smartctl: %w", err)
}
// after
if err := os.WriteFile(destPath, embeddedSmartctl, 0o755); err != nil {
os.Remove(destPath) // clear possibly locked/quarantined stale binary
return fmt.Errorf("failed to write embedded smartctl to %s: %w", destPath, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
dir := filepath.Join(os.TempDir(), "beszel", "smartmontools")
probe, err := os.CreateTemp(dir, ".probe-*")
if err == nil {
probe.Close()
os.Remove(probe.Name())
} Try / catch
path, err := ensureEmbeddedSmartctl()
if err != nil {
if strings.Contains(err.Error(), "write embedded smartctl") {
os.Remove(filepath.Join(os.TempDir(), "beszel", "smartmontools", "smartctl.exe"))
}
return fmt.Errorf("SMART disabled: %w", err)
} Prevention
- Exclude %TEMP%\\beszel from antivirus real-time scanning
- Remove stale smartctl.exe before restarting the agent
- Check free disk space before deployment
- Prefer NTFS over FAT/exFAT for the temp volume so exec permissions behave
When it happens
Trigger: os.WriteFile(destPath, embeddedSmartctl, 0o755) fails after the directory was created successfully — typically because writing or setting exec permission on smartctl.exe is denied.
Common situations: Antivirus quarantines or locks the freshly written smartctl.exe; file already exists as a locked running process; disk full; FAT/exFAT volumes ignoring or rejecting exec permission bits.
Related errors
- failed to create smartctl directory: %w
- failed to create temp directory: %w
- battery tag not returned
- battery capacity unknown
- data directory not found
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/55102c705207ffdd.
Report an issue: GitHub.