mount
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 file system found on some device to the big file tree. Conversely, the umount command will detach it again.[1]
Documentation
- man 8 'mount' [EN]
Parameters
- -a
- Mount all filesystems mentioned in fstab.
- -n, --no-mtab
- Mount without writing in /etc/mtab. This is necessary for example when /etc is on a read-only filesystem.
- -o OPTION,[OPTION,...]
- OPTIONs are specified with a -o flag followed by a comma separated string of options.
- loop
- This type of mount knows about three options, namely loop, offset and encryption, that are really options to losetup. (These options can be used in addition to those specific to the filesystem type.)
- If no explicit loop device is mentioned (but just an option -o loop is given), then mount will try to find some unused loop device and use that. If you are not so unwise as to make /etc/mtab a symbolic link to /proc/mounts then any loop device allocated by mount will be freed by umount. You can also free a loop device by hand, using losetup -d, see losetup.
- remount
- Attempt to remount an already-mounted file system. This is commonly used to change the mount flags for a file system, especially to make a readonly file system writeable. It does not change device or mount point.
- ro
- Mount the file system read-only.
- rw
- Mount the file system read-write.
- -t TYPE
- The argument following the -t is used to indicate the file system TYPE. The file system types which are currently supported include: adfs, affs, autofs, cifs, coda, coherent, cramfs, debugfs, 'devpts', 'efs', ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, 'ncpfs', nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, 'usbfs', vfat, xenix, xfs, xiafs.
- -w, --rw
- Mount the filesystem read/write. This is the default. A synonym is -o rw.
Examples
- Perform a file system check on /dev/hda1
mount -o 'remount,ro' '/dev/hda1'
fsck.ext2 -b 8193 '/dev/hda1'
mount -o 'remount,rw' '/dev/hda1'
- Mount a ISO image
mount -o 'loop' -t 'iso9660' "${HOME}/file.iso" '/media/cdrom/'
- Mount a Floppy image
mount -o 'loop' "${HOME}/floppy.img" '/media/floppy/'
- Mount a initial ramdisk (initrd)
cp '/boot/initrd' '/tmp/initrd.gz'
gunzip '/tmp/initrd.gz'
mount -o 'loop' '/tmp/initrd' '/mnt/'
- Make mount more human readable
my::mount() {
if [[ $# -eq 0 ]]; then
\mount | column -t
else
\mount "$@"
fi
}
alias mount='my::mount'
References
- ↑ man 8 'mount'