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