Initial commit

This commit is contained in:
2026-09-05 02:13:35 +08:00
commit b85e5c4a8b
6 changed files with 91 additions and 0 deletions
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# mounts a windows VHD in wsl
APP_DIR="$(dirname "$0")"
WINDOWS_MOUNT="$APP_DIR/windows-mount"
WSL_PATH="$APP_DIR/wsl-path"
WSL_INTEROP_READY="$APP_DIR/wsl-interop-ready"
SLEEP_INTERVAL=0.5
DRIVE="$1"
DISK_LABEL="$2"
DISK_PATH="/dev/disk/by-label/$DISK_LABEL"
if ! $WINDOWS_MOUNT >/dev/null; then
echo "Error: Windows not mounted" >&2
exit 1
fi
if ! $WSL_INTEROP_READY; then
echo "Error: WSL Interop not ready" >&2
exit 1
fi
WSL="$($WSL_PATH)"
if ! [ -e "$DISK_PATH" ]; then
$WSL --mount --bare --vhd "$DRIVE"
# poll until the block device node appears or task times out
until [ -L "$DISK_PATH" ] && [ -b "$DISK_PATH" ]; do
sleep "$SLEEP_INTERVAL"
done
fi
exit 0