Automatically mount and detach a USB script

Source: Internet
Author: User
Automatic mounting and unmounting of USB scripts-General Linux technology-Linux programming and kernel information. For more information, see the following. There is an automatic USB script mounting and uninstalling the USB script program. just run it.

#! /Bin/sh

If
Exec fdisk-l | grep sdb1
Then
Mount/dev/sdb1/mnt/dvd
Df-h | grep sdb1
Elif
Exec fdisk-l | grep sdb
Then
Mount/dev/sdb/mnt/dvd
Df-h | grep sdb
Else
Echo "Please prepare you device first ."
Fi

# If exec df-l | grep sdb1
# Then umount/mnt/dvd
# Fi

Uninstall USB script

#! /Bin/sh
If
Exec df-h | grep sdb
Then
Umount/mnt/dvd
Fi

You can just run the script after it is mounted. to uninstall the script, you can just run the script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.