Created
September 1, 2018 18:33
-
-
Save shokinn/d5ba240e75e22d0b59b9a8ee5b5c190a to your computer and use it in GitHub Desktop.
WSL Windows drive un/mount scripts
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 | |
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 |
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 | |
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