Skip to content

Instantly share code, notes, and snippets.

@NiharG15
Created October 20, 2015 08:19
Show Gist options
  • Save NiharG15/17f235b277b3292c6997 to your computer and use it in GitHub Desktop.
Save NiharG15/17f235b277b3292c6997 to your computer and use it in GitHub Desktop.
Mount / Unmount Script
#A script to mount / unmount devices.
while [ true ]
do
echo "1. Mount a device"
echo "2. Unmount a device"
echo "3. Exit"
echo "Enter your choice: "
read ch
case $ch in
1)
fdisk -l
echo "Select a device to mount: "
read DEVPATH
echo "Contents of /media: "
ls /media/
echo "Enter absolute path to a mount point: "
read MNTPT
if [ ! -e $MNTPT ]
then
mkdir $MNTPT
fi
mount $DEVPATH $MNTPT
echo "Device mounted at $MNTPT"
;;
2)
echo "Contents of media: "
ls /media
echo "Enter absolute path to a mount point to unmount device: "
read MNTPT
umount $MNTPT
echo "Device unmounted"
;;
3)
exit
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment