{"record":{"id":"ead62dd10a24f6bf","repo":"hashicorp/nomad","slug":"failed-creating-alloc-mounts-dir-w","errorCode":null,"errorMessage":"failed creating alloc mounts dir: %w","messagePattern":"failed creating alloc mounts dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/client.go","lineNumber":736,"sourceCode":"\t\t// node is accessible. Upgrade drops and logs corrupt state it\n\t\t// encounters, so failing to start the agent should be extremely\n\t\t// rare.\n\t\treturn fmt.Errorf(\"failed to upgrade state database: %v\", err)\n\t}\n\n\tc.stateDB = db\n\n\t// Ensure host_volumes_dir config is not empty.\n\tif conf.HostVolumesDir == \"\" {\n\t\tconf = c.UpdateConfig(func(c *config.Config) {\n\t\t\tc.HostVolumesDir = filepath.Join(conf.StateDir, \"host_volumes\")\n\t\t})\n\t}\n\n\t// Ensure the alloc mounts dir exists if we are configured with a custom path.\n\tif conf.AllocMountsDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocMountsDir, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating alloc mounts dir: %w\", err)\n\t\t}\n\t}\n\n\t// Ensure the alloc dir exists if we are configured with a custom path.\n\tif conf.AllocDir != \"\" {\n\t\tif err := os.MkdirAll(conf.AllocDir, 0o711); err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating alloc dir: %w\", err)\n\t\t}\n\t} else {\n\t\t// Otherwise make a temp directory to use.\n\t\tp, err := os.MkdirTemp(\"\", \"NomadClient\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed creating temporary directory for the AllocDir: %v\", err)\n\t\t}\n\n\t\tp, err = filepath.EvalSymlinks(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to find temporary directory for the AllocDir: %v\", err)","sourceCodeStart":718,"sourceCodeEnd":754,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L718-L754","documentation":"If conf.AllocMountsDir is set to a custom path, the client runs os.MkdirAll(path, 0o711) during init to guarantee it exists. Failure (any MkdirAll error) aborts client startup with this message. The alloc mounts dir is where allocation mount data is staged, so it is mandatory.","triggerScenarios":"client init with alloc_mounts_dir (or derived alloc dir) configured: os.MkdirAll(conf.AllocMountsDir, 0o711) returns error.","commonSituations":"Custom path on a read-only mount or full disk, parent directory owned by another user with no write permission, SELinux/AppArmor denial, or the path existing as a regular file instead of a directory.","solutions":["Pre-create the directory manually with correct ownership: sudo mkdir -p <path> && sudo chown nomad:nomad <path> && chmod 711 <path>.","Check the wrapped %w error for ENOSPC/EROFS/EACCES and fix disk space, mount flags, or permissions accordingly.","Verify the configured alloc_mounts_dir path is a directory, not a file, and lives on a local writable filesystem."],"exampleFix":"// before (config.hcl)\nclient { alloc_mounts_dir = \"/mnt/ro-disk/nomad/mounts\" }  // read-only mount\n// after\nclient { alloc_mounts_dir = \"/var/lib/nomad/alloc_mounts\" }\n# or fix permissions first:\n# sudo mkdir -p /mnt/disk/nomad/mounts && sudo chown nomad:nomad /mnt/disk/nomad/mounts","handlingStrategy":"validation","validationCode":"func ensureDirWritable(p string) error {\n    fi, err := os.Stat(p)\n    if err == nil && !fi.IsDir() {\n        return fmt.Errorf(\"%s exists and is not a directory\", p)\n    }\n    return os.MkdirAll(p, 0o711)\n}\n// call before constructing client config\nif err := ensureDirWritable(cfg.AllocMountsDir); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := clientInit(); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && strings.Contains(err.Error(), \"failed creating alloc mounts dir\") {\n        log.Printf(\"fix path %s: %v\", pe.Path, pe.Err)\n    }\n}","preventionTips":["Pre-create custom alloc_mounts_dir with correct ownership (nomad user) and 0711 mode","Keep alloc mounts on a writable local volume","Check SELinux/AppArmor policies for the configured path","Ensure the path is a directory, not a file"],"tags":["client-init","filesystem","permissions","directory"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}