Some helpful commands
limactl start ./ubuntu2404.yaml limactl list
limactl shell ubuntu2404
limactl stop ubuntu2404 limactl restart ubuntu2404
| #!/bin/bash | |
| set -e | |
| sudo swapoff -a | |
| # Install build dependencies (apt handles already-installed packages) | |
| sudo apt-get update | |
| sudo apt-get install -y gperf build-essential pkg-config | |
| # Match the macos root directory | |
| export HOME=/Users/$USER | |
| pushd $HOME/go/src/github.com/containerd/containerd | |
| # Download and extract Go if not already present | |
| mkdir -p $HOME/linux/ | |
| # Detect architecture | |
| ARCH=$(uname -m) | |
| case $ARCH in | |
| x86_64) GO_ARCH="amd64" ;; | |
| aarch64) GO_ARCH="arm64" ;; | |
| armv7l) GO_ARCH="armv6l" ;; | |
| *) echo "Unsupported architecture: $ARCH"; exit 1 ;; | |
| esac | |
| GO_TARBALL="$HOME/linux/go1.25.5.linux-${GO_ARCH}.tar.gz" | |
| if [ ! -f "$GO_TARBALL" ]; then | |
| echo "Downloading Go for ${GO_ARCH}..." | |
| curl -L "https://dl.google.com/go/go1.25.5.linux-${GO_ARCH}.tar.gz" -o "$GO_TARBALL" | |
| fi | |
| if [ ! -x "$HOME/linux/go/bin/go" ]; then | |
| echo "Extracting Go..." | |
| tar -C $HOME/linux/ -xzf "$GO_TARBALL" | |
| fi | |
| export PATH=$PATH:$HOME/linux/go/bin | |
| # Install seccomp if not present | |
| if ! pkg-config --exists libseccomp 2>/dev/null; then | |
| echo "Installing seccomp..." | |
| script/setup/install-seccomp | |
| else | |
| echo "Skipping seccomp (already installed)" | |
| fi | |
| # Install runc if not present | |
| if ! command -v runc &>/dev/null; then | |
| echo "Installing runc..." | |
| script/setup/install-runc | |
| else | |
| echo "Skipping runc (already installed)" | |
| fi | |
| # Install CNI if not present | |
| CNI_DIR="/opt/cni/bin" | |
| if [ ! -d "$CNI_DIR" ] || [ -z "$(ls -A $CNI_DIR 2>/dev/null)" ]; then | |
| echo "Installing CNI..." | |
| script/setup/install-cni $(grep containernetworking/plugins go.mod | awk '{print $2}') | |
| else | |
| echo "Skipping CNI (already installed)" | |
| fi | |
| # Build containerd if not already built | |
| if [ ! -x "bin/containerd" ]; then | |
| echo "Building containerd..." | |
| make binaries GO_BUILD_FLAGS="-mod=vendor" | |
| else | |
| echo "Skipping build (binaries already exist)" | |
| fi | |
| # Install containerd if not present | |
| if ! command -v containerd &>/dev/null; then | |
| echo "Installing containerd..." | |
| sudo make install | |
| else | |
| echo "Skipping install (containerd already installed)" | |
| fi | |
| # Stop and disable pre-existing containerd service to ensure a clean state. | |
| if sudo systemctl is-active --quiet containerd; then | |
| sudo systemctl stop containerd | |
| fi | |
| if sudo systemctl is-enabled --quiet containerd; then | |
| sudo systemctl disable containerd | |
| fi | |
| sudo mkdir -p /etc/containerd | |
| sudo tee /etc/containerd/config.toml > /dev/null <<EOF | |
| version = 2 | |
| required_plugins = ["io.containerd.grpc.v1.cri"] | |
| [plugins."io.containerd.grpc.v1.cri".containerd] | |
| default_runtime_name = "runc" | |
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] | |
| runtime_type = "io.containerd.runc.v2" | |
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] | |
| # Ensure containerd uses the runc binary installed from source. | |
| BinaryName = "/usr/local/sbin/runc" | |
| SystemdCgroup = true | |
| # Required for certain node e2e tests. | |
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler] | |
| runtime_type = "io.containerd.runc.v2" | |
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler.options] | |
| # Ensure containerd uses the runc binary installed from source. | |
| BinaryName = "/usr/local/sbin/runc" | |
| SystemdCgroup = true | |
| EOF | |
| sudo cp containerd.service /etc/systemd/system/ | |
| sudo systemctl daemon-reload | |
| sudo systemctl start containerd | |
| # Wait and verify the daemon is ready. | |
| sleep 5 | |
| sudo ctr version | |
| popd |
| vmType: vz | |
| rosetta: | |
| enabled: true | |
| binfmt: true | |
| images: | |
| - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img" | |
| arch: "x86_64" | |
| - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img" | |
| arch: "aarch64" | |
| containerd: | |
| system: false | |
| user: false | |
| mounts: | |
| - location: "~" | |
| writable: true |