Skip to content

Instantly share code, notes, and snippets.

@shokinn
Created September 1, 2018 18:33
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 shokinn/d5ba240e75e22d0b59b9a8ee5b5c190a to your computer and use it in GitHub Desktop.
Save shokinn/d5ba240e75e22d0b59b9a8ee5b5c190a to your computer and use it in GitHub Desktop.
WSL Windows drive un/mount scripts
#!/bin/bash
die () {
echo -e >&2 "$@"
exit 1
}
# check if script runs as root or via sudo
[ "$UID" -eq 0 ] || die "You have to run this script as root!"
# kill if no argument given
[ "$#" -eq 1 ] || die "Windows drive letter required!\n\nRun:\t'$0 <drive_letter>'\ne.g.:\t'$0 d'"
# Create drive dir
mkdir /mnt/$1
# Mount drive
mount -t drvfs $1: /mnt/$1
exit 0
#!/bin/bash
die () {
echo -e >&2 "$@"
exit 1
}
# check if script runs as root or via sudo
[ "$UID" -eq 0 ] || die "You have to run this script as root!"
# kill if no argument given
[ "$#" -eq 1 ] || die "Mounted Windows drive letter required!\n\nRun:\t'$0 <drive_letter>'\ne.g.:\t'$0 d'"
# Unmount drive
umount /mnt/$1
# Remove drive dir
rmdir /mnt/$1
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment