Created
March 22, 2019 07:09
-
-
Save jimyang2008/85e18093144cd3d73e3aad402da4352f to your computer and use it in GitHub Desktop.
Fix NTFS in Mac
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 | |
err() { | |
msg="$@" | |
echo "ERROR: $msg" >&2 | |
} | |
[[ `id -u` == '0' ]] || { | |
err "must run as root or with sudo" | |
exit 1 | |
} | |
main_disk='Macintosh HD' | |
fstab_file=/etc/fstab | |
while read label | |
do | |
[[ "$label" == 'Macintosh HD' ]] && continue | |
label=$(echo $label|sed 's/ /\\040/g') | |
labels="$labels $label" | |
done < <(cd /Volumes; ls -1) | |
#IFS=$'\n' | |
PS3='select LABEL to add:' | |
select label in $labels | |
do | |
[[ -n "$label" ]] && break; | |
done | |
test -n "$label" || exit 0 | |
echo -n "Adding $label to $fstab_file ... " | |
fgrep -q $label $fstab_file || \ | |
echo "LABEL=$label none ntfs rw,auto,nobrowse" >> $fstab_file | |
[[ $? -eq 0 ]] && echo ok || echo fail | |
cat $fstab_file | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment