lima icon indicating copy to clipboard operation
lima copied to clipboard

Support configuring multiple disks for a Lima VM

Open chancez opened this issue 3 years ago • 5 comments

Description

Use case:

I want to persist data within the guest without a network volume mount to the host on a separate disk from the Lima guest's root disk.

This would:

  • Allow higher performance than network volumes while still retaining the ability to persist files even if you recreate your VM.
  • Allow copying the backing disk's image on the host between different VMs, perhaps allowing one to pre-seed VMs with some content separate from the image.

chancez avatar Mar 11 '22 19:03 chancez

Added a "data" option to add a data disk, next to the "disk" option for the root disk.

cpus: 4
memory: "4GiB"
disk: "100GiB"
data: "10GiB"

Currently the disk images are kept inside the Dir, so recreating will delete both of them.

/home/anders/.lima/default/basedisk: QEMU QCOW2 Image (v2), 2361393152 bytes
/home/anders/.lima/default/datadisk: QEMU QCOW2 Image (v3), 10737418240 bytes
/home/anders/.lima/default/diffdisk: QEMU QCOW2 Image (v3), has backing file (path /home/anders/.lima/default/basedisk), 107374182400 bytes

It is possible to copy and backup the "datadisk", and restore it again after creation...

Inside the VM, the root disk is /dev/vda and the data disk is /dev/vdb (unformatted)

  • #759

afbjorklund avatar Mar 26 '22 14:03 afbjorklund

I'm wondering if we should instead have support for "named volumes" that live outside the instance, e.g. in $LIMA_HOME/_data that can be created/deleted with a separate limactl create-volume command, and then referenced from an instance.

This bypasses the whole "factory-reset" issue, as the lifetime of the data volume is no longer linked to a specific instance.

You could even link the same volume from multiple instances, and lima would ensure that only one of them runs at a time (we already do something similar for vde networking interfaces).

jandubois avatar Mar 26 '22 19:03 jandubois

alpine-lima, and forks like colima, already had a "data volume" so I think that this new addition would need a new name.

afbjorklund avatar Mar 27 '22 07:03 afbjorklund

Ideally I could configure any number of disks. Eg: vdb, vdc, etc.

chancez avatar Mar 28 '22 18:03 chancez

I would have used this today as I needed to do some testing with lvm, and it has to be a raw disk and not a loopback device. For those learning lvm, mdraid, or zfs, supporting multiple disks is very useful.

deviantintegral avatar May 27 '22 11:05 deviantintegral