Master Linux File Mounting: From ISO Images to NFS and AutoFS
This guide walks you through Linux file system mounting techniques—including manual mounts for ISO images, USB drives, Windows shares, and NFS—as well as permanent fstab entries and automated mounting with autofs, complete with command examples and configuration tips.
Hello everyone! In server usage, mounting is one of the most common operations, so this article introduces Linux file mounting.
Manual Mounting
The basic syntax is: mount [-t vfstype] [-o options] device dir Key options: -t vfstype: specify filesystem type (e.g., iso9660, msdos, vfat, ntfs). -o options: mounting options such as loop, ro, rw, iocharset. device: the device to mount. dir: the mount point.
Mounting an ISO Image
# cp /dev/cdrom /home/xiuxiu/mydisk.iso # or
# dd if=/dev/cdrom of=/home/xiuxiu/mydisk.isoCreate a mount point and mount the image:
mkdir /mnt/vcdrom mount -o loop -t iso9660 /home/xiuxiu/mydisk.iso /mnt/vcdromMounting a USB Hard Disk
Identify the device (e.g., /dev/sdc1, /dev/sdc5) and create mount points:
mkdir -p /mnt/usbhd1 # mkdir -p /mnt/usbhd2 mount -t ntfs /dev/sdc1 /mnt/usbhd1 # mount -t vfat /dev/sdc5 /mnt/usbhd2For Chinese filenames, use the charset option:
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 Share (SMB/CIFS)
Install the Samba package if needed, then create a mount point and mount:
mkdir -p /mnt/samba mount -t smbfs -o username=administrator,password=pas123 //10.140.133.25/c$ /mnt/sambaMounting a UNIX NFS Share
Create a mount point and mount the NFS export:
mkdir -p /mnt/nfs mount -t nfs -o rw 10.140.133.10:/export/home/xiuxiu /mnt/nfsSupplementary Notes
SMB (also known as CIFS) is a Microsoft protocol for file and printer sharing; Samba provides Unix implementations.
For Solaris NFS server configuration, add a share with share -F nfs -o rw /export/home/xiuxiu and start the service.
For Linux NFS server, edit /etc/exports and start portmap and nfs services.
Mounting Optical Discs
mount /dev/cdrom /mnt/cdrom umount /mnt/cdromPermanent Mounts (fstab)
Add entries to /etc/fstab using device names or UUIDs (obtainable via blkid).
Automatic Mounting with autofs
Install autofs: yum install autofs -y Start and enable the service:
systemctl start autofs.service
systemctl enable autofs.serviceConfigure rule files (e.g., /etc/auto.misc or custom /etc/auto.nfs) and the master map ( /etc/auto.master) to watch a parent directory and apply the rules.
After editing, restart the service: systemctl restart autofs Example NFS rule:
public -fstype=nfs serverb.lab.example.com:/shares/publicOnce configured, accessing the watched directory triggers automatic mounting.
Reminder: Use rm -rf with extreme caution on mounted shares and always unmount when finished to avoid 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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
