mount

Used to mount files outside the Linux system

Supplementary instructions

mount command The Linux mount command is a frequently used command. It is used to mount files outside the Linux system.

If you mount a network disk through the webdav protocol, you need to run the command apt install davfs2 to install the necessary components.

grammar

mount [-hV]
mount -a [-fFnrsvw] [-t vfstype]
mount [-fnrsvw] [-o options [,...]] device | dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir

Options

-V: Display program version
-h: Display auxiliary information
-v: Display comparative information, usually used with -f for debugging.
-a: Mount all file systems defined in /etc/fstab.
-F: This command is usually used together with -a. It will generate a process for each mount action. When the system needs to mount a large number of NFS file systems, it can speed up the mounting action.
-f: Usually used for debugging purposes. It will cause mount not to perform the actual mounting action, but to simulate the entire mounting process. Usually used with -v.
-n: Generally speaking, mount will write a piece of data in /etc/mtab after mounting. However, you can use this option to cancel this action when there is no writable file system in the system.
-s-r: equal to -o ro
-w: equal to -o rw
-L: Split and mount the hard disk with a specific label.
-U: Hang the file system with the file split serial number. -L and -U are only meaningful when a file of this type /proc/partition exists.
-t: Specifies the file system type, usually does not need to be specified. mount will automatically select the correct type.
-o async: Turn on asynchronous mode, all file reading and writing operations will be performed in asynchronous mode.
-o sync: Execute in synchronous mode.
-o atime, -o noatime: When atime is turned on, the system will update the "last call time" of the file each time it 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: Turn on/off automatic hang mode.
-o defaults: Use default options rw, suid, dev, exec, auto, nouser, and async.
-o dev, -o nodev -o exec, -o noexec allow executable files to be executed.
-o suid, -o nosuid: Allow executable files to be executed under root privileges.
-o user, -o nouser: Users can perform mount/umount actions.
-o remount: Remount an already mounted file system in a different way. For example, a system that was originally read-only is now remounted in read-write mode.
-o ro: Mount in read-only mode.
-o rw: Mount in read-write mode.
-o loop=: Use loop mode to partition a file as a hard disk and mount it on the system.

Example 1

Mount /dev/hda1 under /mnt.

mount /dev/hda1 /mnt

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

mount -o ro /dev/hda1 /mnt

Mount the image file of the CD /tmp/image.iso under /mnt/cdrom using loop mode. This method allows you to view the contents of a Linux disc ISO file that can be found on the general network without burning it to a disc.

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

Example 2

Mount network hard disk through webdav protocol

Mount the network storage of https://your.webdav.link.here to the system path /path/to/mount in the form of a network disk

mount -t davfs https://your.webdav.link.here /path/to/mount

Example 3

Mount the Android system system partition to /dev/loopX. If you know the file format, you can use -t to specify the file format, such as ext4.

mount -t ext4 /dev/loopX /mnt/system