What is the difference between mount and umount in Linux?
Learn the difference between mount and umount in Linux, how mount points work, and why safely unmounting prevents data loss, with practical examples.
Expected Interview Answer
mount attaches a filesystem (on a disk, partition, USB drive, or network share) to a directory in the Linux tree so its contents become accessible, while umount detaches it, cleanly closing access to that filesystem.
Linux has one unified directory tree, so external and additional filesystems must be grafted onto it at a chosen directory called a mount point. mount makes the device's files appear under that directory; umount safely disconnects it, flushing any buffered writes to disk first. You cannot unmount a filesystem while it is busy — a process using it or a shell sitting inside it will block the operation until you free it.
- Attaches disks, partitions, and network shares into one tree
- Lets you choose exactly where a filesystem appears
- umount flushes buffers so no data is lost
- Supports many filesystem types through one interface
- Enables safe removal of external and removable media
AI Mentor Explanation
Think of adding a temporary practice net to the main ground: mounting bolts it onto a chosen spot so players can use it as part of the field, and unmounting unbolts and clears it away once practice ends. In Linux, mount bolts a filesystem onto a directory so its files are usable, and umount detaches it cleanly so the ground is safe to alter.
Step-by-Step Explanation
Step 1
Identify the device
Find the partition or share, e.g. /dev/sdb1, using lsblk or blkid.
Step 2
Choose a mount point
Pick or create an empty directory such as /mnt/usb to attach the filesystem.
Step 3
Run mount
mount /dev/sdb1 /mnt/usb makes the device's files appear under /mnt/usb.
Step 4
Use the filesystem
Read and write files under the mount point as part of the normal tree.
Step 5
Run umount
Ensure nothing is using it, then umount /mnt/usb to flush writes and detach safely.
What Interviewer Expects
- That mount attaches and umount detaches a filesystem
- Understanding of the mount point concept
- Awareness that umount flushes buffers to prevent data loss
- Knowledge that a busy filesystem cannot be unmounted
- Familiarity with /etc/fstab for persistent mounts
Common Mistakes
- Spelling it 'unmount' as the command (it is umount)
- Pulling a USB drive without unmounting, risking corruption
- Trying to umount while inside the mount point directory
- Mounting onto a non-empty directory and hiding its contents
- Forgetting to specify or create the mount point
Best Answer (HR Friendly)
“mount connects a storage device or share into Linux so you can open its files, and umount safely disconnects it. Unmounting first makes sure everything is written to disk, which is why you should always do it before removing a USB drive.”
Code Example
lsblk # find the device, e.g. /dev/sdb1
sudo mkdir -p /mnt/usb # create a mount point
sudo mount /dev/sdb1 /mnt/usb # attach the filesystem
ls /mnt/usb # its files are now visible
sudo umount /mnt/usb # flush writes and detach safely
# If it says 'target is busy':
sudo fuser -vm /mnt/usb # see which processes hold it openFollow-up Questions
- What is a mount point and can it be a non-empty directory?
- How do you make a mount persist across reboots?
- What does 'target is busy' mean when unmounting?
- What is the difference between umount and umount -l (lazy)?
- How does /etc/fstab relate to the mount command?
MCQ Practice
1. What does the mount command do?
mount attaches a filesystem to a mount-point directory so its contents become accessible in the tree.
2. Why should you umount a USB drive before removing it?
umount flushes any buffered writes to disk before detaching, preventing data loss or corruption.
3. What error commonly blocks an unmount?
If a process is using the filesystem or a shell is inside the mount point, umount reports the target is busy.
Flash Cards
What does mount do? — Attaches a filesystem (disk, partition, or share) to a directory so its files become accessible in the tree.
What does umount do? — Safely detaches a mounted filesystem, flushing buffered writes to disk first.
What is a mount point? — The directory where a filesystem is attached; its contents appear under that directory.
Why can't you always umount? — If a process is using the filesystem or you are inside the mount point, it is busy and won't detach until freed.
Continue Learning
Related Interview Questions
How does the Linux filesystem hierarchy work with directories like /bin, /etc, /var?
easy
What is the difference between a hard link and a symbolic link in Linux?
medium
What is the difference between absolute and relative paths in Linux?
easy
What is the Linux inode and what information does it store?
medium