Master Linux mount and umount with 15 practical examples
This guide walks through creating partitions, mounting devices and filesystems using the Linux mount command, exploring common scenarios such as mounting CD-ROMs, viewing current mounts, binding directories, remounting, mounting ISO images, and safely unmounting with options like lazy, force, and selective unmounting.
After creating partitions on a new disk with tools like fdisk or parted and formatting them with mkfs, you use the mount command to attach a filesystem to a directory and start using it.
1. Mount a CD-ROM
# mount -t iso9660 -o ro /dev/cdrom /mntThe -o ro option mounts the CD-ROM read‑only; ensure the target directory /mnt exists before mounting.
2. View all mounted filesystems
# mountRunning mount without arguments lists every currently mounted filesystem, as shown in the example output where a USB drive ( /dev/sdb) is mounted on /media/myusb.
3. Mount everything listed in /etc/fstab
# mount -aThe -a flag reads /etc/fstab and mounts all entries that are 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. Re‑issuing the command on an already‑mounted point yields an error indicating the device is busy.
5. List mounts of a particular filesystem type
# mount -l -t ext2
# mount -l -t ext4This filters the mount list to show only ext2 or ext4 filesystems.
6. Mount a floppy disk
# mount /dev/fd0 /mnt
# cd /mntAfter mounting, the floppy’s contents are accessible; unmount with umount /mnt before physically removing the disk.
7. Bind‑mount a directory to a new location
# mount -B /mydata /mntThe bind mount makes the same filesystem visible at /mnt. Changes made under either path are reflected in the other.
8. Move a mount point to a new directory
# mount -M /mydata /mnt/The -M option relocates the existing mount tree without unmounting the original point.
9. Mount without updating /etc/mtab
# mount -n /dev/sda6 /mydataUsing -n performs the mount but does not write an entry to /etc/mtab, so the mount is invisible to mount listings that read that file.
10. Mount read‑only or read/write
# mount /dev/sda6 /mydata -r # read‑only (same as -o ro)
# mount -t ext4 -o ro,noload /dev/sda6 /mydata # read‑only with no journal replayRead‑write is the default; use -w or omit -o rw for normal operation.
11. Remount an already mounted filesystem
# mount -o remount,rw /mydataThe remount option changes mount options (e.g., from read‑only to read‑write) without detaching the filesystem.
12. Mount an ISO image
# mount -t iso9660 -o loop pdf_collections.iso /mntThe ISO file is treated as a virtual CD‑ROM and its contents become accessible under /mnt.
13. Unmount multiple mount points at once
# umount /mydata /backupSpecify several targets in a single umount command.
14. Lazy unmount
# umount -l /mydataThe -l (lazy) flag detaches the filesystem immediately but delays cleanup until all references are closed.
15. Force unmount
# umount -f /mntIf a device is busy, -f forces the unmount; if that fails, a lazy unmount or identifying the holding process with ps or fuser can help.
Additional utilities such as df (to show disk usage), lsof, and fuser (to locate processes using a mount point) are mentioned throughout the examples.
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.
