diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/05-lima-disks.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/05-lima-disks.sh index a4802e0299f5..d31750bf692e 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/boot/05-lima-disks.sh +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/05-lima-disks.sh @@ -14,6 +14,7 @@ for i in $(seq 0 $((LIMA_CIDATA_DISKS - 1))); do DEVICE_NAME="$(get_disk_var "$i" "DEVICE")" FORMAT_DISK="$(get_disk_var "$i" "FORMAT")" FORMAT_FSTYPE="$(get_disk_var "$i" "FSTYPE")" + FORMAT_FSARGS="$(get_disk_var "$i" "FSARGS")" test -n "$FORMAT_DISK" || FORMAT_DISK=true test -n "$FORMAT_FSTYPE" || FORMAT_FSTYPE=ext4 @@ -22,7 +23,8 @@ for i in $(seq 0 $((LIMA_CIDATA_DISKS - 1))); do if [[ ! -b "/dev/disk/by-label/lima-${DISK_NAME}" ]]; then if $FORMAT_DISK; then echo 'type=linux' | sfdisk --label gpt "/dev/${DEVICE_NAME}" - mkfs.$FORMAT_FSTYPE -L "lima-${DISK_NAME}" "/dev/${DEVICE_NAME}1" + # shellcheck disable=SC2086 + mkfs.$FORMAT_FSTYPE $FORMAT_FSARGS -L "lima-${DISK_NAME}" "/dev/${DEVICE_NAME}1" fi fi diff --git a/pkg/cidata/cidata.TEMPLATE.d/lima.env b/pkg/cidata/cidata.TEMPLATE.d/lima.env index a5713a41bae3..e584a56e9ac0 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/lima.env +++ b/pkg/cidata/cidata.TEMPLATE.d/lima.env @@ -13,6 +13,7 @@ LIMA_CIDATA_DISK_{{$i}}_NAME={{$disk.Name}} LIMA_CIDATA_DISK_{{$i}}_DEVICE={{$disk.Device}} LIMA_CIDATA_DISK_{{$i}}_FORMAT={{$disk.Format}} LIMA_CIDATA_DISK_{{$i}}_FSTYPE={{$disk.FSType}} +LIMA_CIDATA_DISK_{{$i}}_FSARGS={{range $j, $arg := $disk.FSArgs}}{{if $j}} {{end}}{{$arg}}{{end}} {{- end}} LIMA_CIDATA_GUEST_INSTALL_PREFIX={{ .GuestInstallPrefix }} {{- if .Containerd.User}} diff --git a/pkg/cidata/cidata.go b/pkg/cidata/cidata.go index b330373de40c..82dc25784f43 100644 --- a/pkg/cidata/cidata.go +++ b/pkg/cidata/cidata.go @@ -217,6 +217,7 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort Device: diskDeviceNameFromOrder(i), Format: format, FSType: fstype, + FSArgs: d.FSArgs, }) } diff --git a/pkg/cidata/template.go b/pkg/cidata/template.go index ed1f6fcb642b..044c232e47a9 100644 --- a/pkg/cidata/template.go +++ b/pkg/cidata/template.go @@ -50,6 +50,7 @@ type Disk struct { Device string Format bool FSType string + FSArgs []string } type TemplateArgs struct { Name string // instance name diff --git a/pkg/limayaml/limayaml.go b/pkg/limayaml/limayaml.go index b44dc0a5f778..98e3f33f57e2 100644 --- a/pkg/limayaml/limayaml.go +++ b/pkg/limayaml/limayaml.go @@ -80,9 +80,10 @@ type Image struct { } type Disk struct { - Name string `yaml:"name" json:"name"` // REQUIRED - Format *bool `yaml:"format,omitempty" json:"format,omitempty"` - FSType *string `yaml:"fsType,omitempty" json:"fsType,omitEmpty"` + Name string `yaml:"name" json:"name"` // REQUIRED + Format *bool `yaml:"format,omitempty" json:"format,omitempty"` + FSType *string `yaml:"fsType,omitempty" json:"fsType,omitEmpty"` + FSArgs []string `yaml:"fsArgs,omitempty" json:"fsArgs,omitEmpty"` } type Mount struct { diff --git a/pkg/limayaml/load_test.go b/pkg/limayaml/load_test.go index 351e79bd6d4d..0a7c09fe5142 100644 --- a/pkg/limayaml/load_test.go +++ b/pkg/limayaml/load_test.go @@ -42,6 +42,7 @@ additionalDisks: assert.Equal(t, y.AdditionalDisks[0].Name, "name") assert.Assert(t, y.AdditionalDisks[0].Format == nil) assert.Assert(t, y.AdditionalDisks[0].FSType == nil) + assert.Assert(t, y.AdditionalDisks[0].FSArgs == nil) } func TestLoadDiskStruct(t *testing.T) { @@ -50,6 +51,7 @@ additionalDisks: - name: "name" format: false fsType: "xfs" + fsArgs: ["-i","size=512"] ` y, err := Load([]byte(s), "disk.yaml") assert.NilError(t, err) @@ -59,4 +61,7 @@ additionalDisks: assert.Equal(t, *y.AdditionalDisks[0].Format, false) assert.Assert(t, y.AdditionalDisks[0].FSType != nil) assert.Equal(t, *y.AdditionalDisks[0].FSType, "xfs") + assert.Assert(t, len(y.AdditionalDisks[0].FSArgs) == 2) + assert.Equal(t, y.AdditionalDisks[0].FSArgs[0], "-i") + assert.Equal(t, y.AdditionalDisks[0].FSArgs[1], "size=512") }