Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of mount Command under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the use of mount commands under Linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the use of mount commands under Linux".

Linux mount command is a frequently used command, it is used to mount files outside the Linux system, this command is most commonly used to mount cdrom, so that we can access the data in cdrom, because you insert the CD into cdrom, Linux will not be automatically mounted, you must use the Linux mount command to mount manually.

Linux shows that all directories are under a directory tree, regardless of which drive / hardware they are located on. The contents of the disk under Linux appear as subdirectories.

Use the Linux mount command to mount cdrom.

Command:

Mount-t auto / dev/cdrom / mnt/cdrom

The command is to mount the cdrom in the / mnt/cdrom directory, where I can access the contents.

Learning operation process:

[OK_008@CentOS4 ~] $mount-t auto / dev/cdrom / mnt/cdrom

Mount: only root can do that-ordinary users cannot mount cdrom, only root users can operate it.

[OK_008@CentOS4 ~] $

-- switch user operations:

[root@CentOS4 /] # mount-t auto / dev/cdrom / mnt/cdrom

Mount: the mount point / mnt/cdrom does not exist-- / mnt/cdrom directory does not exist and needs to be created first.

[root@CentOS4 /] # cd / mnt

-bash: cd: / mnt: No such file or directory

[root@CentOS4 /] #

[root@CentOS4 /] # mkdir-p / mnt/cdrom-create the / mnt/cdrom directory

[root@CentOS4 /] # ls

Bin dev home lib media mnt proc sbin srv tmp var

Boot etc initrd lost+found misc opt root selinux sys usr

[root@CentOS4 /] # mount-t auto / dev/cdrom / mnt/cdrom-Mount cdrom

Mount: block device / dev/cdrom is write-protected, mounting read-only-mounted successfully

[root@CentOS4 /] # ls-l / mnt/cdrom-- View the contents of cdrom

Total 859

Dr-xr-xr-x 4 root root 2048 Sep 4 2005 CentOS

2 root root 8859 Mar 19 2005 centosdocs-man.css

-Rmuri-9 root root 18009 Mar 1 2005 GPL

Dr-xr-xr-x 2 root root 241664 May 7 02:32 headers

Dr-xr-xr-x 4 root root 2048 May 7 02:23 images

Dr-xr-xr-x 2 root root 4096 May 7 02:23 isolinux

Dr-xr-xr-x 2 root root 18432 May 2 18:50 NOTES

2 root root 5443 May 7 01:49 RELEASE-NOTES-en.html

Dr-xr-xr-x 2 root root 2048 May 7 02:34 repodata

-Rmuri-9 root root 1795 Mar 1 2005 RPM-GPG-KEY

2 root root 1795 Mar 1 2005 RPM-GPG-KEY-centos4

1 root root 571730 May 7 01:39 yumgroups.xml

[root@CentOS4 /] #

[root@CentOS4 /] # umount / mnt/cdrom-Uninstall cdrom. It's easy to use umount / mnt/cdrom directly.

For other parameters of the mount command, please refer to the following:

Name: mount

Rights of use: system administrator or users allowed in / etc/fstab

Mode of use:

Mount [- hV]

Mount-a [- fFnrsvw] [- t vfstype]

Mount [- fnrsvw] [- o options [,...]] Device | dir

Mount [- fnrsvw] [- t vfstype] [- o options] device dir

Description:

Interpret the contents of a file as a file system, and then hang it on a location in the directory. When this command is successfully executed, all files under this command will not be available for the time being until we remove the file system using umnount.

This command can be used to mount any file system, and you can even use the-o loop option to mount a general file as if it were a hard drive. This feature is very useful for interpreting ramdisk,romdisk or ISO 9660 video files.

Parameters.

-V

Show program version

-h

Display auxiliary messages

-v

Display more messages, usually with-f to debug.

-a

Mount all file systems defined in / etc/fstab.

-F

This command, usually used with-a, generates a stroke for each mount action to be executed. When the system needs to hang a large number of NFS file system, you can speed up the action of hanging.

-f

Usually used for debugging purposes. It causes mount not to perform the actual mount action, but to simulate the entire mount process. Usually used with-v.

-n

Generally speaking, mount will write a piece of data in / etc/mtab after hanging up. However, you can use this option to cancel this action if there is no writable file system in the system.

-smurr

Equal to-o ro

-w

Equal to-o rw

-L

Split the hard drive with a specific label and hang it.

-U

Hang up the file system with the file division serial number. -L and-U only make sense when files such as / proc/partition exist.

-t

Specify the type of file system, which is usually not required. Mount automatically selects the correct type.

-o async

Turn on asynchronous mode, and all file read and write actions will be performed in asynchronous mode.

-o sync

Executes in synchronous mode.

-o atime

-o noatime

When atime is opened, the last call time of the archive is updated each time the archive is read. When we use the flash file system, we may choose to turn this option off to reduce the number of writes.

-o auto

-o noauto

Toggles auto hang mode on / off.

-o defaults

Use the default options rw, suid, dev, exec, auto, nouser, and async.

-o dev

-o nodev-o exec

-o noexec

Allows the execution file to be executed.

-o suid

-o nosuid

Allows the execution file to be executed under root authority.

-o user

-o nouser

The user can perform the action of mount/umount.

-o remount

Re-mount a file system that has been suspended in a different way. For example, a system that used to be read-only is now re-hung in read-write mode.

-o ro

Hang up in read-only mode.

-o rw

Hang it in read / write mode.

-o loop=

Use loop mode to attach a file to the system as if it were a hard disk partition.

Example

Hang / dev/hda1 under / mnt.

# mount / dev/hda1 / mnt

Hang / dev/hda1 under / mnt in read-only mode.

# mount-o ro / dev/hda1 / mnt

Hang the image file of the CD / tmp/image.iso under / mnt/cdrom using loop mode. In this way, the contents of Linux ISO files that can be found on the network can be viewed without burning them into CDs.

# mount-o loop / tmp/image.iso / mnt/cdrom

Another command related to the Linux mount command is the Linux umount command.

Thank you for your reading, the above is the content of "the use of mount commands under Linux". After the study of this article, I believe you have a deeper understanding of the use of mount commands under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report