Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CubeMaster/pkg/templatecenter/template_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const (
fallbackArtifactStoreDir = "cubemaster-rootfs-artifacts-store"
rootfsWritableVolumeName = "cube_rootfs_rw"
defaultDistributionWorkers = 4
requiredExtractionSpace = 20 << 30
)

var getTemplateImageConfig = config.GetConfig
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Loading