Skip to content

Conversation

afbjorklund
Copy link
Member

@afbjorklund afbjorklund commented Aug 18, 2025

Do this when setting up the cidata instead, next to the decision on whether to use "cidata/" directory or "cidata.iso".

This means that this particular boot script is not depending on the driver, but can be used from all container drivers.

We probably want to add an explicit bool config for it to the driver, instead of checking for the driver name?

And there are still some features left to add to the script (from cloud-config), like the hostname and timezone.

Currently we dont use user-data, but lima.env (+ ssh key)

We execute this script through the boot.sh directly (lima-init).

@afbjorklund
Copy link
Member Author

afbjorklund commented Aug 24, 2025

This should be returned by the driver, instead of hardcoded on driver name like now:

func useCloudInit(instConfig *limayaml.LimaYAML) bool {
       // all drivers but WSL2 use cloud-init
       return *instConfig.VMType != limayaml.WSL2
}

Not so keen on the variable name, but it does follow the "default is false" convention.

NoCloudInit

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 27, 2025
@AkihiroSuda AkihiroSuda linked an issue Aug 27, 2025 that may be closed by this pull request
@AkihiroSuda
Copy link
Member

Needs rebase

@afbjorklund
Copy link
Member Author

afbjorklund commented Sep 7, 2025

Now the script has been duplicated in each driver instead:

pkg/driver/wsl2/boot
└── 02-wsl2-setup.sh
pkg/driver/ac/boot
└── 02-ac-setup.sh
pkg/driver/dc/boot
└── 02-dc-setup.sh

https://github.com/lima-vm/lima/blob/master/pkg/driver/wsl2/boot/02-wsl2-setup.sh

# This script replaces the cloud-init functionality of creating a user and setting its SSH keys
# when using a WSL2 VM.
[ "$LIMA_CIDATA_VMTYPE" = "wsl2" ] || exit 0
# This script replaces the cloud-init functionality of creating a user and setting its SSH keys
# when using a AC VM.
[ "$LIMA_CIDATA_VMTYPE" = "ac" ] || exit 0
# This script replaces the cloud-init functionality of creating a user and setting its SSH keys
# when using a DC VM.
[ "$LIMA_CIDATA_VMTYPE" = "dc" ] || exit 0

But it still needs to be fixed in the cidata, still hardcoded:

        if args.VMType == limatype.WSL2 || args.VMType == limatype.AC || args.VMType == limatype.DC {
                layout = append(layout, iso9660util.Entry{
                        Path:   "ssh_authorized_keys",
                        Reader: strings.NewReader(strings.Join(args.SSHPubKeys, "\n")),
                })
                return writeCIDataDir(filepath.Join(instDir, filenames.CIDataISODir), layout)
        }

        return iso9660util.Write(filepath.Join(instDir, filenames.CIDataISO), "cidata", layout)

Do this when setting up the cidata instead, next to the
decision on whether to use "cidata" dir or "cidata.iso".

This means that this particular boot script is not depending
on the driver, but can be used from all container drivers.

Signed-off-by: Anders F Björklund <[email protected]>
@afbjorklund afbjorklund marked this pull request as ready for review September 13, 2025 12:11
Instead of hardcoding which drivers do not use cloud-init,
make it into a driver feature. Currently, that is only WSL2.

The container drivers do mount a cidata.iso, instead they
mount a cidata dir. Then they include a boot script for it.

Signed-off-by: Anders F Björklund <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 36de594 into lima-vm:master Sep 17, 2025
62 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vmdrivers VM driver infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cidata: identify vmtype-specific boot scripts
2 participants