When deploying multilingual websites, data transfer services, or off-site backup platforms on Japan cloud servers, some users may need to use external USB hard drives or cloud drives for data expansion. By default, CentOS cannot directly write to these storage devices, which use the Windows NTFS file system. In practice, understanding how to permanently mount NTFS partitions in CentOS is crucial to ensure automatic boot recognition, stable read and write access, and strong compatibility.
Why can't CentOS directly write to NTFS?
As an enterprise-grade Linux distribution, CentOS doesn't have full NTFS write support by default, enabling only read-only access. NTFS is the default file system format for Windows platforms and requires additional driver support in non-Windows systems. This is especially true in server scenarios, where you can't simply rely on the graphical mounting methods of desktop Linux. Therefore, to achieve stable read and write access to NTFS partitions, you must use a third-party driver, such as ntfs-3g.
Step 1: Verify that the NTFS partition is recognized.
First, connect the NTFS-formatted disk or partition to the Japan cloud server (by mounting a cloud drive or mapping a USB device).
Run the following command to view currently connected devices and partitions:
lsblk
Or use:
fdisk -l
Find the NTFS partition device path, such as /dev/sdb1 or /dev/vdb1.
Step 2: Install the ntfs-3g driver
The default CentOS repository may not include ntfs-3g. You must first install the EPEL repository (Extra Packages for Enterprise Linux).
sudo yum install epel-release -y
Then install ntfs-3g:
sudo yum install ntfs-3g -y
After installation, the system will support reading and writing NTFS partitions.
Step 3: Manually mount the NTFS partition for testing
Create the mount directory:
sudo mkdir /mnt/ntfsdisk
Execute the mount command:
sudo mount -t ntfs-3g /dev/sdb1 /mnt/ntfsdisk
Enter the directory to test write permissions:
cd /mnt/ntfsdisk
touch testfile.txt
If the file is created, the mount was successful and the write permissions are correct.
Step 4: Configure automatic mounting at startup (permanent mounting)
To automatically mount the NTFS partition after each system reboot, edit the /etc/fstab file.
First, back up the original file:
sudo cp /etc/fstab /etc/fstab.bak
Edit the fstab file:
sudo vi /etc/fstab
Add the following line to the end of the file (assuming your partition is /dev/sdb1):
/dev/sdb1 /mnt/ntfsdisk ntfs-3g defaults 0 0
After saving and exiting, you can run the following command to verify the mount configuration:
sudo umount /mnt/ntfsdisk
sudo mount -a
If there are no errors, the settings are effective.
Step 5: Permission Adjustment and Security Recommendations
The server environment has strict permission requirements. The NTFS file system uses Windows-style ACLs by default and does not support commands like chown in Linux. Therefore, you can restrict permissions using the mount parameters:
/dev/sdb1 /mnt/ntfsdisk ntfs-3g defaults,uid=1000,gid=1000,umask=022 0 0
Where:
uid/gid specify the owner of the mounted directory.
umask=022 sets file permissions to 755, making the file readable and executable.
To prevent system boot failures due to cloud drive disconnection or NTFS partition corruption, it is recommended to add the nofail parameter to the mount configuration:
/dev/sdb1 /mnt/ntfsdisk ntfs-3g defaults,nofail,uid=1000,gid=1000,umask=022 0 0
Supplement: Common Mounting Troubleshooting Tips
The system cannot find /dev/sdb1 because you used lsblk to confirm the device's existence. Ensure the disk is properly mounted to the cloud server. If you experience write issues after mounting, immediately check whether ntfs-3g is installed. Verify that the mount parameters include read and write permissions. If booting is stuck due to errors in the fstab configuration, it's recommended to add the nofail parameter. After booting, enter single-user mode and remove the incorrect mount entry.
NTFS storage mounting issues are inevitable when deploying cloud servers in Japan. Whether backing up data or importing migrated content, mastering how to stably and permanently mount NTFS partitions in CentOS is crucial for improving operational efficiency.