{{Short description|Unix command to mount a filesystem}} {{lowercase}} {{Infobox software | name = mount | logo = | screenshot = Mount-command-example.png | screenshot size = | caption = | author = Ken Thompson,<br />Dennis Ritchie | developer = AT&T Bell Laboratories | released = {{Start date and age|1971|11|3}} | latest release version = | latest release date = | operating system = Unix and Unix-like | genre = Command | license = | website = }} In computing, '''<code>mount</code>''' is a command in various operating systems. Before a user can access a file on a Unix-like machine, the file system on the device<ref>{{Cite web|url=https://man7.org/linux/man-pages/man8/mount.8.html|title=mount(8) - Linux manual page|website=man7.org|access-date=2021-06-21|archive-date=2012-11-30|archive-url=https://web.archive.org/web/20121130074806/https://man7.org/linux/man-pages/man8/mount.8.html|url-status=live}}</ref> which contains the file needs to be mounted with the '''mount''' command. Frequently '''<code>mount</code>''' is used for SD card, USB storage, DVD and other removable storage devices. The command is also available in the EFI shell.<ref name="EFI-Shells-and-Scripting">{{cite web | url = http://software.intel.com/en-us/articles/efi-shells-and-scripting/ | title = EFI Shells and Scripting | publisher = Intel | accessdate = 2013-09-25 | archive-date = 2009-01-30 | archive-url = https://web.archive.org/web/20090130105136/http://software.intel.com/en-us/articles/efi-shells-and-scripting/ | url-status = live }}</ref>
==Overview== The '''<code>mount</code>''' command instructs the operating system that a file system is ready to use, and associates it with a particular point in the overall file system hierarchy (its ''mount point'') and sets options relating to its access. Mounting makes file systems, files, directories, devices and special files available for use and available to the user. Its counterpart '''<code>umount</code>''' instructs the operating system that the file system should be disassociated from its mount point, making it no longer accessible and may be removed from the computer. It is important to '''<code>umount</code>''' a device before removing it since changes to files may have only partially been written and are completed as part of the '''<code>umount</code>'''.
The '''<code>mount</code>''' and '''<code>umount</code>''' commands require root user privilege to effect changes. Alternately, specific privileges to perform the corresponding action may have been previously granted by the root user. A file system can be defined as user mountable in the <code>/etc/fstab</code> file by the root user.
==Examples== To display all mounted partitions: <syntaxhighlight lang="console"> $ mount proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/nvme0n1p1 on /efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remo unt-ro) /tmp on /var/tmp type none (rw,noexec,nosuid,bind) 10.4.0.4:/srv/export/setup_server on /nfs/setup_server type nfs (ro,addr=10.4.0.4) </syntaxhighlight>
To mount the second partition of a hard disk drive to the existing directory ''/media/PHOTOS'' (mount point): <syntaxhighlight lang="bash"> $ mount /dev/nvme0n1p5 /media/PHOTOS </syntaxhighlight> To unmount by referring to the physical disk partition: <syntaxhighlight lang="bash"> $ umount /dev/nvme0n1p5 </syntaxhighlight> To unmount by referring to the mount point: <syntaxhighlight lang="bash"> $ umount /media/PHOTOS </syntaxhighlight>
To remount a partition with specific options: <syntaxhighlight lang="bash"> $ mount -o remount,rw /dev/nvme0n1p5 </syntaxhighlight>
===Bind mounting===
Bind mounting allows a filesystem hierarchy or a file to be mounted at a different mount point. Unlike a symbolic link, a bind mount does not exist on the filesystem itself.<ref>{{Cite web|url=https://newbedev.com/what-is-the-difference-between-ln-s-and-mount-bind|title=What is the difference between ln -s and mount --bind?|access-date=2022-05-04|archive-date=2023-02-20|archive-url=https://web.archive.org/web/20230220021843/https://newbedev.com/what-is-the-difference-between-ln-s-and-mount-bind|url-status=live}}</ref> In the following example, the path <code>/olddir</code> will be mounted in <code>/newdir</code>
<syntaxhighlight lang="bash"> $ mount --bind /olddir /newdir </syntaxhighlight>
===Mounting loop devices===
A loop device is a device that corresponds to a file, usually a disk image. Mounting a loop device allows the file to be accessed as a filesystem. This allows it to be used as a virtual drive.
For example, a virtual disk image can be mounted as a regular filesystem.
<syntaxhighlight lang="bash"> $ mount -o loop my_virtual_disk.img /mnt </syntaxhighlight>
==Derivatives and wrappers== <code>pmount</code> is a wrapper around the standard '''mount''' program which permits normal users to mount removable devices without a matching /etc/fstab entry. This provides a robust basis for automounting frameworks like GNOME's Utopia project and keeps the usage of root to a minimum.
This package also contains a wrapper '''pmount-hal''', which reads information such as device labels and mount options from HAL and passes it to '''pmount'''.
The <code>gnome-mount</code> package contains programs for mounting, unmounting and ejecting storage devices. The goal for gnome-mount is for GNOME software such as gnome-volume-manager and GNOME-VFS to use this instead of invoking mount/umount/eject/pmount or direct HAL invoking methods. GNOME previously used pmount. Note, gnome-mount is not intended for direct use by users.
All the gnome-mount programs utilize HAL methods and as such run unprivileged. The rationale for gnome-mount is to have a centralized place (in GConf) where settings such as mount options and mount locations are maintained.<ref>{{Cite web|url=http://www.linuxfromscratch.org/blfs/view/svn/gnome/gnome-mount.html|archiveurl=https://web.archive.org/web/20080605160454/http://www.linuxfromscratch.org/blfs/view/svn/gnome/gnome-mount.html|url-status=dead|title=gnome-mount-0.6|archivedate=June 5, 2008}}</ref>
As with all unix-like commands, the options are specific to the version of mount and are precisely detailed in its man page.
In addition to the system call '''mount''', the function '''mount_root()''' mounts the first, or root filesystem. In this context '''mount''' is called by the system call '''setup'''.
==See also== * Mount (computing) * mtab * util-linux
==References== {{Reflist}}
==External links== * {{man|1|mount|v7}} * {{man|8|mount|die.net}} * {{man|8|mount|FreeBSD}} * {{man|1|pmount|die.net}} * {{man|1|gnome-mount|die.net}}
{{Unix commands}} {{Disk image emulators software}}
Category:Unix file system-related software