Skip to content

Commit 8edf32a

Browse files
committed
Unmount mount points under /tmp before moving to persistent volume
With 9p and cloud init, the mounts happen before the provisioning scripts execute. So by the time we move /tmp to /mnt/data/tmp the /tmp/lima directory is already mounted, blocking the move. Signed-off-by: Jan Dubois <[email protected]>
1 parent 4510d67 commit 8edf32a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/05-persistent-data-volume.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then
3333
PART=$(lsblk --list /dev/"${DISK}" --noheadings --output name,type | awk '$2 == "part" {print $1}')
3434
mkfs.ext4 -L data-volume /dev/"${PART}"
3535
mount -t ext4 /dev/disk/by-label/data-volume /mnt/data
36+
# Unmount all mount points under /tmp so we can move it to the data volume:
37+
# "mount1 on /tmp/lima type 9p (rw,dirsync,relatime,mmap,access=client,trans=virtio)"
38+
for MP in $(mount | awk '$3 ~ /^\/tmp\// {print $3}'); do
39+
umount "${MP}"
40+
done
3641
for DIR in ${DATADIRS}; do
3742
DEST="/mnt/data$(dirname "${DIR}")"
3843
mkdir -p "${DIR}" "${DEST}"
@@ -48,4 +53,6 @@ if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then
4853
mount --bind /mnt/data"${DIR}" "${DIR}"
4954
fi
5055
done
56+
# Make sure to re-mount any mount points under /tmp
57+
mount -a
5158
fi

0 commit comments

Comments
 (0)