Insert USB device under Linux to automatically mount using scripts

Source: Internet
Author: User

One day the customer said to want to insert a USB flash drive on the Linux OS, and then the same as in Windows to implement automatic mount, no search for useful information on the Internet, there is a software usbmount, but the test can not be used, interested to see, the address is as follows

http://usbmount.alioth.debian.org/#what

Customer is the customer

Then use the script to implement the process

1. VI mount.sh

#!/bin/bashmount_dir=/mnt/usb #挂载USB设备之后挂载的路径mount_txt =/etc/mount.txtumount $mount _dir >/dev/null 2>&1 # If there is no umount at the time of the first pull-out, this can be achieved first umount after the "test-d $mount _dir ' #检查是否存在挂载的目的文件夹, if not, create a status=$?if [$status-eq 1] Then ' mkdir $mount _dir ' fifdisk-l|grep/dev/> $mount _txtmount_result= ' tail-n-1 $mount _txt|awk ' {print $} ' #插入usb设 After provisioning, Fdisk can see, remove the device name mount-t vfat-o iocharset=cp950 $mount _result $mount _dir #使用上一步取到的设备名进行挂载cd $mount _dirlsecho "----- ------------------"echo" Please enter $mount _dir "echo"-----------------------"

2. edit the script to add executable permissions

chmod +x mount.sh

./mount.sh

If you want to go directly to the mounted directory, use the

Source mount.sh

For some other relevant knowledge, refer to the following links

Http://www.360doc.com/content/11/0513/18/2065845_116508393.shtml


This article is from "The girl said" blog, please be sure to keep this source http://sugarlovecxq.blog.51cto.com/6707742/1564828

Insert USB device under Linux to automatically mount using scripts

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.