CN104007987A - Script capable of carrying out automatic mounting under Linux - Google Patents

Script capable of carrying out automatic mounting under Linux Download PDF

Info

Publication number
CN104007987A
CN104007987A CN201410196382.XA CN201410196382A CN104007987A CN 104007987 A CN104007987 A CN 104007987A CN 201410196382 A CN201410196382 A CN 201410196382A CN 104007987 A CN104007987 A CN 104007987A
Authority
CN
China
Prior art keywords
script
carry
automatic
dev
demount
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410196382.XA
Other languages
Chinese (zh)
Inventor
李坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201410196382.XA priority Critical patent/CN104007987A/en
Publication of CN104007987A publication Critical patent/CN104007987A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention provides a script capable of automatically mounting a USB flash disc, a mobile hard disc, a CD driver and an ISO file under the Linux. An udev rule and the method of mount command mounting are adopted by the automatic script, and the automatic script is generated to achieve the function of automatically mounting the mobile equipment and the ISO file. According to the method, the udev rule is modified, and a command of detecting the mobile equipment and a mount command are added to the script. The mobile equipment is connected to a host, and the automatic script is used and executed for automatically mounting the mobile equipment. The ISO file needing to be mounted and the automatic script are placed under a current catalogue together or placed under a catalogue needing to be mounted, and the automatic script is executed.

Description

The script of automatic carry under a kind of Linux
Technical field
The present invention relates to computer technology, relate in particular to the script of automatic carry under a kind of Linux.
Background technology
Linux system is used more and more widely in the middle of enterprise, in the middle of daily use, use mobile device or ISO file to need the identical order of the input of being pestered beyond endurance of many times, in order to save time, increase work efficiency, the present invention has just proposed one and has automatically performed script.
Monitored by kernel when a new equipment connects, kernel can produce a hotplug event and search/proc/sys/kernel/hotplug goes for out the user space program that management equipment connects.Udev initializtion script registration udev as this hander. when hotplug events occurs, kernel notify udev go detection/sys file system be attached to the information of this new equipment create it /dev/ entrance.
The title of entrance is not fixed, and may be sda1, may be also sdc1 etc., this just follow under windows, insert USB flash disk show may be that moveable magnetic disc I, g, e, f are the same.The present invention is exactly by the setting to udev, allows after the U dish message that udev receives that kernel sends carry automatically.
Traditional method is that mobile device is connected on the main frame that user will use, and then uses mount order to remove to realize carry, just can see afterwards the file in user's mobile device.And ISO file is also to use mount order to remove to realize the carry of file, in the time of the each use of user, all to go a mount order of input of many times, the present invention is exactly the input command for avoiding repetition, thereby the transmission of carrying out file and use that can be convenient, to increase work efficiency.
Summary of the invention
The present invention is directed to the energy dissipation problem existing in existing air-conditioning use, a kind of script based on automatic carry USB flash disk, portable hard drive, ISO file under linux system is provided.Be used for conveniently operating, save time, raise the efficiency.
The invention discloses the script of automatic carry under a kind of Linux, its technical scheme that solve the technical problem employing is as follows: the invention provides a kind of script based on automatic carry USB flash disk, portable hard drive, ISO file under linux system, this automatic script uses the method for udev rule and mount order carry, generates automatic script to realize the function of mobile device and the automatic carry of ISO file.The method amendment udev rule, and in script, add the order and the mount order that detect mobile device.Mobile device is connected on main frame, uses automatic script, carry out script, with automatic carry mobile device.The ISO file and the automatic script that need carry are placed under current directory in the lump, or are placed under the catalogue that needs carry, carry out automatic script.
Under a kind of Linux disclosed by the invention, the beneficial effect of the script of carry is automatically:
By this script based on automatic carry USB flash disk, portable hard drive, ISO file under linux system, need not all use at every turn and detect mobile device and mount order, directly carry out script; Use automatic script can realize the automatic carry of mobile device and ISO file.Very convenient operation, saves time, and raises the efficiency.
Embodiment
Below the script of automatic carry under a kind of Linux of the present invention is described in further details, does not cause limitation of the present invention.
The present invention is exactly the problem for avoiding repeating described in background technology input command, and provide a kind of based on the automatic script of carry USB flash disk, portable hard drive, CD-ROM drive, ISO file under linux system, this automatic script uses the method for udev rule and mount order carry, generates automatic script to realize the function of mobile device and the automatic carry of ISO file.The method amendment udev rule, and in script, add the order and the mount order that detect mobile device.Mobile device is connected on main frame, uses automatic script, carry out script, with automatic carry mobile device.The ISO file and the automatic script that need carry are placed under current directory in the lump, or are placed under the catalogue that needs carry, carry out automatic script.
Its basic procedure of script based on automatic carry mobile device and ISO file under linux system comprises:
1) amendment udev rule, and in script, add the order and the mount order that detect mobile device.
2) mobile device is connected on main frame, uses automatic script, carry out script, with automatic carry mobile device.Amendment automatic script, by the catalogue that the ISO file that needs carry is input in the middle of script and input need to be mounted to.
Need not all use at every turn and detect mobile device and mount order by the script of automatic carry under Linux of the present invention, directly carry out script; Use automatic script can realize the automatic carry of mobile device and ISO file.
Under this Linux, the method for the script of carry realizes by following steps automatically:
1) under udev rule, (/etc/udev/rules.d catalogue the inside) creates automount.rules and adds following content:
ACTION!="add",GOTO="out"
KERNEL=="sd[a-z][0-9]",RUN+="/sbin/automounttmp.sh?%k"
LABEL="out"
2) then in/sbin/ catalogue, creating automounttmp.sh script file
Automounttmp.sh thes contents are as follows:
#!/bin/sh
mkdir?-p?/mnt/$1?>/dev/null?1>&2
demount=0
if?[?-x?mount?];then
mount?-t?vfat?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
if?[?$demount?-ne?0?];then
mount?-t?vfat?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
fi
if?[?$demount?-ne?0?];then
mount?-t?ntfs-3g?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
fi
fi
if?[?$demount?-ne?0?];then
The direct carry ISO of # file
mount?-o?loop?/*.iso?/mnt/*?>/dev/null?1>&2
demount=$
if?[?$demount?-ne?0?];then
mkdir?/mnt/cdrom
# carry CD-ROM drive
mount?-t?iso9660?-o?loop?/dev/cdrom?/mnt/cdrom?>/dev/null?1>&2
demount=$
fi
fi
3) note: at carry portable hard drive (NTFS form) before, need to download ntfs-3g software package, can realize the read-write support of NTFS under linux system.
Except above-mentioned content for script, yet can add other carry content, as msdos etc.(mount?–t?msdos?/dev/$1?/mnt/$1)
This file setup of attribute for carrying out, chmod a+x auotomounttmp.sh
In the time of carry ISO file, need to modify to sh file, input the path that you need the ISO file of carry, and need the catalogue of carry.
The foregoing is only embodiments of the invention, within the spirit and principles in the present invention all, any amendment of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (3)

1. the script of automatic carry under a Linux, it is characterized in that, the described script based on automatic carry USB flash disk, portable hard drive, ISO file under linux system, use the method for udev rule and mount order carry, generate automatic script to realize the function of mobile device and the automatic carry of ISO file, the method amendment udev rule, and in script, add the order and the mount order that detect mobile device; Mobile device is connected on main frame, uses automatic script, carry out script, with automatic carry mobile device, the ISO file and the automatic script that need carry are placed under current directory in the lump, or are placed under the catalogue that needs carry, carry out automatic script.
2. the script of automatic carry under a kind of Linux according to claim 1, is characterized in that, its basic procedure of script based on automatic carry mobile device and ISO file under linux system comprises:
Amendment udev rule, and in script, add the order and the mount order that detect mobile device;
Mobile device is connected on main frame, uses automatic script, carry out script, with automatic carry mobile device;
Amendment automatic script, by the catalogue that the ISO file that needs carry is input in the middle of script and input need to be mounted to.
3. the script of automatic carry under a kind of Linux according to claim 2, is characterized in that, under this Linux, the method for the script of carry realizes by following steps automatically:
Under udev rule, create automount.rules and add following content:
ACTION!="add",GOTO="out"
KERNEL=="sd[a-z][0-9]",RUN+="/sbin/automounttmp.sh?%k"
LABEL="out"
Then in/sbin/ catalogue, creating automounttmp.sh script file
Automounttmp.sh thes contents are as follows:
#!/bin/sh
mkdir?-p?/mnt/$1?>/dev/null?1>&2
demount=0
if?[?-x?mount?];then
mount?-t?vfat?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
if?[?$demount?-ne?0?];then
mount?-t?vfat?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
fi
if?[?$demount?-ne?0?];then
mount?-t?ntfs-3g?/dev/$1?/mnt/$1?>/dev/null?1>&2
demount=$
fi
fi
if?[?$demount?-ne?0?];then
The direct carry ISO of # file
mount?-o?loop?/*.iso?/mnt/*?>/dev/null?1>&2
demount=$
if?[?$demount?-ne?0?];then
mkdir?/mnt/cdrom
# carry CD-ROM drive
mount?-t?iso9660?-o?loop?/dev/cdrom?/mnt/cdrom?>/dev/null?1>&2
demount=$
fi
fi
Before carry portable hard drive, download ntfs-3g software package, obtain the read-write support of NTFS under linux system.
CN201410196382.XA 2014-05-12 2014-05-12 Script capable of carrying out automatic mounting under Linux Pending CN104007987A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410196382.XA CN104007987A (en) 2014-05-12 2014-05-12 Script capable of carrying out automatic mounting under Linux

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410196382.XA CN104007987A (en) 2014-05-12 2014-05-12 Script capable of carrying out automatic mounting under Linux

Publications (1)

Publication Number Publication Date
CN104007987A true CN104007987A (en) 2014-08-27

Family

ID=51368654

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410196382.XA Pending CN104007987A (en) 2014-05-12 2014-05-12 Script capable of carrying out automatic mounting under Linux

Country Status (1)

Country Link
CN (1) CN104007987A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105589657A (en) * 2014-10-23 2016-05-18 中兴通讯股份有限公司 Method and device for realizing mounting of mobile storage
CN105657309A (en) * 2015-12-29 2016-06-08 Tcl数码科技(深圳)有限责任公司 Multi-way data collection method and system of law enforcement recorder
CN105700980A (en) * 2016-04-27 2016-06-22 浪潮电子信息产业股份有限公司 Method for realizing automatic mounting of USB flash disk and testing rate of USB port
CN107608738A (en) * 2017-10-12 2018-01-19 郑州云海信息技术有限公司 Start the method, apparatus and computer-readable recording medium of object storage device
CN107741827A (en) * 2017-09-08 2018-02-27 郑州云海信息技术有限公司 A kind of out of order method and system of solution Linux disks
CN108279933A (en) * 2018-01-25 2018-07-13 郑州云海信息技术有限公司 A kind of method of automatic carry USB flash disk under Linux system
CN108984230A (en) * 2018-07-25 2018-12-11 郑州云海信息技术有限公司 A kind of password remapping method and system based on Linux

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
465096793: "《https://wenku.baidu.com/view/ee7df2727fd5360cba1adbe5.html》", 11 August 2011 *
MENGBING24: "《https://wenku.baidu.com/view/ec6b780a581b6bd97f19ea80.html》", 20 September 2011 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105589657A (en) * 2014-10-23 2016-05-18 中兴通讯股份有限公司 Method and device for realizing mounting of mobile storage
CN105657309A (en) * 2015-12-29 2016-06-08 Tcl数码科技(深圳)有限责任公司 Multi-way data collection method and system of law enforcement recorder
CN105700980A (en) * 2016-04-27 2016-06-22 浪潮电子信息产业股份有限公司 Method for realizing automatic mounting of USB flash disk and testing rate of USB port
CN107741827A (en) * 2017-09-08 2018-02-27 郑州云海信息技术有限公司 A kind of out of order method and system of solution Linux disks
CN107608738A (en) * 2017-10-12 2018-01-19 郑州云海信息技术有限公司 Start the method, apparatus and computer-readable recording medium of object storage device
CN107608738B (en) * 2017-10-12 2021-03-02 苏州浪潮智能科技有限公司 Method and device for starting object storage equipment and computer readable storage medium
CN108279933A (en) * 2018-01-25 2018-07-13 郑州云海信息技术有限公司 A kind of method of automatic carry USB flash disk under Linux system
CN108984230A (en) * 2018-07-25 2018-12-11 郑州云海信息技术有限公司 A kind of password remapping method and system based on Linux
CN108984230B (en) * 2018-07-25 2021-04-09 郑州云海信息技术有限公司 Linux-based password resetting method and system

Similar Documents

Publication Publication Date Title
CN104007987A (en) Script capable of carrying out automatic mounting under Linux
US9652271B2 (en) Autonomously managed virtual machine anti-affinity rules in cloud computing environments
US8990642B2 (en) Managing error logs in a distributed network fabric
US10089186B1 (en) Method and apparatus for file backup
EP2972728B1 (en) Tracking application usage in a computing environment
CN103513940A (en) Method for on-line extension of disk size of virtual machine and virtual system console
CN101650660A (en) Booting a computer system from central storage
US9338057B2 (en) Techniques for searching data associated with devices in a heterogeneous data center
JP2014127209A (en) Computer program installation system of virtual machine, and method for the same
CN104679852A (en) Method and device for recommending application software
CN103955405A (en) Application management method and device
CN111145382A (en) Log data processing method and device of automatic driving system
CN104951342A (en) Method and device for adjusting starting sequence
CN104932922A (en) Method and device for regulating boot sequence of SAS (Serial Attached SCSI) card hard disk
CN105224422A (en) A kind of data back up method and equipment
US20140082275A1 (en) Server, host and method for reading base image through storage area network
US10228961B2 (en) Live storage domain decommissioning in a virtual environment
CN105607869B (en) A kind of quick formatting and the method using magnetic disk of virtual machine
CN101950339A (en) Security protection method and system of computer
CN101833496A (en) Detection device based on host anti-object reusability of hard disk and detection method thereof
US10216433B2 (en) Accessing a virtual volume on a storage array
JP2014513344A (en) Method and apparatus for moving a software object in the background
US9009430B2 (en) Restoration of data from a backup storage volume
CN104133726A (en) Process context mandatory access control method
US8495033B2 (en) Data processing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140827