Hello! This is a simple bash script I wrote for mounting a specific partition to a designated folder. It was designed to run on an Linux system and was optimized for running as a cron job.
The script operates by performing the following steps:
- Checking if the designated partition exists.
- Checking if the partition is already mounted.
- Ensuring the target mount folder exists, and creating it if necessary.
- Attempting to mount the partition to the specified folder.
- Providing feedback on the success or failure of these operations through a log file.
The paths to echo
, grep
, mkdir
, and mount
commands are explicitly specified to ensure reliability when the script is run as a cron job.
-
Clone the repository containing the script.
-
Open the script with a text editor and set the
PARTITION
,MOUNT_FOLDER
, andLOG_FILE
variables to suit your needs. -
Save and close the script.
-
Set the script to be executable by running
chmod +x ./Mount.sh
from the command line. -
Test the script by running
./Mount.sh
from the command line. -
If the script runs without errors, you can add it to your crontab for automatic execution at your preferred intervals.
This script is intended to be run with root privileges due to the use of the mount
command. Please be aware that running scripts with root privileges can pose a risk if the scripts contain harmful commands. Always review and understand the scripts before running them as root.
If you encounter any issues or have any suggestions for improvements, please feel free to open an issue in this repository.