Created
January 31, 2024 14:08
-
-
Save panosru/58ca6559bf1ebb42d791c4b3ad002450 to your computer and use it in GitHub Desktop.
VMWare Fusion Bootcamp Volume Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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