Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created March 5, 2018 14:39
Show Gist options
  • Save westonwatson/c0c1ae05804ea6e17acb2a2258fe194f to your computer and use it in GitHub Desktop.
Save westonwatson/c0c1ae05804ea6e17acb2a2258fe194f to your computer and use it in GitHub Desktop.
Mount Removable Drives in Windows' Ubuntu/Bash/Subsystem
#!/bin/bash
cat << EOF
__________ ______ ______________ ______ _________
___ ____/ ___ |/ /_ __ \\_ / / /__ | / /__ __/
__ __/ / /|_/ /_ / / / / / /__ |/ /__ /
_ /___ / / / / / /_/ // /_/ / _ /| / _ /
/_____/ /_/ /_/ \\____/ \\____/ /_/ |_/ /_/
Must be run as root
EOF
echo "Please Enter the Removable Drive You Want to Mount, Followeb by [ENTER]: "
echo "Please use lower drive letters (example: e, f, d)"
read driveletter
echo "Attempting to Mount Removable Drive [$driveletter] to /mnt/$driveletter..."
echo "Creating Directory '$driveletter' in '/mnt'"
mkdir /mnt/$driveletter
uppercase=$(echo "$driveletter" | awk '{print toupper($driveletter)}')
mount -t drvfs $uppercase: /mnt/$driveletter
echo "Your Removable Drive [$uppercase] Should be Mounted on /mnt/$driveletter"
echo ""
ls /mnt/$driveletter -al
echo ""
echo ""
echo "Type 'sudo umount /mnt/$driveletter' Before Removing Drive [$uppercase]"
echo "And 'sudo rm /mnt/$driveletter -fr' to Remove the Directory from Earlier"
echo "Enjoy!"
@westonwatson
Copy link
Author

curl https://gist.githubusercontent.com/westonwatson/c0c1ae05804ea6e17acb2a2258fe194f/raw/9a3be045eeffff2e3a6dc24a8410af319b3409d5/emount.sh > emount.sh
chmod +x emount.sh
sudo ./emount.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment