Mount
Montar normalmente implica la conexión de un sistema de archivos adicional al sistema de archivos accesible en un computador.[1]
Mounting typically involves the attaching of an additional filesystem to the currently accessible filesystem of a computer.[2]
Instalación
La orden mount es parte del paquete sys-apps/util-linux. En Gentoo Linux sys-apps/util-linux es parte del conjunto del sistema y está instalado en todos los sistemas Gentoo por defecto. Si por alguna extraña y no común razón no estuviera instalado, se pude instalar con la orden emerge:
If for some strange and unordinary reason it is missing it can be re-installed by running a simple emerge command (always use the --oneshot
option). This can also be used after changing USE flags:
root #
emerge --ask sys-apps/util-linux
Utilización
root #
mount --help
List mounts
Se pueden mostrar los sistemas de archivos montados lanzando la orden sin argumentos ni opciones:
root #
mount
There is also a more visual way of showing mounted filesystems using the findmnt tool also provided by sys-apps/util-linux. For more details see man 8 findmnt.
Mount filesystem
To mount a filesystem, a device file, UUID or label or other means of locating the partition or data source and a mount point are required. Non-system relevant filesystems are normally mounted in the /mnt directory. The proper syntax for mounting a file system is as follows:
root #
mount <DISPOSITIVO> <DIRECTORIO>
Para más detalles, lea man 8 mount.
The /media directory is generally used to mount removable devices such as USB drives or SD cards. After determining which device the USB drive shows up as, a command like the following could be used to mount its contents to a newly created usb folder in /media:
root #
mkdir /media/usb
root #
mount /dev/sdb1 /media/usb
{{{1}}}
Unmount a filesystem
To unmount a filesystem, the device file or the mount point can be specified:
root #
umount <DISPOSITIVO>
root #
umount <DIRECTORIO>
Invocation information:
user $
umount --help
Mount options
Sometimes, mounting a filesystem requires special options:
root #
mount [OPciones] <DISPOSITIVO> <DIRECTORIO>
Opción | Descripción |
---|---|
-f
|
Simula el montaje |
-t
|
Especifica el sistema de archivos, por ejemplo ext4 |
-o OPCIÓN1,OPCIÓN2,...
|
Especifica las opciones de montaje (vease abajo) |
-a
|
Monta todos los sistemas de archivos en /etc/fstab |
The filesystem being used must support the mount option being passed. Many options are common, but some are filesystem specific.
Option | Description |
---|---|
defaults
|
Use the default mount options: rw , suid , dev , exec , auto , nouser , async .
|
auto
|
Mount the filesystem automatically on boot. |
noauto
|
Do not mount the filesystem automatically on boot. |
ro
|
Mount the filesystem read-only. |
rw
|
Mount the filesystem read-write. |
sw
|
Mount a swap partition. |
atime
|
Update inode access times on every read. |
relatime
|
Update inode access times only on writes to improve I/O performance. |
noatime
|
Never update inode access times for best I/O performance. |
sync
|
Sync drive after each write. Can shorten lifespan for e.g. some flash drives. |
async
|
Sync drive asynchronously. |
discard
|
The equivalent of trim support on Linux. |
exec
|
Allow execution of binaries. |
noexec
|
Do not allow execution of binaries. |
suid
|
Follow SUID and SGID bits. |
nosuid
|
Do not follow SUID and SGID bits. |
user
|
Allow a user to mount the filesystem. Implies nodev , noexec , and nosuid options unless explicitly setting dev , exec , or suid respectively.
|
users
|
Allow every user to mount the filesystem. |
nouser
|
Allow only "root" to mount the filesystem. |
Mount options of already-mounted filesystems can be changed using remount
option. For example, setting a filesystem on /dev/foo to be mounted as read-write can be achieved using:
root #
mount -o remount,rw /dev/foo /dir
Tips
Mounting as non-superuser
According to man mount, only the superuser can mount filesystems. However, when /etc/fstab contains the user
option on a line, any user will be capable of mounting the corresponding partition, device, drive, etc.
Mounting removable media
See the relevant section in the Removable media article.
Despite /etc/fstab entries, non-superuser mounts of Windows shares will fail (for security reasons). In the following example is found a fstab entry for Windows share; pay close attention to the cifs
option:
/etc/fstab
[...]
//servidor/carpeta /home/larry/winmount cifs noauto,user 0 0
[...]
user $
mount /home/larry/winmount
This program is not installed setuid root - "user" CIFS mounts not supported.
The solution is to use sudo mount /home/larry/winmount in combination with a corresponding entry in /etc/sudoers to allow passwordless mounting.
/etc/sudoers
[...]
larry ALL = NOPASSWD: /bin/mount /home/larry/winmount/, /bin/mount /home/larry/winmount
larry ALL = NOPASSWD: /bin/umount /home/larry/winmount/, /bin/umount /home/larry/winmount
[...]
Ver también
- Mounting partitions in the Security Handbook
- /etc/fstab — un fichero de configuración que defines cómo y dónde se deben montar los sistemas de ficheros, especialmente en el arranque del sistema.
- Removable media — any media that is easily removed from a system.
- AutoFS — a program that uses the Linux kernel automounter to automatically mount filesystems on demand.
- Udevil — a small auto-mount utility created to be a "a hassle-free replacement for udisks."
- CurlFtpFS — allows for mounting an FTP folder as a regular directory to the local directory tree.
- USB/Guide - Mounting a USB Mass Storage device
- UUIDs and labels