mount – mount a filesystem

mount command
mount command

mount attaches filesystems to the directory tree, making them accessible. Without arguments, it shows currently mounted filesystems.

Synopsis

mount [OPTIONS] DEVICE MOUNTPOINT
mount [OPTIONS] [-t TYPE] DEVICE MOUNTPOINT

Examples

Show mounted filesystems

$ mount
/dev/sda1 on / type ext4 (rw,relatime)
/dev/sdb1 on /data type xfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev)

Better view with findmnt

$ findmnt
$ findmnt -t ext4,xfs    # Only specific types

Mount a partition

$ sudo mount /dev/sdb1 /mnt/data

Mount with filesystem type

$ sudo mount -t ntfs /dev/sdc1 /mnt/usb
$ sudo mount -t vfat /dev/sdc1 /mnt/usb

Mount ISO image

$ sudo mount -o loop disk.iso /mnt/iso

Mount network share (NFS)

$ sudo mount -t nfs server:/share /mnt/nfs

Mount network share (CIFS/SMB)

$ sudo mount -t cifs //server/share /mnt/smb -o username=user

Mount with options

$ sudo mount -o ro /dev/sdb1 /mnt/data          # Read-only
$ sudo mount -o rw,noexec /dev/sdb1 /mnt/data   # No execute

Common Options

OptionDescription
-t TYPEFilesystem type
-o OPTIONSMount options
-rRead-only (same as -o ro)
-aMount all in /etc/fstab
--bindBind mount (mount directory to another location)

Mount Options (-o)

OptionDescription
roRead-only
rwRead-write
noexecDon’t allow execution
nosuidIgnore setuid bits
nodevIgnore device files
loopMount file as block device
uid=NSet owner UID
gid=NSet owner GID

Persistent Mounts (/etc/fstab)

# /etc/fstab
# <device>      <mountpoint>  <type>  <options>       <dump> <pass>
/dev/sdb1       /data         ext4    defaults        0      2
UUID=abc123     /backup       xfs     defaults,noatime 0     2
//server/share  /mnt/smb      cifs    credentials=/etc/samba/creds 0 0

Apply fstab changes:

$ sudo mount -a

Tips

  • Use UUID: More reliable than device names (blkid to find UUIDs)
  • Check fstab syntax: mount -a tests all entries
  • Unmount before removing: Always umount before disconnecting drives
  • Lazy unmount: umount -l if device is busy

See Also

  • umount — Unmount filesystems
  • df — Disk space usage
  • lsblk — List block devices
  • findmnt — Find mounted filesystems

Tutorials