diff --git a/CubeMaster/pkg/templatecenter/template_image.go b/CubeMaster/pkg/templatecenter/template_image.go index a1c9959..46e67b8 100644 --- a/CubeMaster/pkg/templatecenter/template_image.go +++ b/CubeMaster/pkg/templatecenter/template_image.go @@ -72,6 +72,7 @@ const ( fallbackArtifactStoreDir = "cubemaster-rootfs-artifacts-store" rootfsWritableVolumeName = "cube_rootfs_rw" defaultDistributionWorkers = 4 + requiredExtractionSpace = 20 << 30 ) var getTemplateImageConfig = config.GetConfig @@ -2000,12 +2001,29 @@ func artifactModelToInfo(record *models.RootfsArtifact) *types.RootfsArtifactInf LastError: record.LastError, } } +func checkPartition(tempPath string) error { + var stat syscall.Statfs_t + err := syscall.Statfs(tempPath, &stat) + if err != nil { + return fmt.Errorf("error! Failed to check disk space at %s: %w", tempPath, err) + } + available := stat.Bavail * uint64(stat.Bsize) + if available < requiredExtractionSpace { + return fmt.Errorf("error: not enough space on %s\nRequired 20GiB\n Available: %dGiB", tempPath, available>>30) + } + return nil +} func artifactWorkRootDir() string { + tempDir := os.TempDir() if value := strings.TrimSpace(os.Getenv("CUBEMASTER_ROOTFS_ARTIFACT_DIR")); value != "" { return value } - return filepath.Join(os.TempDir(), "cubemaster-rootfs-artifacts") + if err := checkPartition(tempDir); err == nil{ + return filepath.Join(tempDir, "cubemaster-rootfs-artifacts") + } + fallbackDir := artifactStoreRootDir() + return filepath.Join(fallbackDir, "tmp", "cubemaster-rootfs-artifacts") } func artifactStoreRootDir() string { diff --git a/README.md b/README.md index de7758c..442f9aa 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,8 @@ Cube Sandbox requires an x86_64 Linux environment with KVM support — **WSL 2** > - **Windows users**: run `wsl --install` in an admin PowerShell to set up WSL 2 (requires Windows 11 22H2+, with nested virtualization enabled in BIOS / WSL). > - **Bare-metal / physical machine users**: grab an x86_64 Linux physical machine, or rent a bare-metal server from a cloud provider. > - **Ordinary cloud VM users**: no bare-metal required — install the PVM host kernel to enable KVM on any standard cloud VM. See [PVM Deployment](./docs/guide/pvm-deploy.md). +> +> **NOTE on storage**: Ensure the partition hosting the CubeMaster storage directory (usually `/data`) has at least 20GiB of free space for template creation. Once your environment is ready, launch your first sandbox in four steps: