lima icon indicating copy to clipboard operation
lima copied to clipboard

apk installs to tmpfs

Open moenodedev opened this issue 1 year ago • 9 comments

Description

apk installs into /usr which is a tmpfs mount. If the disk runs out of space while installing packages ssh won't work after rebooting. Should /usr be in /dev/disk/by-label/data-volume?

$ df -h /usr
Filesystem                Size      Used Available Use% Mounted on
tmpfs                   955.7M     70.0M    885.7M   7% /

limactl version 0.22.0 macOS Sonoma 14.5 alpine-lima-std-3.19.0-aarch64.iso mountType: "virtiofs"

moenodedev avatar May 14 '24 15:05 moenodedev

I think if you want to move /usr to persistent storage, then you would be better off using a regular disk image instead of booting from an ISO.

It looks like Alpine is publishing cloudinit images now, so I would suggest trying to build a template using https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/cloud/nocloud_alpine-3.19.1-x86_64-bios-cloudinit-r0.qcow2

We probably need to adjust some code in Lima that assumes Alpine always means ISO, but that shouldn't be a problem, once it is confirmed that the Alpine cloud images can work.

jandubois avatar May 14 '24 15:05 jandubois

Or https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/cloud/nocloud_alpine-3.19.1-aarch64-uefi-cloudinit-r0.qcow2 for aarch64.

jandubois avatar May 14 '24 15:05 jandubois

Maybe apk should be disabled (or issue warnings?) in alpine-lima, and refer to making custom "editions" instead

afbjorklund avatar May 14 '24 16:05 afbjorklund

If the disk runs out of space while installing packages ssh won't work after rebooting

Maybe I am missing something here, but wouldn't the tmpfs be "freed up" after a reboot?

afbjorklund avatar May 14 '24 16:05 afbjorklund

Maybe apk should be disabled (or issue warnings?) in alpine-lima,

Why? You can use the apk add in a provisioning script. The packages get cached, and will be reinstalled from the cache on reboot. From the user's point of view this should be indistinguishable from having /usr persisted as well, except for a tiny delay for reinstalling them.

Of course if you do massive installs and run out of RAM, then this whole mechanism of running of a LiveCD does not really work anymore.

jandubois avatar May 14 '24 16:05 jandubois

OK, so then running out of RAM in alpine-lima should be equivalent to running out of /usr disk in alpine

afbjorklund avatar May 14 '24 16:05 afbjorklund

The packages get cached, and will be reinstalled from the cache on reboot

I added this feature to "tinycloud" as well, so it will use /mnt/data/tce for .tcz

i.e. same thing, but with mounting instead of copying (see the TCL concepts)

It's a nice feature... Maybe we should have it for containers and images too?

afbjorklund avatar May 14 '24 16:05 afbjorklund

I have a disk defined and it's taking up space:

disk: "15GiB"

What is the disk used for?

moenodedev avatar May 15 '24 10:05 moenodedev

What is the disk used for?

It is mounted to /mnt/data and can be used to persist user data (e.g. container images) across reboots: https://github.com/lima-vm/lima/blob/9b699479f1af392f5402b0d8994ba0421295f3f6/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh#L10

It also holds the apk cache used to reinstall packages on reboot: https://github.com/lima-vm/lima/blob/9b699479f1af392f5402b0d8994ba0421295f3f6/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh#L118-L119

You can create your own directories there as well, as long as they don't conflict with the ones used by Lima.

/tmp is the exception to it storing just user data. It is moved there to prevent /tmp from taking up RAM.

jandubois avatar May 15 '24 16:05 jandubois

Thanks I started a discussion to see if I can replace UTM with lima.

#2359

moenodedev avatar May 24 '24 22:05 moenodedev