The Wayback Machine - https://web.archive.org/web/20240814182013/https://www.geeksforgeeks.org/mount-command-in-linux-with-examples/
Open In App

How to Mount File System in Linux | mount Command

Last Updated : 08 Jan, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

All files in a Linux filesystem are arranged in form of a big tree rooted at ‘/‘.These files can be spread out on various devices based on your partition table, initially your parent directory is mounted(i.e attached) to this tree at ‘/‘, others can be mounted manually using GUI interface(if available) or using mount command.

mount command is used to mount the filesystem found on a device to big tree structure(Linux filesystem) rooted at ‘/‘. Conversely, another command umount can be used to detach these devices from the Tree.

Understanding File Systems Available for Linux

Before we dive into the practical aspects of mounting file systems, let’s take a moment to understand what file systems are available on our Linux system. Open a terminal and use the following command to list the supported file systems:

cat /proc/filesystems

file system available

file system available

This command provides a list of file system types that Linux supports. Additionally, you can explore more detailed information using the manual:

man filesystems

This manual provides documentation on various file systems that Linux can work with.

How to List Currently Mounted File Systems on Linux

Now, let’s see what file systems are currently mounted on our Linux system. The mount command allows us to view this information easily:

mount

list mounted file system

list mounted file system

This command displays a list of currently mounted file systems. If you are curious about the static file systems, you can view them in the `/etc/fstab` file:

cat /etc/fstab

static filesystem

static filesystem

To explore mounted file systems in a tree structure, you can use the `findmnt` command:

findmnt

If you want to narrow down the output to a specific type of file system, you can do so with filters:

findmnt -t ext4

And if you’re interested in block devices, the lsblk command is handy:

lsblk

How to Mount File Systems on Linux

Now that we’ve covered the basics let’s move on to the practical aspects of mounting file systems on Linux. Mounting can be a temporary or permanent operation, and it’s typically performed by an administrator, either by logging in as the root user or by using the sudo command.

Syntax of mount Command

mount -t type device dir

Other forms:

mount [-l|-h|-V]
mount -a [-fFnrsvw] [-t fstype] [-O optlist]
mount [-fnrsvw] [-o options] device|dir
mount [-fnrsvw] [-t fstype] [-o options] device dir

These commands tell the Kernel to attach the filesystem found at device to the dir.

Note:

  • If you leave the dir part of syntax it looks for a mount point in /etc/fstab.
  • You can use –source or –target to avoid ambivalent interpretation.
    mount --target /mountpoint
    
    
  • /etc/fstab usually contains information about which device is need to be mounted where.
  • Most of the devices are indicated by files like /dev/sda4, etc. But it can be different for certain filesystems. Please refer below for more information.
    man mount
    
    

Note: It is important to note that we are only discussing the standard form of mount command given as syntax. Different forms are somewhat discussed because it has certain limitations on different kernels.

Options Available in mount Command

Options

Description

l

Lists all the file systems mounted yet.

h

Displays options for command.

V

Displays the version information.

a

Mounts all devices described at /etc/fstab.

t

Type of filesystem device uses.

T

Describes an alternative fstab file.

r

Read-only mode mounted.

Practical Examples of How to Mount File Systems on Linux with Available Options

1. Displays information about file systems mounted

2. Mounts file systems

3. Displays version information

4. Unmounts file systems

Frequently Asked Question

1. What is the purpose of mounting a file system in Linux?

Mounting a file system in Linux is like connecting a USB drive or accessing files from another location on your computer. It’s a way to make files and folders from an external source, like a disk or network, part of your computer’s directory structure. This allows you to interact with those files seamlessly as if they were on your computer all along.

2. How do I check which file systems are currently mounted on my Linux system?

To see what’s already connected or “mounted,” you can use the `mount` command in the terminal. It’ll show you a list of all the devices and locations that are currently a part of your system. Just type `mount` and press Enter.

3. Can I mount multiple file systems simultaneously in Linux?

Absolutely! You can connect more than one external device or network location at the same time. Each of these connections will have its own special place on your computer, called a “mount point.” Just make sure each one has its unique spot so you can easily find and use your files.

4. What is the difference between temporary and permanent mounting in Linux?

Think of temporary mounting like plugging in a USB drive for a quick look at your files. It’s done for a single time, and when you restart your computer, it won’t be connected anymore. Permanent mounting, on the other hand, is like setting up your favorite external hard drive to always be there whenever you turn on your computer. You configure it once, and it stays connected every time you start up.

5. How can I unmount a file system in Linux?

Unmounting is like safely removing your USB drive before pulling it out. If you want to disconnect a file system, use the `umount` command followed by the location where it’s connected.

For example, if your USB drive is at `/mnt/usb`, you’d type `umount /mnt/usb` and press Enter. Just make sure you’re not using any files from that location before you unmount!

Conclusion

In this article we discussed how to mount file system in linux using mount command in linux in which we learned that all your files are organized like a tree starting from the root ‘/’. Sometimes, your files are on different devices, and to access them, you use a command called ‘mount.’ This command connects those devices to specific folders in the tree. The mount command is like plugging in a USB drive or connecting to a network location. It can be temporary, for one session, or permanent, set up to connect every time you start your computer. Understanding and using the mount command helps you easily access your files. The FAQs at the end answer common questions, making it simpler for beginners to grasp.



Previous Article
Next Article

Similar Reads

How to Mount and Unmount Drives on Linux
In the Linux operating system, everything is treated as a file. Every Linux administrator must know how to organize and access files better. In this article, we will learn about the Mount and Unmount commands. What are mounting and unmounting in Linux?Mounting and Unmounting are essential tasks in any Linux Operating System. It allows users to acce
4 min read
Unmount File System in Linux Using the umount Command
Unmounting a file system is a vital procedure for securely deleting storage devices or rendering system resources accessible. A vital instrument in this procedure is the "umount" command, which enables users to softly unmount mounted devices or partitions. Before beginning the unmounting process, this step ensures data integrity and protects any po
7 min read
Ccat – Colorize Cat Command Output command in Linux with Examples
ccat is a command-line tool for Linux and OSX, which is similar to the cat command in Linux. But the difference between cat and ccat is that the ccat shows the content of the file with the syntax highlighted. Currently, ccat supports the following programming languages. JavaScriptJavaRubyPythonGoCJSONInstallation of Ccat First, we are going to see
2 min read
How to Display Command History in Linux | history Command
The command-line interface in Linux provides powerful tools for users, and mastering command history is essential for efficient navigation and retrieval of previously executed commands. The history command is a valuable utility that allows users to view and search through their command history. In this comprehensive guide, we will explore the vario
4 min read
file command in Linux with examples
file command is used to determine the type of a file. .file type may be of human-readable(e.g. ‘ASCII text’) or MIME type(e.g. ‘text/plain; charset=us-ascii’). This command tests each argument in an attempt to categorize it. It has three sets of tests as follows: filesystem test: This test is based on the result which returns from a stat system cal
3 min read
How to Save Output of Command in a File in Linux?
When we run a command on a terminal on Linux it generates some output of that command. Sometimes we need the output result of the commands. Today we are going to see how to save the output of the command. Using Redirections in Linux: We can use the redirections operators to save the output of commands into files. Redirection operators redirect the
3 min read
How to Create a Text File Using the Command Line in Linux
There are a couple of quick ways to create a text file from the Linux Command Line or Terminal. Some of them have been explained in the following article. 1) touch commandThis is the most standard command to quickly create an empty text file. The command is quite simple to type and makes it quite easier to create several text files at once. The com
6 min read
Extract Emails From a Text File Using Grep Command in Linux
Let's consider we have a text file that contains lots of text and in that text file there are some email IDs present, and we have to find the all email IDs present in that text file. So what we can do? How can we find all email IDs present in that text file?. One way to find all email IDs manually, but this is a very time-consuming and boring proce
3 min read
How to compress file in Linux | Compress Command
Linux, renowned for its powerful command-line utilities, provides users with various tools to streamline file management tasks. One such tool, the compress `command`, is specifically designed to compress individual files, reducing their size for efficient storage and transfer. In this comprehensive guide, we'll explore the ins and outs of the compr
5 min read
Use the Lines of a File as Arguments of a Linux Command
Handling multiple arguments for a command can be difficult, especially when there are a lot of parameters. One way to make this easier is to put the arguments in a text file and use each line of the file as an argument for the command. This can simplify the process and save time. For example, let's say you have a text file with a list of 100 client
6 min read
Article Tags :
three90RightbarBannerImg