{"record":{"id":"7ca12a81e9e69d70","repo":"abiosoft/colima","slug":"error-preparing-storage-pools-directory-w","errorCode":null,"errorMessage":"error preparing storage pools directory: %w","messagePattern":"error preparing storage pools directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/container/incus/incus.go","lineNumber":486,"sourceCode":"\t\treturn err\n\t}\n\n\tif out != poolName {\n\t\treturn fmt.Errorf(\"default storage pool recovery failure\")\n\t}\n\n\treturn nil\n}\n\nfunc (c *incusRuntime) wipeDisk(size int) error {\n\t// prepare by deleting relevant files/directories\n\tdeleteScript := strings.NewReplacer(\n\t\t\"{disk_file}\", poolDiskFile,\n\t\t\"{meta_dir}\", poolMetaDir,\n\t).Replace(\"sudo rm -rf {disk_file} {meta_dir}\")\n\n\tif err := c.guest.RunQuiet(\"sh\", \"-c\", deleteScript); err != nil {\n\t\treturn fmt.Errorf(\"error preparing storage pools directory: %w\", err)\n\t}\n\n\t// create new storage pool\n\tvar diskSize = fmt.Sprintf(\"%dGiB\", size)\n\treturn c.guest.RunQuiet(\"sudo\", \"incus\", \"storage\", \"create\", poolName, storageDriver, \"size=\"+diskSize)\n}\n\n// migrationScript returns a script that migrates from the old disk layout\n// (separate incus-disks and incus-backups subdirectories) to the new layout\n// (full /var/lib/incus directory).\nfunc migrationScript() string {\n\tmountPoint := limautil.MountPoint()\n\treturn `MOUNT_POINT=\"` + mountPoint + `\"\nif [ -d \"$MOUNT_POINT/incus-disks\" ] && [ ! -d \"$MOUNT_POINT/incus\" ]; then\n  mkdir -p \"$MOUNT_POINT/incus\"\n  if [ -d /var/lib/incus ]; then\n    cp -a /var/lib/incus/. \"$MOUNT_POINT/incus/\"\n  fi","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/container/incus/incus.go#L468-L504","documentation":"wipeDisk begins by running 'sudo rm -rf <disk_file> <meta_dir>' in the guest to clear old pool artifacts before recreating storage; that cleanup command failed. rm failures here usually mean the pool file is busy (zfs still holding it), sudo failed, or the guest filesystem errored.","triggerScenarios":"guest.RunQuiet('sh','-c', 'sudo rm -rf ...') errors: zfs pool still imported and holding the .img, another process has files open under the meta dir, permissions changed, guest disk in read-only/error state.","commonSituations":"Wiping after a failed recovery where the pool got imported in between, concurrent incus operations in the guest, disk I/O errors on the data volume.","solutions":["Check what holds the files: 'colima ssh -- sudo lsof +D /var/lib/incus; sudo zpool list'","Export any imported pool first: 'colima ssh -- sudo zpool export <pool>' then retry","Retry after a full stop/start: 'colima stop && colima start'","If the data volume is faulty, recreate the VM: 'colima delete && colima start'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure nothing holds the pool before wiping\nif c.poolImported() {\n    _ = c.guest.RunQuiet(\"sh\", \"-c\", \"sudo zpool export \"+poolName)\n}","typeGuard":null,"tryCatchPattern":"if err := c.guest.RunQuiet(\"sh\", \"-c\", deleteScript); err != nil {\n    // busy files clear after services stop; retry once post-stop\n    _ = c.systemctl.Stop(\"incus.service\")\n    if err2 := c.guest.RunQuiet(\"sh\", \"-c\", deleteScript); err2 != nil {\n        return fmt.Errorf(\"error preparing storage pools directory: %w\", err2)\n    }\n}","preventionTips":["Stop incus services before manual cleanup of disk files","Export zfs pools before removing their .img backing files","Monitor guest disk health (dmesg I/O errors) and replace flaky volumes"],"tags":["incus","storage","filesystem","cleanup"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}