I've recently made 2 script that take care of mounting and dismounting a harddrive in linux. The thing that I could not figure out is the following. I am currently mounting
/home/media/externalHardDrive. The thing is, when I insert another usb device (like usb stick) while the harddrive is not being inserted it will most likely put the usb-stick on
/dev/sdc1. I would like to learn a way to identify the device before mounting it, so I can make sure that only the harddrive is affected by this script.
These are my scripts: unmount_script.sh:
#!/bin/bash MOUNT="/home/media/externalHardDrive" if grep -qs "$MOUNT" /proc/mounts; then umount "$MOUNT" if [ $? -eq 0 ]; then echo "HardDrive kan veilig worden verwijderd :D" else echo "Er is iets mis gegaan, blijf overal vanaf :(" fi else echo "Er is geen HardDrive gemount op $MOUNT, deze kan daarom niet verwijderd worden!" fi
#!/bin/bash MOUNT="/home/media/externalHardDrive" if grep -qs "$MOUNT" /proc/mounts; then echo "HardDrive is al gemount op $MOUNT ;)" else mount /dev/sdc1 "$MOUNT" if [ $? -eq 0 ]; then echo "HardDrive is succesvol gemount :D" fi fi
Can somebody point me in the right direction? I am running these scripts on a debian server.