Skip to content

Introduce stable disk/iso filenames with symlink-based migration#4587

Open
jandubois wants to merge 1 commit intolima-vm:masterfrom
jandubois:disk3
Open

Introduce stable disk/iso filenames with symlink-based migration#4587
jandubois wants to merge 1 commit intolima-vm:masterfrom
jandubois:disk3

Conversation

@jandubois
Copy link
Member

@jandubois jandubois commented Feb 16, 2026

Alternative to #4206.

Replace the legacy basedisk/diffdisk naming with self-documenting filenames: "image" (downloaded VM image), "disk" (VM disk), and "iso" (optional CDROM).

New instances download to "image" and create symlinks: non-ISO images get disk→image; ISO images get iso→image plus a real empty disk. QEMU no longer creates a qcow2 overlay backed by basedisk; it symlinks disk→image directly.

Existing instances are migrated by MigrateDiskLayout, which creates disk→diffdisk and (for ISO basedisks) iso→basedisk symlinks. The original files remain so older Lima versions can still use them.

Boot paths now check for the "iso" symlink via osutil.FileExists instead of calling iso9660util.IsISO9660 at startup.


Comparing existing instance vs. one created with this PR

Using ISO image

ls -lh ~/.lima/alpine-iso/{image,*disk,iso}
ls: /Users/jan/.lima/alpine-iso/image: No such file or directory
-rw-r--r--@ 1 jan  staff    91M Oct 12 20:22 /Users/jan/.lima/alpine-iso/basedisk
-rw-r--r--@ 1 jan  staff   100G Feb 15 16:43 /Users/jan/.lima/alpine-iso/diffdisk
lrwxr-xr-x@ 1 jan  staff     8B Feb 15 16:42 /Users/jan/.lima/alpine-iso/disk -> diffdisk
lrwxr-xr-x@ 1 jan  staff     8B Feb 15 16:42 /Users/jan/.lima/alpine-iso/iso -> basediskls -lh ~/.lima/alpine-new/{image,*disk,iso}
-rw-r--r--@ 1 jan  staff   100G Feb 15 16:43 /Users/jan/.lima/alpine-new/disk
-rw-r--r--@ 1 jan  staff   103M Jan  7 15:01 /Users/jan/.lima/alpine-new/image
lrwxr-xr-x@ 1 jan  staff     5B Feb 15 16:43 /Users/jan/.lima/alpine-new/iso -> image

Regular non-ISO image

ls -lh ~/.lima/default/{image,*disk}
ls: /Users/jan/.lima/default/image: No such file or directory
-rw-r--r--@ 1 jan  staff   838M Nov 24 20:38 /Users/jan/.lima/default/basedisk
-rw-r--r--@ 1 jan  staff   100G Feb 15 16:51 /Users/jan/.lima/default/diffdisk
lrwxr-xr-x@ 1 jan  staff     8B Feb 15 16:48 /Users/jan/.lima/default/disk -> diffdiskls -lh ~/.lima/default-new/{image,*disk}
lrwxr-xr-x@ 1 jan  staff     5B Feb 15 16:49 /Users/jan/.lima/default-new/disk -> image
-rw-r--r--@ 1 jan  staff   100G Feb 15 16:51 /Users/jan/.lima/default-new/image

@jandubois
Copy link
Member Author

Things for maybe a follow-up PR:

  • AcceptableAsBaseDisk should be renamed, maybe ValidateImage?
  • Common code from EnsureDisk should be factored out

AkihiroSuda
AkihiroSuda previously approved these changes Feb 16, 2026
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

Replace the legacy basedisk/diffdisk naming with self-documenting
filenames: "image" (downloaded VM image), "disk" (VM disk), and "iso"
(optional CDROM).

New instances download to "image" and create symlinks: non-ISO images
get disk→image; ISO images get iso→image plus a real empty disk.
QEMU no longer creates a qcow2 overlay backed by basedisk; it
symlinks disk→image directly.

Existing instances are migrated by MigrateDiskLayout, which creates
disk→diffdisk and (for ISO basedisks) iso→basedisk symlinks. The
original files remain so older Lima versions can still use them.

Boot paths now check for the "iso" symlink via osutil.FileExists
instead of calling iso9660util.IsISO9660 at startup. Both QEMU and
VZ attach the VM disk before the ISO.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
return nil
// EnsureDisk creates the VM disk from the downloaded image.
// For ISO images, it symlinks the ISO and creates an empty disk in the target format.
// For non-ISO images, it converts the image in place and symlinks disk to it.
Copy link
Member

Choose a reason for hiding this comment

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

Why not just rename image to disk

disk:
- `basedisk`: the base image
- `diffdisk`: the diff image (QCOW2)
- `image`: the downloaded VM image (raw, qcow2, or ISO9660)
Copy link
Member

Choose a reason for hiding this comment

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

Can we mark image non-mutable (but deletable) ?

- `basedisk`: the base image
- `diffdisk`: the diff image (QCOW2)
- `image`: the downloaded VM image (raw, qcow2, or ISO9660)
- `disk`: the VM disk (symlink to `image` or legacy `diffdisk`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- `disk`: the VM disk (symlink to `image` or legacy `diffdisk`)
- `disk`: the VM disk (can be a symlink to legacy `diffdisk`)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants