mount is an application used to access file systems, partition tables, and shared folders. It can mount file systems supported by the Linux kernel, but can be extended with other drivers or applications, such as NTFS filesystems.for mounting
Supported file systems
To view the supported file systems by your kernel and their configurations:
$ zgrep -e 'FS_' -e _FS -e 'CONFIG_ISO' -e '_NLS=' -e CONFIG_NLS_ISO /proc/config.gz
You can read about supported file systems by the mount command in the manual:
Mounting a file system
The file /etc/fstab (see fstab(5)), may contain lines describing what devices are usually mounted where, using which options. A filesystem specified in
/etc/fstab will be mounted at boot time, with some exceptions. For example, any device whose line contains the
noauto option will not be mounted. This is useful for things like partitions for other OSes. External devices that are to be mounted when present, but ignored if absent, may require the
nofail option. See external devices for more information.
When mounting a filesystem mentioned in fstab or mtab, it is sufficient to give only the device, or only the mount point.
# mount /dev/sdXY
The mount program does not read the /etc/fstab file if device (or LABEL/UUID) and dir (mount point) are specified. For example:
# mount /dev/foo /dir
If the mount point does not exist, it may be necessary to create it first. To mount to MYDIR1:
# mkdir /mnt/mydir1 # mount /dev/sdXY /mnt/mydir1
man fstab and
man mount for more information.
Listing mounted file systems
You can see the mounted file systems by looking at the
mount program is executed without any arguments, this file is printed. Each line in the file represents a file system that is currently mounted and displays the following information:
- device node
- mount point
- file system type
- Mount options used while mounting the file system.
Alternatives to change the default mount options
A few examples about how to extend mount functionality and modify default options:
- By editing fstab to include the desired mount options
- By creating udev / udisks rules - mostly useful for removable devices
- Mounting manually / by using scripts
- The mount.X scripts or symbolic links, where X is the name of a file system, can be used to alter the default mount options for almost any of its supported file systems. Option
-iis used to let the mount command ignore mount.X scripts and must also be used inside mount.X scripts for any mount command.
- There are two ways to list the available scripts:
- Write mount and press a
- Write mount and press a
- To change the default settings in the kernel, you will need to compile it yourself.
Some other file systems
VFAT, FAT, DOS
Here is an example of the default mount configuration in the kernel:
$ zgrep -e FAT -e DOS /proc/config.gz | sort -r
# DOS/FAT/NT Filesystems CONFIG_FAT_FS=m CONFIG_MSDOS_PARTITION=y CONFIG_FAT_FS=m CONFIG_MSDOS_FS=m CONFIG_VFAT_FS=m CONFIG_FAT_DEFAULT_CODEPAGE=437 CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" CONFIG_NCPFS_SMALLDOS=y
A short description of the options:
- Language settings: CONFIG_FAT_DEFAULT_CODEPAGE, CONFIG_FAT_DEFAULT_IOCHARSET
- All filenames to lower letters on a FAT partitions if enabled: CONFIG_NCPFS_SMALLDOS
- Enables support of the FAT file systems: CONFIG_FAT_FS, CONFIG_MSDOS_FS, CONFIG_VFAT_FS
- Enables support of a FAT partitioned harddisks on 86x PCs: CONFIG_MSDOS_PARTITION
If the partition type detected by mount is VFAT then it will run the
#!/bin/bash #mount VFAT with full rw (read-write) permissions for all users #/usr/bin/mount -i -t vfat -oumask=0000,iocharset=utf8 "$@" #The above is the same as mount -i -t vfat -oiocharset=utf8,fmask=0000,dmask=0000 "$@"
The default configuration:
$ zgrep ^CONFIG_NTFS /proc/config.gz
The kernel config option
CONFIG_NTFS_RW=y enables read-write support for NTFS file systems. It also means the kernel is predefined to use the ntfs-3g driver in read-write mode. The build in support of the NTFS file systems by the kernel is read-only even if read-write is activated by an option.
The default mount options can be altered when running
mount.ntfs by renaming the
/usr/bin/mount.ntfs symlink if exists and creating a script in its place with a preferred options or use the -i option (
mount -i -t ntfs) to ignore all the mount.X files and use the natively supported functionality by the kernel. This example will mount NTFS as a read-only:
#!/bin/bash #mount -i -oro "$@" #mount with a read-only rights ntfs-3g -oro "$@" & disown
man 8 ntfs-3g for more information about the ntfs-3g driver.
You can add more actions for when an external storage device, such as a USB drive or image file (ISO, img, dd), is mounted by using scripts.