Saturday, December 17, 2016
Mount non Linux drives automatically when they are not in etc fstab
Mount non Linux drives automatically when they are not in etc fstab
So, I usually face this problem when Im not using GUI based File Managers. They allow you to auto mount drives when you click on them but when you are using CLI based file managers or no file managers at all, the only way is to mount them through writing commands. Im a lazy fad and I want this done automatically. So heres a script for that. [ https://gist.github.com/Tafhim/5d0839caca813ae82c97 ].
#!/usr/bin/zsh
if [[ "$1" == "" ]] then
echo "Please specify a device name";
exit;
fi;
deviceFile=$1
## Auto mount only ntfs, fat32, vfat
for i in $(ls $deviceFile* | grep [0-9]$); do
blkid -s UUID -o value $i | read z;
blkid -s TYPE -o value $i | read f;
echo "$z is $f";
if [[ "$z" != "" && ("$f" == "ntfs" || "$f" == "vfat" || "$f" == "fat32" ) ]] then
/usr/bin/udisksctl mount -t $f -b $i # https://help.ubuntu.com/community/AutomaticallyMountPartitions
fi;
done
Go to link download