Posts Tagged shell script

Check USB harddisk mounted or not in Linux

Today, I am checking how to use a script to check if USB hard disk is mounted or not in Linux.

After doing research, I developed the following script to check “mount” status.

1. Create a file
2. chmod 755
3. Add the follow content to “”.

if mount | grep sdb1 > /dev/null
        echo "sdb1 mounted"
        echo "No sdb1"
        mount /dev/sdb1 /backup

If sdb1 is mounted, there is no action will be taken.
If sdb1 is not mounted, /dev/sdb1 will be mounted automatically.

You can put this script in cron job and check  mount status regularly.

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.18_1163]
Rating: 0 (from 0 votes)
Total views: 4,947 views


No Comments