Linux mount Command
The Linux mount command is a frequently used command that is used to mount files external to the Linux system.
Syntax
mount [-hV]
mount -a [-fFnrsvw] [-t vfstype]
mount [-fnrsvw] [-o options [,...]] device | dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir
Parameter Description:
- -V: Display program version
- -h: Display help information
- -v: Display more information, usually used with -f for debugging.
- -a: Mount all file systems defined in /etc/fstab.
- -F: This command is usually used with -a. It creates a process for each mount operation to execute. This can speed up the mounting action when a large number of NFS file systems need to be mounted.
- -f: Typically used for debugging purposes. It causes mount to simulate the entire mounting process without actually performing the mount. Usually used with -v.
- -n: Normally, mount writes an entry to /etc/mtab after mounting. This option can be used to cancel this action if there is no writable file system in the system.
- -s-r: Equivalent to -o ro
- -w: Equivalent to -o rw
- -L: Mount the disk partition with a specific label.
- -U: Mount the file system with the partition serial number. -L and -U are only meaningful when files like /proc/partitions exist.
- -t: Specify the type of file system, usually not necessary. Mount will automatically select the correct type.
- -o async: Enable asynchronous mode, all file read and write operations will be executed in asynchronous mode.
- -o sync: Execute in synchronous mode.
- -o atime, -o noatime: When atime is enabled, the system updates the 'last accessed time' of the file each time it is read. This option can be turned off to reduce the number of writes when using a flash file system.
- -o auto, -o noauto: Enable/disable automatic mount mode.
- -o defaults: Use the 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 permissions.
- -o user, -o nouser: Allow users to perform mount/umount actions.
- -o remount: Remount an already mounted file system with different options. For example, remount a read-only system with read-write mode.
- -o ro: Mount in read-only mode.
- -o rw: Mount in read-write mode.
- -o loop=: Use loop mode to mount a file as a disk partition.
Examples
Mount /dev/hda1 under /mnt.
#mount /dev/hda1 /mnt
Mount /dev/hda1 in read-only mode under /mnt.
#mount -o ro /dev/hda1 /mnt
Mount the CD image file /tmp/image.iso using loop mode under /mnt/cdrom. This method can be used to view the contents of a Linux CD ISO file found on the Internet without burning it to a CD.
#mount -o loop /tmp/image.iso /mnt/cdrom