Created
May 11, 2015 19:37
-
-
Save jlongman/ccfb88d5f87e907cfa96 to your computer and use it in GitHub Desktop.
VirtualBox drive cleaner, removes inaccessible references from hard drive management and boxes
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
#!/bin/bash | |
################################################################################ | |
# closes all inaccessible drives that are not snapshots, and which dont exist | |
################################################################################ | |
vboxmanage=VBoxManage | |
while read rawuuid; do | |
uuid=`echo $rawuuid| grep -Eo ' [a-f0-9-]+' | grep -Eo '[a-f0-9-]+'` | |
read rawlocation | |
location=`echo $rawlocation | grep -o "/.*"` | |
echo "$uuid" " to " "$location" | |
if [ ! -e "$location" ]; then | |
$vboxmanage closemedium disk "$uuid" | |
else | |
echo -e $uuid file found! | |
ls -la "$location" | |
fi | |
done < <($vboxmanage list hdds | grep -C 2 --null inaccessible | grep -E '(UUID|Location)' | grep -v Parent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment