NAME
mount - mount a filesystem
SYNOPSIS
mount [-lhV]
mount -a [-fFnrsvw] [-t vfstype] [-O
optlist]
mount [-fnrsvw] [-o
option[,option]...] device|dir
mount [-fnrsvw] [-t vfstype] [-o
options] device dir
DESCRIPTION
All files accessible in a Unix system are
arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over
several devices. The mount command serves to attach the
filesystem found on some device to the big file tree. Conversely, the
umount(8) command will detach it again.
The standard form
of the mount command, is
mount -t type device dir
This tells
the kernel to attach the filesystem found on device (which is of type
type) at the directory dir. The previous
contents (if any) and owner
and mode of
dir become invisible,
and as long as this filesystem remains mounted, the pathname dir refers
to the root of the filesystem on device.
The listing and help
Three forms of invocation do not
actually mount anything:
mount –h prints a help message
mount –V prints a version string
mount [-l] [-t type] lists all mounted filesystems (of type
type). The option -l adds the labels in
this listing. See below.
The device indication
Most devices are
indicated by a file name (of a block
special device), like /dev/sda1,
but there are other possibilities. For example, in the case of an NFS
mount, device may
look like knuth.cwi.nl:/dir. It is
possible to indicate a block special device using its volume LABEL or UUID (see
the -L and -U options below).
The recommended
setup is to use LABEL=<label> or UUID=<uuid> tags rather than
/dev/disk/by-{label,uuid} udev symlinks in
the /etc/fstab file. The
tags are more
readable, robust and portable. The mount(8) command internally
uses udev symlinks, so use the symlinks
in /etc/fstab is
not advantage over LABEL=/UUID=. For more details see libblkid(3). The proc
filesystem is not associated with a special device, and when mounting it, an
arbitrary keyword, such as proc can be used instead of a device
specification. (The customary choice
none is less fortunate: the error message ‘none busy’ from umount can be
confusing.)
The /etc/fstab,
/etc/mtab and /proc/mounts files. The file /etc/fstab (see fstab(5)), may
contain lines describing what devices are usually mounted where, using which
options.
The command
mount -a [-t type] [-O optlist]
(usually given in
a bootscript) causes all filesystems mentioned in fstab (of the proper type
and/or having or not
having the proper options)
to be mounted as indicated, except for those whose
line contains the noauto keyword.
Adding the -F
option will make mount fork, so that the filesystems are mounted
simultaneously.
When mounting a
file system mentioned in fstab or mtab, it suffices to give only the device, or
only the mount point. The programs mount
and umount maintain
a list of currently mounted filesystems in the file /etc/mtab. If no arguments are given to mount, this list is printed. The mount
program does not read the
/etc/fstab file if device (or LABEL/UUID) and dir are specified. For example:
mount /dev/foo /dir
If you want to
override mount options from /etc/fstab
you have to use:
mount device|dir -o <options>
and then the
mount options from command line will be appended to the list of options from
/etc/fstab. The usual behavior is that the last option wins if there is more
duplicated options. When the proc file system is mounted (say at /proc), the
files /etc/mtab and /proc/mounts have very similar contents. The former
has somewhat more
information, such as the mount options used, but is not necessarily
up-to-date (cf. the -n option below). It is possible to replace /etc/mtab by a
symbolic link to /proc/mounts, and especially when you have very large numbers of
mounts things will be much faster with that symlink, but some information is
lost that way, and in particular using the "user" option will fail.
The non-superuser mounts
Normally, only
the superuser can mount
filesystems. However, when fstab
contains the user option on a line, anybody can mount the corresponding system.
Thus, given a line
/dev/cdrom /cd
iso9660 ro,user,noauto,unhide
any user
can mount the iso9660 filesystem found on his CDROM using
the command
mount /dev/cdrom
or
mount
/cd
For more details,
see fstab(5). Only the user that
mounted a filesystem can unmount it again. If any user should be able to unmount, then
use users instead of user in the fstab line. The owner option is similar to the user
option, with the restriction that the user must be the owner of the special
file. This may be useful e.g. for /dev/fd if a login script makes the console
user owner of this
device. The group option is
similar, with the restriction that
the user must be member of the group of the special
file.
The bind mounts
Since Linux 2.4.0 it is possible to
remount part of
the file hierarchy somewhere
else. The call is mount --bind olddir newdir or shortoption
mount -B olddir newdir
or fstab
entry is:
/olddir
/newdir none bind
After this call
the same contents is accessible in two places. One can also remount a single
file (on a single file). This call attaches only (part of) a single filesystem,
not possible submounts.
The entire file hierarchy including submounts is attached a second place
using
mount --rbind olddir newdir
or
shortoption
mount -R
olddir newdir
Note that the
filesystem mount options will remain the same as those on
the original mount
point, and cannot be changed by passing the -o option
along with --bind/--rbind. The
mount options can be changed by a separate remount command,
for example:
mount --bind olddir newdir
mount -o remount,ro newdir
The move operation
Since Linux 2.5.1 it is possible
to atomically move a mounted tree to another place. The call is
mount --move olddir newdir
or shortoption
mount -M olddir newdir
This will cause
the contents which previously appeared under olddir to be accessed under
newdir. The physical location of the
files is not changed.
The shared subtrees operations
Since Linux 2.6.15 it is possible to
mark a mount and its submounts as shared, private, slave or unbindable. A
shared mount provides ability to
create mirrors of
that mount such that mounts and umounts within any of
the mirrors propagate to the
other mirror. A slave mount receives propagation from its
master, but any not vice-versa. A private mount carries no propagation abilities. A unbindable mount is a private
mount which cannot cloned through a bind operation. Detailed
semantics is documented in
Documentation/sharedsubtree.txt file in the kernel source tree.
mount --make-shared
mountpoint
mount --make-slave
mountpoint
mount --make-private
mountpoint
mount --make-unbindable
mountpoint
The following
commands allows one to recursively change the type of all the mounts under a
given mountpoint.
mount --make-rshared
mountpoint
mount --make-rslave
mountpoint
mount --make-rprivate
mountpoint
mount --make-runbindable mountpoint
COMMAND LINE OPTIONS
The full set of mount options used by an
invocation of mount is determined by first extracting the mount options for the
filesystem from the fstab table,
then applying any options specified by
the -o argument, and finally applying a -r or -w option, when present.
Command
line options available for the mount command:
-V,
--version Output version.
-h,
--help Print a help message.
-v,
--verbose Verbose
mode.
-a,
--all Mount all filesystems
(of the given types) mentioned in fstab.
-i,
--internal-only Don’t call
the
/sbin/mount.<filesystem>
helper even if it exists.
-l Add
the labels in the mount output. Mount must
have permission to read
the disk device (e.g. be suid
root) for this to work. One can set such a label for
ext2, ext3 or
ext4 using the e2label(8) utility, or for XFS using xfs_admin(8), or
for reiserfs using reiserfstune(8).
-n,
--no-mtab Mount
without writing in /etc/mtab. This is
necessary for example when /etc is on a read-only filesystem.
-r,
--read-only Mount the filesystem read-only. A
synonym is -o ro.
Note that,
depending on the filesystem type,
state and kernel behavior, the system may still write to
the device. For example, Ext3 or ext4 will replay its journal if the filesystem
is dirty. To prevent this kind of write access, you may want to mount ext3 or
ext4 filesystem with "ro,noload" mount options
or set the block device to read-only mode, see
command blockdev(8).
-w, --rw Mount the filesystem read/write. This is the
default. A synonym is -o rw.
-L label Mount
the partition that has the specified label.
-U
uuid Mount the partition that has the
specified uuid. These two options require the file /proc/partitions (present
since Linux 2.1.116) to exist.
0 comments:
Post a Comment