Master Linux File System Mounting: From ISO Images to NFS and Auto‑Mount
This guide walks through Linux mounting techniques, covering manual mount syntax, mounting ISO images, USB drives, Windows shares via SMB, NFS shares, and configuring persistent and automatic mounts with /etc/fstab and autofs, complete with command examples and practical tips.
Introduction
The mount command attaches a block device, image file, or remote share to a directory in the Linux file system, making the directory a gateway to the underlying resource.
Manual mount syntax
General form:
mount [-t vfstype] [-o options] device mount_pointCommon options: -t vfstype – specify the file‑system type (e.g., iso9660, ntfs, vfat, nfs, smbfs). -o options – mount options such as loop, ro, rw, iocharset=cp936 (for Chinese characters). device – block device or image file. mount_point – existing directory that will become the mount point.
Mounting an ISO image
Create an ISO from a CD/DVD:
# cp /dev/cdrom /home/user/mydisk.iso
# dd if=/dev/cdrom of=/home/user/mydisk.isoCreate an ISO from a directory:
mkisofs -r -J -V mydisk -o /home/user/mydisk.iso /home/user/mydirMount the image:
mkdir -p /mnt/vcdrom
mount -o loop -t iso9660 /home/user/mydisk.iso /mnt/vcdromMounting a USB hard drive
Identify partitions (e.g., /dev/sdc1, /dev/sdc5) with fdisk -l or cat /proc/partitions. Then create mount points and mount:
mkdir -p /mnt/usbhd1 /mnt/usbhd2
mount -t ntfs /dev/sdc1 /mnt/usbhd1
mount -t vfat /dev/sdc5 /mnt/usbhd2If file names appear garbled, specify the character set:
mount -t ntfs -o iocharset=cp936 /dev/sdc1 /mnt/usbhd1
mount -t vfat -o iocharset=cp936 /dev/sdc5 /mnt/usbhd2Mounting a USB flash drive
mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usbMounting a Windows SMB/CIFS share
Install the Samba client package if it is not present, then mount the share:
mkdir -p /mnt/samba
mount -t smbfs -o username=administrator,password=pas123 //10.140.133.25/c$ /mnt/sambaMounting an NFS share
mkdir -p /mnt/nfs
mount -t nfs -o rw 10.140.133.10:/export/home/xiuxiu /mnt/nfsNFS server configuration
Solaris
share -F nfs -o rw /export/home/xiuxiu
/etc/init.d/nfs.server start
# Add additional shares as needed
share /export/home/xiuxiu1Linux (RHEL/RedHat style)
# /etc/exports
/export/home/xiuxiu 10.140.133.25(rw) *(rw) /export/home/xiuxiu1(rw) /export/home/xiuxiu2(rw)
# Start required services
/etc/rc.d/init.d/portmap start # RHEL default
/etc/rc.d/init.d/nfs start
# Apply changes
exportfs -rvMounting a CD‑ROM directly
mount /dev/cdrom /mnt/cdrom # access contents
umount /mnt/cdrom # safely ejectPersistent mounts with /etc/fstab
Obtain the device UUID: blkid Add a line to /etc/fstab using either the device name or the UUID, specifying the desired mount options. Example:
UUID=123e4567-e89b-12d3-a456-426614174000 /mnt/vcdrom iso9660 loop,ro 0 0Automatic mounting with autofs
Install and enable the service:
yum install -y autofs
systemctl start autofs.service
systemctl enable autofs.serviceCreate or edit rule files (e.g., /etc/auto.misc, /etc/auto.nfs) to map subdirectories to remote resources. Example rule for an NFS share:
public -fstype=nfs serverb.lab.example.com:/shares/publicReference the rule file from /etc/auto.master to watch a parent directory such as /mnt: /mnt /etc/auto.misc Restart the daemon to apply changes:
systemctl restart autofsExample: auto‑mounting a web directory
Configure a temporary HTTP virtual host (shown as a code snippet) and mount a CD‑ROM to the document root:
<VirtualHost 192.168.220.129:80>
DocumentRoot /public/test
ServerName 192.168.220.129
</VirtualHost>
mkdir -p /public/test
echo "this is a test" > /public/test/index.html
systemctl stop firewalld
setenforce 0
systemctl restart httpd
mount /dev/sr0 /public/test # temporary mountSafety reminder
When working with mounted network resources, avoid careless use of rm -rf and always unmount the resource after use to prevent accidental data loss.
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.
