Networking | Programming | Security | Linux | Computer Science | About

Mount Drives in Linux

Unlike the Microsoft Windows operating system, which mounts its filesystems automatically, the Linux operating system allows you to manually mount a filesystem or have a filesystem automatically mounted when your system initially starts up. So, what it mounting? Mounting is form of attaching or joining a separate storage device to your existing root directory hierarchy. It makes accessible physically sep- arate disks and/or partitions on a local or remote machine available to you. The attached location on the client machine is called a mount point.

The mount and umount Commands

To manually mount a filesystem to your existing root directory structure, the connection is established to a local mount point.

The Linux mount command can be used with and without any arguments. The Linux mount command issued with no arguments (as a stand-alone command) will list all of the currently mounted filesystems on your system:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=249110,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=401868k,mode=755)
/dev/vda1 on / type ext3 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup        (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup   (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs   (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=200936k,mode=700)

The Linux mount command, when issued with arguments, typically require only two arguments. The first argument represents the storage device that you wish to attach to your root directory structure. A unique feature about Linux operating systems is its treatment of devices (for example, storage devices, terminals). The Linux system treats devices as directories (folders). The /dev directory is used within the Linux environment to mount devices. The second argument represents the directory location where you want to attach it underneath. Again, this is known as the mount point. The general directory location for most Linux systems is the /mnt and /media directories. The /media directory, typically, is used for the mounting of remov- able media (for example, floppy disks, CD/DVD drives, and USB/thumb drives). In addition, prior to mounting any storage device, a mount point directory needs to exist before executing the mount command.

mount/dev/sdb1 /mnt/morestorage

The Linux mount command includes extra arguments (for example, sb for superblock, noload for turning off journaling) that can be used, if necessary. To execute the additional arguments, the -o argument must be specified first. To specify a specific filesystem type, the -t argument should be used. In most cases, the -t option is not necessary. The Linux kernel, typically, will detect the type of filesystem of the storage device that you are attaching.

Depending on the type of device you are mounting, at some point of time in the future, you may wish to disconnect the mounted device from the local mount point. To perform this operation, the Linux umount command is used. To perform this operation, only one additional argument is required. This argument, where you attached the device, is the mount point.


Note: The Linux umount command is spelled without the letter (n). Even though its purpose is to unmount the storage device, the actual command omits the letter n.


To automatically mount a filesystem, you need to become familiar with the /etc/fstab file. This text-based file contains the filesystems defined during the installation of the Linux distribution (for example, root partition, swap partition) and any new filesystems that you would like to mount on a permanent basis whenever the system is booted. Most Linux systems automatically mount removable devices such as CD/DVD, floppy disks, and USB devices.

The structure for adding a filesystem to the /etc/fstab file so that it can be mounted automatically at boot up contains the disk partition you want to mount, the directories mount point, the filesystem type, and other filesystem options (for example, noload, noatime, and noauto).

Published on Mon 08 September 2003 by Jake Steadman in Linux with tag(s): mount umount