Skip to content

Instantly share code, notes, and snippets.

@panosru
Created January 31, 2024 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panosru/58ca6559bf1ebb42d791c4b3ad002450 to your computer and use it in GitHub Desktop.
Save panosru/58ca6559bf1ebb42d791c4b3ad002450 to your computer and use it in GitHub Desktop.
VMWare Fusion Bootcamp Volume Fix
#!/usr/bin/env bash
FILE_VMDK="/Users/panosru/Library/Application Support/VMware Fusion/Virtual Machines/Boot Camp/Boot Camp.vmwarevm/Boot Camp.vmdk"
DRIVE_NEW=$(diskutil list | awk '/Windows/{print $NF}' | cut -c 1-5 | uniq)
# Function to find DRIVE_OLD
find_old_drive() {
grep -o 'disk[0-9]\+' "$1" | sort -u | head -n 1
}
# Ensure the file exists and is readable
if [[ ! -f "$FILE_VMDK" ]]; then
echo "File not found: $FILE_VMDK"
exit 1
fi
# Find the old drive
DRIVE_OLD=$(find_old_drive "$FILE_VMDK")
if [[ -z "$DRIVE_OLD" ]]; then
echo "No old drive identifier found in the file."
exit 1
fi
echo "Replacing $DRIVE_OLD with $DRIVE_NEW in $FILE_VMDK"
sed -i.bak "s/$DRIVE_OLD/$DRIVE_NEW/g" "$FILE_VMDK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment