Thursday 22 December 2011

NTFS support in Linux (RHEL / CENTOS)

NTFS file system is not supported in RHEL 5 or 6. How do you I enable NTFS support?

To enable NTFS support we need to do a couple of things.

First of all enable the EPEL repo. Click here to learn How to enable the EPEL repo.
Then install the package "ntfs-3g" using yum.

[root@localhost ~]# yum list ntfs-3g
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Available Packages
ntfs-3g.i686                                        2:2011.4.12-5.el6                                  epel
ntfs-3g.x86_64                                    2:2011.4.12-5.el6                                  epel


[root@localhost ~]# yum install ntfs-3g
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntfs-3g.x86_64 2:2011.4.12-5.el6 set to be updated
 --> Finished Dependency Resolution

Dependencies Resolved

==================================================================================
 Package                 Arch                   Version                              Repository            Size
==================================================================================
Installing:
 ntfs-3g                 x86_64                 2:2011.4.12-5.el6                    epel                 247 k

Transaction Summary
==================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 247 k
Installed size: 624 k
Is this ok [y/N]:y 
Downloading Packages:
ntfs-3g-2011.4.12-5.el6.x86_64.rpm                                                                             | 247 kB     00:02    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : 2:ntfs-3g-2011.4.12-5.el6.x86_64                                                                               1/1

Installed:
  ntfs-3g.x86_64 2:2011.4.12-5.el6                                                                                                   

Complete!


Mounting NTFS partition
First of all find out the ntfs partition using the disk management utility. Use palimpsest or fdisk or some other tools.

[root@localhost ~]# fdisk -cul

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003c727

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *                63     51199154     25599546    7  HPFS/NTFS
/dev/sda2         51200000   103628799     26214400   83  Linux
/dev/sda3       103628800   124600319     10485760   8e  Linux LVM
/dev/sda4       124600320   488396799   181898240    5  Extended
/dev/sda5       124604416   132993023       4194304   82  Linux swap / Solaris
/dev/sda6       132995072   143480831       5242880   82  Linux swap / Solaris

On listing my /dev/sda1 is the NTFS partition.

Now decide the mount point (location to mount the partition). Example say /ntfs directory.

[root@localhost ~]# mount -t ntfs /dev/sda1 /ntfs

Now list the active mountings that are currently in use.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G   16G  8.0G  66% /
tmpfs                 983M  112K  982M   1% /dev/shm
/dev/mapper/myvg-home                      9.8G  152M  9.2G   2% /home
/dev/sda1              25G  6.9G   18G  29% /ntfs

It says that the partition /dev/sda1 is mounted at /ntfs directory.
Ok. Now look at the mount point /ntfs to see the ntfs partition.

[root@localhost ~]# ls /ntfs
ADFS          CONFIG.SYS         IO.SYS        pagefile.sys       WINDOWS      AUTOEXEC.BAT    Documents and Settings     MSDOS.SYS        Program Files            wmpub       NTDETECT.COM  Program Files (x86)     System Volume Information        boot.ini      Intel                   ntldr        

Now everything seems to be good in working condition.

Unmounting

[root@localhost ~]# umount /ntfs
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G   16G  8.0G  66% /
tmpfs                 983M  112K  982M   1% /dev/shm
/dev/mapper/myvg-home                      9.8G  152M  9.2G   2% /home

Persistent mounting

The above mounting is a temporary mounting, ie it will remain mounted only upto the next system shutdown. Once the system boots the mounting is no more. This type of mounting is called persistent mounting.
For persistent mounting add an entry for the device into the /etc/fstab file system table file.
For mounting an NTFS partition set the file system type as "ntfs".

[root@localhost ~]# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Dec 13 19:08:24 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=20a51f87-11b8-4baf-afc1-8d136377e66c /                       ext4    defaults        1 1
/dev/mapper/myvg-home   /home                   ext4    defaults        1 2
UUID=8d0cc585-2af6-46f4-8d20-e4ee45ff2e7c swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sda2               /ntfs                   ntfs    defaults        0 0


save and quit.

Now activate the new /etc/fstab file by,

[root@localhost ~]# mount -a

Again list the active mountings that are currently in use.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G   16G  8.0G  66% /
tmpfs                 983M  112K  982M   1% /dev/shm
/dev/mapper/myvg-home                      9.8G  152M  9.2G   2% /home
/dev/sda1              25G  6.9G   18G  29% /ntfs

Now our mounting is persistent after system boots.

No comments:

Post a Comment

Navigation by WebRing.