Attaching external storage or a network share to your Linux file system requires creating a mount point as the access location. This guide will show you exactly how to create a mount point in Linux using simple commands and best practices. You’ll learn everything from basic directory creation to permanent mounts that survive reboots.
Understanding Mount Points In Linux
A mount point is simply a directory where you attach a file system. Think of it as a doorway. When you plug in a USB drive or connect a network share, Linux needs a specific folder to access that storage. Without a mount point, your system can’t interact with the new storage device.
Every Linux system has a root directory (/). All other directories branch from there. When you create a mount point, you’re essentially creating a new branch where external data becomes visible.
Why Mount Points Matter
Mount points keep your file system organized. Instead of guessing where your external drive appears, you decide the exact location. This prevents confusion and makes automation easier. For example, you can mount a backup drive at /mnt/backup and know exactly where to find your files.
Without proper mount points, you risk data loss or system instability. The system might mount devices in unpredictable locations, especially if you have multiple storage devices connected.
How To Create A Mount Point In Linux
Now let’s get practical. The process involves three main steps: creating the directory, mounting the device, and verifying the mount. Here’s the complete workflow.
Step 1: Identify Your Storage Device
Before creating a mount point, you need to know what device you’re working with. Use the lsblk command to list all block devices:
lsblk
This shows devices like /dev/sdb1 or /dev/nvme0n1p1. Look for the device you want to mount. Common identifiers include size, label, or type.
You can also use sudo fdisk -l for more details. This command lists partition tables and file system types. Note the device name carefully—mounting the wrong device can cause problems.
Step 2: Create The Mount Point Directory
Use the mkdir command to create a directory. Standard practice places mount points under /mnt for temporary mounts or /media for removable media. For permanent mounts, you might use /mnt or a custom path.
sudo mkdir /mnt/mydrive
Replace mydrive with a descriptive name. Avoid spaces in directory names—use underscores or hyphens instead. The directory must exist before you can mount anything to it.
You can create multiple mount points for different devices. Just ensure each directory name is unique. For example:
/mnt/backup/mnt/projects/media/usb1
Step 3: Mount The Device
Now attach the device to your new mount point. Use the mount command with the device path and mount point:
sudo mount /dev/sdb1 /mnt/mydrive
Replace /dev/sdb1 with your actual device. If the file system isn’t automatically detected, specify it with the -t option:
sudo mount -t ext4 /dev/sdb1 /mnt/mydrive
Common file system types include ext4, ntfs, vfat, and xfs. Use blkid to check the file system type if you’re unsure.
Step 4: Verify The Mount
Check that the mount succeeded. Use the df -h command to see mounted file systems:
df -h
Look for your mount point in the output. You should see the device, size, used space, and mount location. Alternatively, use mount | grep /mnt/mydrive to filter results.
Navigate to the mount point and list files to confirm access:
ls /mnt/mydrive
If you see your files, the mount worked. If not, check for errors in the previous steps.
Making Mounts Permanent With /Etc/fstab
Temporary mounts disappear after a reboot. To make them permanent, edit the /etc/fstab file. This file tells your system which file systems to mount automatically at boot.
Finding The UUID
Instead of device names like /dev/sdb1, use the UUID (Universally Unique Identifier). Device names can change when you add or remove hardware, but UUIDs remain constant. Find the UUID with:
sudo blkid
Copy the UUID for your device. It looks like UUID="abc123-...".
Editing Fstab
Open /etc/fstab with a text editor as root:
sudo nano /etc/fstab
Add a line at the end with this format:
UUID=your-uuid-here /mnt/mydrive ext4 defaults 0 2
Replace your-uuid-here with the actual UUID. Change the file system type if needed. The defaults option works for most cases. The numbers at the end control dump and fsck behavior—0 2 is standard for data partitions.
Save the file and exit. Test the configuration without rebooting:
sudo mount -a
This mounts all entries in fstab. If there are no errors, your setup is correct. Reboot to confirm the mount persists.
Common Mount Point Locations
Linux has standard directories for mount points. Understanding these helps you choose the right location for your needs.
/Mnt
This directory is for temporarily mounted file systems. System administrators traditionally use /mnt for manual mounts. It’s a good choice for testing or one-time connections.
/Media
Modern Linux distributions use /media for removable media like USB drives and CDs. Desktop environments often auto-mount devices here. You can manually create subdirectories under /media for custom mounts.
/Run/media
Some systems, especially those using systemd, mount removable media under /run/media/username/. This is dynamic and works well for user-specific mounts.
Custom Paths
You can create mount points anywhere in your file system. For example, mount a network share at /home/youruser/shared or a backup drive at /srv/backups. Just ensure the directory exists and has appropriate permissions.
Mounting Network Shares
Network file systems like NFS or Samba require the same mount point process. Create a directory first, then mount the share.
NFS Mount Example
sudo mkdir /mnt/nfs_share
sudo mount -t nfs 192.168.1.100:/exported/path /mnt/nfs_share
Install the NFS client if needed: sudo apt install nfs-common (Debian/Ubuntu) or sudo dnf install nfs-utils (Fedora).
Samba Mount Example
sudo mkdir /mnt/smb_share
sudo mount -t cifs //server/share /mnt/smb_share -o username=youruser
Install CIFS utilities: sudo apt install cifs-utils or sudo dnf install cifs-utils.
For permanent network mounts, add entries to /etc/fstab with the appropriate options like _netdev to delay mounting until network is available.
Permissions And Ownership
After mounting, you might encounter permission issues. The mounted file system inherits permissions from the device, not the mount point directory. To control access, use mount options.
Changing Permissions With Mount Options
Add options like uid, gid, umask, or fmask to the mount command or fstab entry. For example, to give your user full access:
sudo mount -o uid=1000,gid=1000 /dev/sdb1 /mnt/mydrive
Replace 1000 with your user’s UID and GID. Find these with id command.
For FAT or NTFS file systems, use dmask and fmask to set directory and file permissions:
sudo mount -o uid=1000,gid=1000,dmask=027,fmask=137 /dev/sdb1 /mnt/mydrive
Using ACLs
For ext4 and other Linux file systems, use Access Control Lists (ACLs) for fine-grained permissions. Enable ACLs with the acl mount option, then use setfacl to assign permissions.
sudo mount -o acl /dev/sdb1 /mnt/mydrive
sudo setfacl -m u:youruser:rwx /mnt/mydrive
Troubleshooting Mount Issues
Sometimes mounts fail. Here are common problems and solutions.
Device Busy Error
If you get “device is busy,” another process is using the file system. Use lsof or fuser to find the culprit:
sudo lsof /mnt/mydrive
sudo fuser -v /mnt/mydrive
Close the offending application or kill the process. Then unmount and remount.
Wrong File System Type
If the mount command fails with “wrong fs type,” specify the correct type with -t. Use blkid to check the file system. For unknown types, try auto:
sudo mount -t auto /dev/sdb1 /mnt/mydrive
Permission Denied
If you can’t access the mount point, check directory permissions. The mount point itself must be accessible. Also check the mounted file system’s permissions using ls -la on the mount point.
Mount Not Persistent
If the mount disappears after reboot, verify your /etc/fstab entry. Check for typos in the UUID, mount point, or file system type. Use sudo mount -a to test without rebooting.
Unmounting A File System
To safely remove a mounted device, use the umount command:
sudo umount /mnt/mydrive
Always unmount before physically disconnecting a drive. This prevents data corruption. If you get “target is busy,” use lsof to find open files, or force unmount with umount -l (lazy unmount) as a last resort.
Automating Mounts With Scripts
For repeated tasks, create a script to mount and unmount. Here’s a simple bash script example:
#!/bin/bash
MOUNT_POINT="/mnt/mydrive"
DEVICE="/dev/sdb1"
if [ ! -d "$MOUNT_POINT" ]; then
sudo mkdir -p "$MOUNT_POINT"
fi
sudo mount "$DEVICE" "$MOUNT_POINT"
echo "Mounted $DEVICE at $MOUNT_POINT"
Save the script, make it executable with chmod +x, and run it when needed. You can also add it to cron for scheduled mounts.
Best Practices For Mount Points
Follow these guidelines to keep your system organized and reliable.
- Use descriptive mount point names that reflect the content or purpose
- Avoid mounting at the root directory or system directories like
/etc - Always use UUIDs in fstab instead of device names
- Test mounts with
mount -abefore rebooting - Document your mount points in a readme file or system notes
- Use the
noexecoption for data partitions to prevent execution of binaries - Regularly check mounted file systems with
df -handmount
Advanced Mount Options
For specific use cases, customize mount behavior with options.
Read-Only Mounts
Prevent accidental writes with the ro option:
sudo mount -o ro /dev/sdb1 /mnt/mydrive
Noexec Mounts
Disable program execution from the mounted file system:
sudo mount -o noexec /dev/sdb1 /mnt/mydrive
Bind Mounts
Mount an existing directory to another location:
sudo mount --bind /original/path /new/mountpoint
This is useful for making directories accessible from multiple locations without copying data.
Mounting ISO Files
You can mount ISO files using a loop device. Create a mount point first, then mount the ISO:
sudo mkdir /mnt/iso
sudo mount -o loop /path/to/file.iso /mnt/iso
This lets you access the ISO contents without burning it to a disc.
Monitoring Mount Points
Use system tools to monitor mounts. The findmnt command shows a tree view of mounted file systems:
findmnt
For real-time monitoring, use watch:
watch -n 5 df -h
This updates every 5 seconds, useful when testing mount stability.
Security Considerations
Mount points can introduce security risks if not configured properly.
- Avoid mounting untrusted file systems with
suidordevoptions - Use the
nosuidoption to ignore setuid bits on mounted file systems - Restrict access to mount points with proper permissions
- For network mounts, use encrypted protocols like NFSv4 with Kerberos
- Regularly audit fstab entries for unauthorized changes
FAQ: Mount Points In Linux
What is a mount point in Linux?
A mount point is a directory where you attach a file system, making its contents accessible. It acts as the access location for storage devices, network shares, or ISO files.
How do I create a mount point in Linux?
Use the mkdir command to create a directory, then use mount to attach the device. For example: sudo mkdir /mnt/mydrive followed by sudo mount /dev/sdb1 /mnt/mydrive.
Can I mount multiple devices to the same mount point?
No, each mount point can only host one file system at a time. Mounting a new device to an occupied mount point hides the previous content until unmounted.
How do I make a mount point permanent?
Add an entry to /etc/fstab with the device UUID, mount point, file system type, and options. Use