# Mount

Related articles

- Fstab
- Udev
- File permissions and attributes
- umask
- File systems
- USB Storage Devices
- List of applications#Mount tools
- Optical Disc Drive
- QEMU#Mounting a partition_inside a raw disk image

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-3g for mounting NTFS filesystems.

## Supported file systems

To view the supported file systems by your kernel:

    $ zgrep _FS= /proc/config.gz

Or, for a cleaner output:

    $ zgrep _FS= /proc/config.gz | sed "s/^CONFIG_//m" | sed "s/.$//m" | sed "s/_FS=//m" | sort

A list of the supported file systems are also visible in `man mount`.

To view the supported files systems by your kernel and their configurations:

    $ zgrep -e 'FS_' -e _FS -e 'CONFIG_ISO' -e  '_NLS=' -e CONFIG_NLS_ISO /proc/config.gz

## Changing the default options

Here are a few examples about how to extend mount functionality and modify default options. To change the default settings in the kernel you will need to compile the kernel yourself. If the script does not exist then the default options will be used.

- By compiling the kernel yourself
- By using scripts
- By editing fstab
- By creating udev / udisks rules - device manager for the Linux kernel.

The mount.X scripts, 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. Use the -i option to ignore mount.X scripts, `mount -i -t reiserfs /dev/sdXY /mnt/sdXY`.

### 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

Note: Default mount permission rights is rwxr-xr-x, `umask=755` same as `fmask=0022,dmask=0022`

If the partition type detected by mount is VFAT then it will run the `/usr/bin/mount.vfat` script.

    $ cat /usr/bin/mount.vfat

    #!/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 "$@"

See also: more details about mounting of the FAT file systems.

### NTFS

The default configuration:

    $ zgrep ^CONFIG_NTFS  /proc/config.gz

    CONFIG_NTFS_FS=m
    CONFIG_NTFS_RW=y

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.

Note:

- When ntfs-3g is being installed it might create a symlink `/usr/bin/mount.ntfs` to the `/usr/bin/ntfs-3g`.
- The ntfs-3g mount tool supports many of the same command line options as the linux standard mount utility, but is specialized on mounting of the NTFS formated partitions.
- By default on mounting the ntfs-3g driver gives the full read-write permissions to the all users. In some situations access with a full permission rights can cause the damage, see NTFS troubleshooting.

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:

    $ cat /usr/bin/mount.ntfs

    #!/bin/bash
    #mount -i -oro "$@"
    #mount with a read-only rights
    ntfs-3g -oro  "$@" & disown

See `man 8 ntfs-3g` for more information about the ntfs-3g driver.

### ISO image file, CD, DVD

When the iso9660 image type is detected by mount, it will run the `/usr/bin/mount.iso9660` script.

    $ cat /usr/bin/mount.iso9660

     #!/bin/bash
     mount -i -t iso9660 "$@"
     #mount -oloop,ro,relatime,utf8 -i -t iso9660 "$@"
     # fuseiso "$@"

- It works by adding `utf8` but will get errors when using `iso8859` for iocharset.
- The `utf8` option is the same as `iocharset=utf8`, you can use either of them.
- You can even use fuseiso and then just comment out the mount line and uncomment `fuseiso "$@"`. Or use any other mount application in the script.

Note: You still need root rights (su/sudo) to use the mount command even if fuseiso is used in the script.

Defaults of ISO mount configuration in the kernel:

    $ zgrep -e CONFIG_ISO -e  CONFIG_NLS_ISO /proc/config.gz

    CONFIG_ISO9660_FS=m
    CONFIG_NLS_ISO8859_8=m
    CONFIG_NLS_ISO8859_1=m
    CONFIG_NLS_ISO8859_2=m
    CONFIG_NLS_ISO8859_3=m
    CONFIG_NLS_ISO8859_4=m
    CONFIG_NLS_ISO8859_5=m
    CONFIG_NLS_ISO8859_6=m
    CONFIG_NLS_ISO8859_7=m
    CONFIG_NLS_ISO8859_9=m
    CONFIG_NLS_ISO8859_13=m
    CONFIG_NLS_ISO8859_14=m
    CONFIG_NLS_ISO8859_15=m

### ReiserFS

Defaults of the reiserfs:

    $ zgrep -ie reiserfs /proc/config.gz

    CONFIG_REISERFS_FS=m
    # CONFIG_REISERFS_CHECK is not set
    CONFIG_REISERFS_PROC_INFO=y
    CONFIG_REISERFS_FS_XATTR=y
    CONFIG_REISERFS_FS_POSIX_ACL=y
    CONFIG_REISERFS_FS_SECURITY=y

RaiserFS has a problem on mounting by using the `mount.reiserfs` script. Mount ignores the `-oro` switch for read-only and uses the `-orw` option for read-write, but has no problems for using of the `-oro` correctly from the command line. I tested only by creating and mounting a RaiserFS formatted file.

## Create and mount image files

### An empty file, format and mount

It is very easy to create an empty formated file with the dd command: `dd if=/dev/zero of=./testfile.reiserfs bs=200M count=1`

You can use mkfs.* the same way as it was a hard drive to create the file system on it but chose the file as a destination. `mkfs.reiserfs ./testfile.reiserfs -f` Is useful when you want to create a place to hide the files, protect or just store all on the same place in the one file... Windows cannot handle files like this in case someone want borrow your USB (mount inside mount). You can find a lot of reasons why or just for the testing purposes. To mount use the same routines as for other sources: `mount -i -oro -t reiserfs ./testfile.reiserfs /mnt`. After you created an empty (not compressed) file system formated file you can try check your real harddrive parttion with testdisk and it will find the "reiserfs" inside your partition.

### The compressed image file

#### SquashFS

To create a Squash file system you need to install the squashfs-tools package. SquashFS can be mounted only in the read-only mode. It supports a warriors compression methods such as gzip, lzma, lzo, lz4, xz where gzip is a default.

    mksquashfs source destination.img   -comp lzo  -Xalgorithm  lzo1x_999 -Xcompression-level 9

Note: Options must be in the end after a destination.

After the compressed file created you can mount it.

The mksquashfs utility doesn't have a man page in the Arch Linux but you can use the `mksquashfs -h` to see all available options.

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.

## See also

- Documentation of file systems supported by kernel: kernel.org
- Manual for the mount command: linux.die.net
- Wikipedia:Mount (Unix)
- Creating and using disk images mini-howto: darkdust.net

Category:

- File systems