-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floppy disk issues with WSL2 #2
Comments
Turns out I had more than one WSL distribution installed as shown below and the fact that To fix script not detecting the correct WSL distroTo fix this I updated the script to first find the registry path for the current distro and then query the BasePath for the distro GUID using the newly found registry path 😄 Update line 1-5 as follows: #!/bin/bash
# Get the Windows registry path for the current WSL distro
wsl_distro_regpath=$(reg.exe query "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lxss" /s /f DistributionName 2>&1 | sed -e 's|\r||g' | grep -B1 -e "$WSL_DISTRO_NAME$" | head -n1)
# Get path for WSL storage
wslroot=$(wslpath $(reg.exe query $wsl_distro_regpath /s /v BasePath | awk 'BEGIN { FS = "[ \t]+" } ; /BasePath/{print $4}' | tr -d "[:cntrl:]")) To fix WSL2 issue where rootfs is not a vailid pathComment out the if-clause for the floopy-disk check so it becomes: # Packer tries to create floppy in the linux /tmp folder which is not representable in Windows. Replace it with direct storage path
#if [[ $argument == /tmp/* ]]; then
#argument="$wslroot/rootfs$argument"
#fi Issue showing multiple WSL distros:
Full bash script after edits:#!/bin/bash
# Get the Windows registry path for the current WSL distro
wsl_distro_regpath=$(reg.exe query "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lxss" /s /f DistributionName 2>&1 | sed -e 's|\r||g' | grep -B1 -e "$WSL_DISTRO_NAME$" | head -n1)
# Get path for WSL storage
wslroot=$(wslpath $(reg.exe query $wsl_distro_regpath /s /v BasePath | awk 'BEGIN { FS = "[ \t]+" } ; /BasePath/{print $4}' | tr -d "[:cntrl:]"))
# Initialize defaults
is_next_path=0
args=()
for argument; do
# If the current argument is --medium expect path of the medium in next argument
if [ "$argument" == 'none' ]; then
is_next_path=0
elif [ "$argument" = '--medium' ]; then
is_next_path=1
elif [ $is_next_path = 1 ]; then
# Packer tries to create floppy in the linux /tmp folder which is not representable in Windows. Replace it with direct storage path
#if [[ $argument == /tmp/* ]]; then
#argument="$wslroot/rootfs$argument"
#fi
# Convert WSL paths to Windows path
argument=$(wslpath -w "$argument")
is_next_path=0
fi
args+=("\"$argument\"")
done
# Redirect to Windows VBoxManage and convert Windows paths back to WSL paths
echo "${args[@]}" | xargs /mnt/c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe | sed -r '/[A-Za-z]:\\.*$/{h; s/(.*)([A-Za-z]:\\.*)$/\2/; s/(.+)/wslpath "\1"/e; H; x; s/(([A-Za-z]:\\.*)\n(.+))/\3/ }'
# /[A-Za-z]:\\.*$/ # Find lines that end with Windows paths
# { # For each line
# h; # Copy to hold storage
# s/(.*)([A-Za-z]:\\.*)$/\2/; #Remove everything except the path
# s/(.+)/wslpath "\1"/e; #Convert the path to WSL path
# H; # Append to the hold storage
# x; # Swap pattern storage with hold storage
# # Pattern storage have 2 lines now:
# # SAMPLE C:\Windows\Temp
# /mnt/c/Windows/Temp
# s/(([A-Za-z]:\\.*)\n(.+))/\3/ # Replace Windows path in the first line with the WSL path in the second line
# This is how the path for the floppy-disk looks like to VirtualBox: |
Hello, I'm using this and seeing floppy disk is failing to attach with WSL2.
Error log:
Version info:
The text was updated successfully, but these errors were encountered: