Mount a Damaged NTFS Hard Drive on a CentOS Linux Computer
Mounting a NTFS hard drive in CentOS Linux is fairly easy. In my case the drive was damaged and wouldn’t mount properly in Windows however I was able to put it into a USB hard drive enclosure and mount it under CentOS to recover the data. If you are mounting the drive via a external USB enclosure this article may help.
Follow the directions below to mount a NTFS drive in CentOS Linux.
- Enable rpmforge Repo: If you don’t already have the rpmforge yum repository already then you need to install/enable it. First download the proper rpmforge repo RPM here. Use the below two commands below to download and install but obviously replacing the package name with the RPM package you downloaded.
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.$dist.rf.$arch.rpm rpm -Uhv rpmforge-release-0.3.6-1.$dist.rf.$arch.rpm
- Install Packages Via yum: You will need to install numerous packages include fuse, fuse-ntfs-3g, dkms, and dkms-fuse. As long as you have the standard kernel installed then kernel-devel will be downloaded and installed as a prerequisite of dkms.
yum install fuse fuse-ntfs-3g dkms dkms-fuse
- Update Kernel Package: Now issue the below command to update the kernel package via yum to make sure it matches the kernel-devel package that was installed in the previous step.
yum update kernel
- Reboot Server: Once all of the above packages are installed you will need to reboot the server. It is not often that this is required in Linux however when the kernel is modified you need to reboot to load the new kernel.
- Mount NTFS Drive: Now its time to actually attempt to mount the damaged USB drive. First make a directory in the /mnt directory to mount to using the below command.
Then attempt to mount the damaged drive using the below command.
mount /dev/sda2 /mnt/baddrive
In my case no switches were required however you may need to use the “-t” switch to specify type. If that is the case use “-t ntfs-3g” right after mount in the above command.
- Verify Drive is Mounted: Now verify the drive is mounted issuing the below command and you should see results similar to the below as well.
[root@hunter src]# df -kh Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 215G 6.3G 198G 4% / /dev/hda1 99M 24M 71M 26% /boot tmpfs 506M 0 506M 0% /dev/shm /dev/sda2 75G 64G 12G 86% /mnt/oldxp
Notice the /dev/sda2 drive which is the mounted drive.
If you run into issues there are a couple things to test out. One of the most common errors when attempting to mount an NTFS drive would be with fuse itself. If you have an issue with fuse you might see an error similar to the below.
Error: FATAL: Module fuse not found
Verify fuse is installed properly by issuing the below command and you should see a result similar to the below.
[root@hunter src]# modprobe -vl fuse /lib/modules/2.6.18-128.1.14.el5/extra/fuse.ko
If there is an issue with fuse you will see an error similar to the “Module fuse not found” above. Typically if the packages have been installed via yum and you are still getting this error then you have one of two issues. The first is you have not rebooted since installing a new kernel or kernel-devel package. The second is the kernel and the kernel-devel packages are installed with different versions. To resolve the first obviously just reboot. To resolve the second issue simply issue the “yum update kernel kernel-devel” command to update both the kernel and the kernel-devel to the latest versions.
There is also a chance you don’t have the standard kernel installed and if this is the case you need to make sure to install the development package that goes with that kernel.