Skip to content
Merged
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
7 changes: 6 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
defaultCPU = 2
defaultMemory = 2
defaultDisk = 100
defaultRootDisk = 20
defaultKubernetesVersion = kubernetes.DefaultVersion

defaultMountTypeQEMU = "sshfs"
Expand Down Expand Up @@ -163,11 +164,12 @@ func init() {

root.Cmd().AddCommand(startCmd)
startCmd.Flags().StringVarP(&startCmdArgs.Runtime, "runtime", "r", docker.Name, "container runtime ("+runtimes+")")
startCmd.Flags().BoolVar(&startCmdArgs.Flags.ActivateRuntime, "activate", true, "set as active Docker/Kubernetes context on startup")
startCmd.Flags().BoolVar(&startCmdArgs.Flags.ActivateRuntime, "activate", true, "set as active Docker/Kubernetes/Incus context on startup")
startCmd.Flags().IntVarP(&startCmdArgs.CPU, "cpus", "c", defaultCPU, "number of CPUs")
startCmd.Flags().StringVar(&startCmdArgs.CPUType, "cpu-type", "", "the CPU type, options can be checked with 'qemu-system-"+defaultArch+" -cpu help'")
startCmd.Flags().Float32VarP(&startCmdArgs.Memory, "memory", "m", defaultMemory, "memory in GiB")
startCmd.Flags().IntVarP(&startCmdArgs.Disk, "disk", "d", defaultDisk, "disk size in GiB")
startCmd.Flags().IntVar(&startCmdArgs.RootDisk, "root-disk", defaultRootDisk, "disk size in GiB for the root filesystem")
startCmd.Flags().StringVarP(&startCmdArgs.Arch, "arch", "a", defaultArch, "architecture (aarch64, x86_64)")
startCmd.Flags().BoolVarP(&startCmdArgs.Flags.Foreground, "foreground", "f", false, "Keep colima in the foreground")
startCmd.Flags().StringVar(&startCmdArgs.Hostname, "hostname", "", "custom hostname for the virtual machine")
Expand Down Expand Up @@ -459,6 +461,9 @@ func prepareConfig(cmd *cobra.Command) {
if !cmd.Flag("disk").Changed {
startCmdArgs.Disk = current.Disk
}
if !cmd.Flag("root-disk").Changed {
startCmdArgs.RootDisk = current.RootDisk
}
if !cmd.Flag("kubernetes").Changed {
startCmdArgs.Kubernetes.Enabled = current.Kubernetes.Enabled
}
Expand Down
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"fmt"
"net"

"github.com/abiosoft/colima/util"
Expand Down Expand Up @@ -30,6 +31,7 @@ var (
type Config struct {
CPU int `yaml:"cpu,omitempty"`
Disk int `yaml:"disk,omitempty"`
RootDisk int `yaml:"rootDisk,omitempty"`
Memory float32 `yaml:"memory,omitempty"`
Arch string `yaml:"arch,omitempty"`
CPUType string `yaml:"cpuType,omitempty"`
Expand Down Expand Up @@ -127,6 +129,9 @@ func (c Config) DriverLabel() string {
return "QEMU"
}

// DiskGiB returns the string represent of the disk in GiB.
func DiskGiB(disk int) string { return fmt.Sprintf("%dGiB", disk) }

// CtxKey returns the context key for config.
func CtxKey() any {
return struct{ name string }{name: "colima_config"}
Expand Down
7 changes: 7 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Version v0.5.6 or lower](#version-v056-or-lower)
- [Issue with Docker bind mount showing empty](#issue-with-docker-bind-mount-showing-empty)
- [How can Docker version be updated?](#how-can-docker-version-be-updated)
- [How can I delete container data](#how-can-i-delete-container-data)

## How does Colima compare to Lima?

Expand Down Expand Up @@ -446,3 +447,9 @@ This is rectified by mounting the volume on the VM, and only then can docker map
Each Colima release includes the latest Docker version at the time of release.

From v0.7.6, there is a new `colima update` command to update the container runtime without needing to update Colima or to wait for the next Colima release.

## How can I delete container data

From v0.9.0, Colima utilises a different disk for the container runtime data. This guards against accidental data loss after deletion and the container data should be reinstated on `colima start`.

To clear all data, `colima delete --data` should be run instead. The `--data` flag ensures that the container data is also deleted.
6 changes: 5 additions & 1 deletion embedded/defaults/colima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Default: 2
cpu: 2

# Size of the disk in GiB to be allocated to the virtual machine.
# Size of the disk in GiB to be allocated to the virtual machine for container data.
# NOTE: value can only be increased after virtual machine has been created.
#
# Default: 100
Expand Down Expand Up @@ -233,6 +233,10 @@ mounts: []
# Default: ""
diskImage: ""

# Size of the disk in GiB for the root filesystem of the virtual machine.
# Default: 20
rootDisk: 20

# Environment variables for the virtual machine.
#
# EXAMPLE
Expand Down
3 changes: 3 additions & 0 deletions environment/vm/lima/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (l *limaVM) createRuntimeDisk(conf config.Config) error {
return fmt.Errorf("runtime disk provisioned for %s runtime. Delete container data with 'colima delete --data' before using another runtime", s.DiskRuntime)
}

l.limaConf.Disk = config.DiskGiB(conf.RootDisk)
l.limaConf.AdditionalDisks = append(l.limaConf.AdditionalDisks, limaconfig.Disk{
Name: config.CurrentProfile().ID,
Format: format,
Expand All @@ -49,6 +50,7 @@ func (l *limaVM) createRuntimeDisk(conf config.Config) error {

func (l *limaVM) useRuntimeDisk(conf config.Config) {
if !limautil.HasDisk() {
l.limaConf.Disk = config.DiskGiB(conf.Disk)
return
}

Expand All @@ -57,6 +59,7 @@ func (l *limaVM) useRuntimeDisk(conf config.Config) {
s, _ := store.Load()
format := !s.DiskFormatted // only format if not previously formatted

l.limaConf.Disk = config.DiskGiB(conf.RootDisk)
l.limaConf.AdditionalDisks = append(l.limaConf.AdditionalDisks, limaconfig.Disk{
Name: config.CurrentProfile().ID,
Format: format,
Expand Down
4 changes: 2 additions & 2 deletions environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err
if conf.Memory > 0 {
l.Memory = fmt.Sprintf("%dMiB", uint32(conf.Memory*1024))
}
if conf.Disk > 0 {
l.Disk = fmt.Sprintf("%dGiB", conf.Disk)
if conf.RootDisk > 0 {
l.Disk = fmt.Sprintf("%dGiB", conf.RootDisk)
}
l.SSH = limaconfig.SSH{LocalPort: conf.SSHPort, LoadDotSSHPubKeys: false, ForwardAgent: conf.ForwardAgent}
l.Containerd = limaconfig.Containerd{System: false, User: false}
Expand Down