CentOS Filesystem Usage Precautions
Before mounting a filesystem, ensure the target device (e.g., HDD, partition, USB) is properly connected and recognized by the system—use lsblk or fdisk -l to verify device existence. For network file systems (NFS), confirm network connectivity and server availability. Always back up critical data before performing partition operations (e.g., resizing, formatting) to prevent accidental loss.
Choose an empty directory as the mount point (commonly under /mnt or /media) to avoid conflicts with system-critical directories (e.g., /, /boot). Ensure the mount point has appropriate permissions—typically 755 (readable/executable by all, writable by root)—to prevent unauthorized access. Avoid using system directories as mount points to maintain system stability.
Confirm the filesystem type of the target partition (e.g., ext4, XFS, NTFS) using blkid or fdisk -l. CentOS defaults to supporting ext4 and XFS; for NTFS, install the ntfs-3g package (yum install ntfs-3g). Mismatched filesystem types will cause mount failures.
For automatic mounting at boot, edit the /etc/fstab file with a structured entry:
UUID=<partition-uuid> <mount-point> <filesystem-type> defaults,noatime 0 2.
Use blkid to obtain the partition’s UUID (more reliable than device names like /dev/sdb1, which can change). Validate /etc/fstab syntax with mount -a before rebooting to avoid boot errors.
Adjust mount options to balance performance and security:
noatime: Disables updating file access times, reducing unnecessary disk I/O (ideal for high-read environments).nodiratime: Disables directory access time updates (further improves performance).barrier=0: Disables write barriers (enhances write speed but risks data corruption if power fails—use only for non-critical data).ro: Mounts the filesystem in read-only mode (prevents accidental writes, suitable for external devices).mount -t ext4 -o noatime,nodiratime /dev/sdb1 /mnt/data.If SELinux is enabled (default in CentOS), it may block certain mount operations. Temporarily set SELINUX=permissive in /etc/selinux/config to test, or adjust boolean values (e.g., setsebool -P allow_mount_anyfile on) to allow specific mounts. For NFS shares, enable nfs_export_all_rw if required.
After mounting, use df -h to confirm the filesystem is mounted correctly (check size, used/free space, mount point). For persistent mounts, reboot the system and verify auto-mounting. If issues arise, check system logs (/var/log/messages or journalctl -xe) for error details.
Never force-unmount a filesystem (using umount -l) unless absolutely necessary. First, ensure no processes are using the mount point—use lsof /mnt/point or fuser -vm /mnt/point to identify and terminate active processes. Force-unmounting can cause data corruption.
fsck (e.g., fsck.ext4 -y /dev/sdb1) to repair errors. Never run fsck on a mounted filesystem—unmount it first or use a live CD.df -h to track space utilization. Use tools like du (e.g., du -sh /path/*) to identify large files/directories consuming excessive space.rsync, tar, or cloud services) to protect against data loss from hardware failure, malware, or user error.ext4/XFS—use for non-critical data.lvextend and resize2fs to expand logical volumes and filesystems.