How to Mount and Unmount Filesystems in Linux? (2024)

How to Mount and Unmount Filesystems in Linux? (1)

  • Trending Categories
  • Data Structure
  • Networking
  • RDBMS
  • Operating System
  • Java
  • MS Excel
  • iOS
  • HTML
  • CSS
  • Android
  • Python
  • C Programming
  • C++
  • C#
  • MongoDB
  • MySQL
  • Javascript
  • PHP
  • Physics
  • Chemistry
  • Biology
  • Mathematics
  • English
  • Economics
  • Psychology
  • Social Studies
  • Fashion Studies
  • Legal Studies
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary
  • Who is Who

LinuxOperating SystemOpen Source

';

Introduction

In Linux, everything (picture, binary file, text file, directory etc.) is treated as file. It is important to know how to organize and access files in a better way. Mount and umount commands are very handy in this case.

In this article, we will learn these two commands. In short, using mount command we can mount a file system into a directory and using umount command we can umount the same file system from that directory. These can be done for hard disk and USB drive also. We have remember that all mount and umount commands works in “sudo” or “root” user only.

List Down all Storage Devices

Before we learn about mount and umount command we need to list down all storage devices in Linnux system.

Command1

sudo fdisk -l

Output

[sudo] password for rian:Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisklabel type: dosDisk identifier: 0x0002d5a1Device Boot Start End Sectors Size Id Type/dev/sda1 * 2048 620969983 620967936 296.1G 83 Linux/dev/sda2 620972030 625141759 4169730 2G 5 Extended/dev/sda5 620972032 625141759 4169728 2G 82 Linux swap / SolarisPartition 2 does not start on physical sector boundary.

Command 2

$ lsblk

Output

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 298.1G 0 disk├─sda2 8:2 0 1K 0 part├─sda5 8:5 0 2G 0 part [SWAP]└─sda1 8:1 0 296.1G 0 part /

“mount “command to know all currently mounted file systems

If we just type “mount” command, we can get all information like what are the currently mounted file system.

Command

$ mount

Output

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,nosuid,relatime,size=985120k,nr_inodes=246280,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,noexec,relatime,size=202976k,mode=755)/dev/sda1 on / type ext4 (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)------Many lines-----cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13500)mqueue on /dev/mqueue type mqueue (rw,relatime)hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)………………………………………

We can also view the above information using below command also.

$ cat /proc/mounts

Now, let us understand only below line from all these output of “mount” command

/dev/sda1 on / type ext4

/dev/sda1 => This is file system name.

on / => This is called mount point. “/” means it’s mounted in root directory.

type ext4 => Here type of file system is ext4.

“mount -t” command to know specific file systems information

If we use –t option then we can get information on specific filesystem (Ex: ext4)

Command

mount -t ext4

Output

/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)

“mount” Command to mount a file system

This is very simple .We can use below two commands to mount any file system.

  • Create the mount point directory using “mkdir” command.

  • Mount the required filesystem.

mount -t Type Device <Directory name created in step1>

Here “Type” can be ext4 and “Device” can be /dev/sda1.

“umount” Command to unmount a file system

After mounting a filesystem we can umount the same filesystem using “umount” command.

Command

$ umount /dev/sda1

Or

$ umount <mount point directory>

After this command we are no longer see the files inside the last mounted mountpoint directory.

We can also use the same “umount” command to unmount multiple filesystem in same time.

Command

$ umount /dev/sda1 /dev/sda2

“umount -l” command to unmount a file system

“umount –l” command is used to unmount a filesystem when user is not sure if any read or write operation in going on the targeted filesystem. This is command waits for any ongoing operation to get finished and then do the unmount. This is also called as lazy unmount.

As per man page

-l, --lazy detach the filesystem now, clean up things later

Command

$ umount –l /dev/sda1

“umount -f” command to forcefully unmount a file system

“umount –f” is used to forcefully unmount a filesystem evenif there is ongoing read or write operation in that filesystem.

Command

$ umount -f /dev/sda1

This is used when a network share is not reachable.

Conclusion

From this article, we have gained knowledge on “mount” and “umount” commands with many arguments and understood the importance of these two commands. Now, depending on situation we can use these commands and do our job much faster way in Linux.

Bamdeb Ghosh

Updated on: 08-May-2023

4K+ Views

  • Related Articles
  • How to Mount and Unmount an ISO Image in Linux?
  • How to Mount_Unmount Local and Network (Samba _ NFS) Filesystems in Linux?
  • How to Mount NTFS Partition in Linux?
  • Cryptmount – A Utility to Create Encrypted Filesystems in Linux
  • How to mount usb drive in a linux system
  • How to Fix \"NTFS Partition Failed to Mount\" Error in Linux?
  • How to Mount Google Drive in Linux Using _Google Drive OCamlfuse_ Client?
  • How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH?
  • How to Mount Windows Partitions in Ubuntu?
  • How to mount the ISO file using PowerShell?
  • How to directly mount NFS share/volume in a container using Docker Compose v3?
  • How to find and kill running processes in linux
  • How to Import and Export MySQL Databases in Linux
  • How to Install and Configure OpenSSH Server In Linux?
  • How to Determine and Fix Boot Issues in Linux?
Kickstart Your Career

Get certified by completing the course

Get Started

How to Mount and Unmount Filesystems in Linux? (31)

Advertisem*nts

';

How to Mount and Unmount Filesystems in Linux? (2024)
Top Articles
Will I notice a difference going from 16 GB of RAM to 32?
Student Pilot Training and Limits
3 Tick Granite Osrs
Antisis City/Antisis City Gym
Golden Abyss - Chapter 5 - Lunar_Angel
Knoxville Tennessee White Pages
Lamb Funeral Home Obituaries Columbus Ga
Craigslist Campers Greenville Sc
Ghosted Imdb Parents Guide
Katmoie
Triumph Speed Twin 2025 e Speed Twin RS, nelle concessionarie da gennaio 2025 - News - Moto.it
50 Meowbahh Fun Facts: Net Worth, Age, Birthday, Face Reveal, YouTube Earnings, Girlfriend, Doxxed, Discord, Fanart, TikTok, Instagram, Etc
Devourer Of Gods Resprite
REVIEW - Empire of Sin
What to do if your rotary tiller won't start – Oleomac
Marion County Wv Tax Maps
Rainfall Map Oklahoma
Committees Of Correspondence | Encyclopedia.com
Tamilyogi Proxy
Morristown Daily Record Obituary
Tripadvisor Napa Restaurants
Masterkyngmash
Best Transmission Service Margate
Puretalkusa.com/Amac
Baja Boats For Sale On Craigslist
C&T Wok Menu - Morrisville, NC Restaurant
Pawn Shop Moline Il
Churchill Downs Racing Entries
Danielle Moodie-Mills Net Worth
Bursar.okstate.edu
Kempsville Recreation Center Pool Schedule
Utexas Baseball Schedule 2023
Wcostream Attack On Titan
Gas Prices In Henderson Kentucky
Teenage Jobs Hiring Immediately
Uhaul Park Merced
The Mad Merchant Wow
Go Smiles Herndon Reviews
Dr. John Mathews Jr., MD – Fairfax, VA | Internal Medicine on Doximity
Florida Lottery Claim Appointment
Santa Clara County prepares for possible ‘tripledemic,’ with mask mandates for health care settings next month
Ghareeb Nawaz Texas Menu
Nimbleaf Evolution
Strange World Showtimes Near Marcus La Crosse Cinema
Egg Inc Wiki
Craigslist Charles Town West Virginia
Minute Clinic Mooresville Nc
Research Tome Neltharus
Solving Quadratics All Methods Worksheet Answers
Bones And All Showtimes Near Emagine Canton
Hcs Smartfind
Predator revo radial owners
Latest Posts
Article information

Author: Jeremiah Abshire

Last Updated:

Views: 6099

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jeremiah Abshire

Birthday: 1993-09-14

Address: Apt. 425 92748 Jannie Centers, Port Nikitaville, VT 82110

Phone: +8096210939894

Job: Lead Healthcare Manager

Hobby: Watching movies, Watching movies, Knapping, LARPing, Coffee roasting, Lacemaking, Gaming

Introduction: My name is Jeremiah Abshire, I am a outstanding, kind, clever, hilarious, curious, hilarious, outstanding person who loves writing and wants to share my knowledge and understanding with you.