Skip to content

Commit 0e90e59

Browse files
committed
Create directory for disk backing file, if needed
- This allows mounting a backing disk file from within the container filesystem or image, e.g. --env=RUNCVM_DISKS=/disks/docker,/var/lib/docker,ext4,1G
1 parent f482ef9 commit 0e90e59

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

runcvm-scripts/runcvm-ctr-qemu

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ do_disk() {
5252
error "Error: disk spec '$spec' invalid: size must be specified if src '$src' does not exist"
5353
fi
5454

55+
# Create directory for disk backing file, if needed.
56+
local dir="$(busybox dirname "$src")"
57+
if ! [ -d "$dir" ]; then
58+
mkdir -p $(busybox dirname "$src")
59+
fi
60+
5561
busybox truncate -s "$size" "$src" >&2 || error "Error: disk spec '$spec' invalid: truncate on '$src' with size '$size' failed"
5662
mke2fs -F -t "$fs" "$src" >&2 || error "Error: disk spec '$spec' invalid: mke2fs on '$src' with fs '$fs' failed"
5763
fi

0 commit comments

Comments
 (0)