Mastering the Linux mount command: Secrets to managing storage devices
Discover the power of the mount and umount commands to professionally manage all your storage devices on Linux, from hard drives and ISO files to Samba network shares.
Linux's Unified File System Architecture
Unlike Windows, which uses separate letters like C: or D: for each drive, Unix-based operating systems like Linux and macOS manage everything in a single directory tree. When a storage device is connected, its file system is "mounted" to a directory on this shared directory tree, called a "mount point," making it part of the unified file system.
In many cases, this process occurs automatically. However, manual mounting via the command-line interface provides administrators with complete control, allowing customization of critical parameters such as mount point, read/write permissions, and many other advanced options. The commandsmount,umountandremountThis is the core set of tools for this task.
Basic operations with storage devices
To begin, checking the current state of the file systems is the first and most important step. Linux provides many tools to accomplish this efficiently.
List the active file systems.
The simplest way to see all mounted file systems is to use the commandmountNo options are included. However, the results returned can be very long and difficult to read.

To filter the results, you can use the option-t(type) to specify the file system type to display, for exampleext4ortmpfs.
mount -t ext4
Another useful tool is the command line.df(Disk free). To avoid displaying unnecessary virtual file systems (e.g., Snap applications' squashfs), use the option.-x(exclude).
df -x squashfs
This command provides an easy-to-read overview of the capacity, used space, free space, and mount points of each device.
Disconnect the device safely.
To unmount a file system, use the commandumount(Note that there is no 'n'). You need to provide the mount point or device name as a parameter.
sudo umount /mnt
If no error messages appear, it means the disconnection process was successful.
Handling specialized storage devices
The mount command isn't limited to physical drives. It can also handle virtual devices and network connections flexibly.
Mount and access ISO image files
You can access the contents of an ISO image file without burning it to a disc by mounting it as a regular file system. This requires the option.-o loopTo use a loop device, a file can be treated as a physical storage device.
sudo mount -t iso9660 -o loop TenFile.iso /mnt
After mounting, you can browse the files and folders inside the ISO image at the mount point./mntNote that ISO files are always mounted in read-only mode.

Connect to Samba network sharing
To integrate network shares from a Windows or Samba server into a Linux file system, you need to install the package.cifs-utilsThen, use the mount command with the file system type ascifs.
sudo apt-get install cifs-utils
The mount command will look like this, requesting information about the IP address, share name, mount point, and the file containing authentication credentials for security.
sudo mount -t cifs -o credentials=/path/to/creds,uid=1000,gid=1000 //SERVER_IP/ShareName /media/NAS
Creating and using virtual file systems
Linux allows you to create an empty file, format it with a file system (like ext4), and then mount that file as a virtual drive. This is a useful technique for testing or creating encrypted storage space.
First, create a file of the desired size using the command.dd:
dd if=/dev/zero of=./virtual_disk.img bs=1G count=1
Next, create the ext4 file system inside the image file you just created usingmkfs:
mkfs -t ext4 ./virtual_disk.img
Finally, attach it to a mounting point:
sudo mount ./virtual_disk.img /media/virtual
Advanced management techniques
In addition to basic operations, the mount command provides many advanced options that allow for more flexible system management.
Remount the file system with the new option (remount).
You can change the options of a mounted file system without having to unmount and remount it. This is commonly used to switch between read-only and read-write modes, and vice versa.
sudo mount -o remount,rw /mnt
The above command will remount the file system at/mntwith read-write access.
Use the 'lazy' option to safely disconnect.
When a file system is being used by a process, the commandumountIt will fail. To solve this problem, the option-l(Lazy) will instruct the system to automatically disconnect as soon as the device is no longer in use, instead of reporting an error immediately.
sudo umount -l /dev/sdb
Bind a point of attachment
The linking feature allows you to "duplicate" a mount point to another folder. This means the device's contents will be accessible from both locations, which is useful for creating shortcuts or rearranging folder structures without moving data.
sudo mount --bind /media/original_mount /home/user/shortcut_folder


