Master Linux mount and umount with 15 practical examples
This guide walks through creating partitions, formatting them, and using the mount and umount commands on Linux, illustrating fifteen real‑world scenarios such as mounting CDs, viewing all mounts, binding directories, remounting, lazy unmounting, and troubleshooting busy filesystems.
After inserting a new hard disk, utilities like fdisk or parted create partitions, mkfs formats them (ext2/3/4), and mount attaches the filesystem to a directory.
1. Mount a CD-ROM
# mount -t iso9660 -o ro /dev/cdrom /mntThe -o ro option mounts the CD read‑only; ensure the target directory /mnt exists.
2. View all mounted filesystems
# mountRunning mount without arguments lists every active mount, e.g., a USB drive appears as /dev/sdb on /media/myusb type vfat (rw, ...).
3. Mount everything listed in /etc/fstab
# mount -aThe -a flag reads /etc/fstab and mounts each entry that is not already active.
4. Mount a specific entry from /etc/fstab
# mount /mydataIf the directory name is supplied, mount searches /etc/fstab for a matching device and mounts it.
5. List mounts of a particular filesystem type
# mount -l -t ext2
# mount -l -t ext4The -t option filters by type; the output shows the only ext2 and ext4 partitions on the system.
6. Mount a floppy disk
# mount /dev/fd0 /mnt
# cd /mntAfter mounting, the floppy’s contents are accessible; unmount with umount /mnt before removal.
7. Bind‑mount a directory
# mount -B /mydata /mntThis creates an additional mount point /mnt that mirrors /mydata. Verification:
# mount | grep /mydata
# mount | grep /mnt8. Move a mount point
# mount -M /mydata /mnt/The -M option relocates the existing mount tree to a new location without unmounting.
9. Mount without updating /etc/mtab
# mount -n /dev/sda6 /mydataThe -n flag performs the mount but does not record it in /etc/mtab, so the mount is invisible to mount listings.
10. Mount read‑only or read/write
# mount /dev/sda6 /mydata -r
# mount -t ext4 -o ro -o noload /dev/sda6 /mydataUse -r (or -o ro) for read‑only; add noload to prevent journal writes on ext3/4. Omit -r for the default read/write mode.
11. Remount an already mounted filesystem
# mount -o remount,rw /mydataThis changes a read‑only mount to read/write without unmounting.
12. Mount an ISO image
# mount -t iso9660 -o loop pdf_collections.iso /mntThe -o loop option treats the ISO file as a block device.
13. Unmount multiple mount points at once
# umount /mydata /backup14. Lazy unmount
# umount -l /mydataThe -l (lazy) flag detaches the filesystem immediately and completes the unmount after any pending I/O finishes.
15. Force unmount and troubleshoot busy mounts
# umount -f /mntIf a device is busy, umount -f forces the unmount. To identify the holding process, use:
# ps ajx | grep /mydata
# fuser -cu /mydataThese commands show the PID and owner, allowing you to stop the process before retrying the unmount.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
