Open Source

Update Red Hat Linux to read Microsoft's NTFS

See how to get and install the software module that can allow Linux to read NTFS partitions.

If you have a dual boot system with a version of Linux and Windows NT, 2000, or XP, there may be times you wish you could read an NTFS partition within Linux. If you use Red Hat, you might be disappointed to find that reading NTFS partitions is not native to the operating system. To overcome this limitation, the Linux NTFS project created an NTFS driver specifically for Linux Red Hat distributions. The project is working to create a Linux driver to give read/write access to NTFS file systems and to program NTFS file utilities. At the moment, the driver is read-only, so don't expect to be able to save files across platforms on an NTFS drive—yet.

You can download either a module or a package that works with Red Hat's Package manager program, rpm. Before installing the driver, you should read this article in its entirety. Obviously, if you don't have a partition installed with the NTFS file system, you won't be able to mount a file system and test the driver in Linux. I've given instructions for using both the shell commands and the GNOME graphical interface for Red Hat Linux Version 8.0. Note that, depending upon what flavor of Linux you have, the commands and the graphical tools may differ.

Can your installation already read NTFS?
As mentioned above, it's possible you already have an NTFS driver installed in your Linux version by default. If so, you may want to skip ahead to mounting the file system. To check whether your distribution can read NTFS, open a terminal and type the following at the shell prompt:
cat /proc/filesystems

The cat or concatenate command is a simple way to display files. The files in the /proc/ directory contain information about the Linux kernel. As the name implies, the kernel is the core of the operating system. Filesystems contains a record of the file systems that have been compiled into the kernel. You should see ntfs listed among the entries. If not, your kernel does not currently support this file system.

Tips for Linux beginners
  • If you're using a graphical interface such as GNOME, you can open a terminal window by clicking the menu bar's Red Hat icon, then clicking Accessories | Terminal. Or click Red Hat | Run Command, and type xterm.
  • Linux is case sensitive—so be sure to type the commands and filenames exactly as they appear.
  • After typing the commands, press [Enter] to run the send command.
  • If you receive an error message, recheck the spelling and the case of the command you typed. You may be able to modify commands by pressing the up arrow until a previously entered command appears, editing the line, and then pressing [Enter].

Downloading the package
To install or update the NTFS driver, download the latest version for your kernel from the Linux NTFS Project Web site. Before downloading the driver for installation or updating, jot down the following information, which you'll need to choose and install the correct driver:
  • Root password
  • OS version
  • Linux kernel version
  • Processor type

To display your OS version, at the terminal shell prompt type:
cat /etc/redhat-release

Note that redhat-release is a small file in the /etc directory that contains the program release number and code name. You'll see output similar to the following:
Red Hat Linux release 8.0 (Psyche)

Next find your kernel version by typing the command:
uname -r

where uname displays system information. The -r switch gives the release version. Output will resemble the following:

or, if you have a multi-processor system,

Next, to find out your processor type enter:
rpm -q —queryformat "%{ARCH}\n" kernel

Type kernel-smp, rather than kernel, if you have a multi-processor machine. Possible outputs are i686, i586, i386, and athlon. If you get no output, carefully check the spelling and make sure you use a double dash in front of queryformat, curly braces (not brackets) around ARCH, and a back slash (\) not a forward slash (/) before n. Figure A shows an example of terminal commands and output.

Figure A
Enter Linux shell commands to find out your system information.

Equipped with this system knowledge, you're ready to download the right package. On the Linux NTFS project's Red Hat page, select the correct rpm or module to download. For instance, I chose the rpm listed for the category single processor, kernel version 2.4.18-14, processor i686."

Installing the package
You can use either shell commands in a terminal window or the capabilities of your graphical interface to install the rpm. To install the package in a terminal, first log in as root by entering the command su (substitute user), and type your root password when prompted. Next, change to the directory in which you placed the downloaded .rpm file, if you're not there already. For example:
cd /home/MichaelJ

Next enter the following command, being careful to type U in uppercase. Substitute the name of your package file for the one given below:
rpm -Uhv kernel-ntfs-2.4.18-14.i686.rpm

rpm stands for the Red Hat Package Manager. The switches -U, h, and v tell the program to perform a package Update, to show the progress of the update with a series of hash marks (#), and to run in verbose mode, which reports all messages. You will see two lines of hash marks as rpm runs, first for preparing and then for installing the NTFS driver.

Installation in a graphical interface
If you're used to working in a graphical interface such as KDE or GNOME, it may be easier to use a file browser to display the directory in which you saved the download, and then double-click the downloaded rpm file. Red Hat's Package Manager will automatically install it for you (Figure B).

Figure B
In a graphical file browser, double-click the Package icon to automatically install the driver.

If you are not logged on in the Linux root account, a window will open, asking you to enter the root password. A series of message windows will follow.

Starting the NTFS driver
To start the driver, open a terminal window and log on as root, as explained above. Next, type the following at the shell prompt:
/sbin/modprobe ntfs

Here, modprobe simply loads kernel modules. If the command is successful, you won't receive a message, just a new shell prompt. To check the version of the package you just installed, type:
dmesg | grep NTFS

The output should be something like:
NTFS driver v1.1.22 (Flags: R/O MODULE)

To check whether Linux now recognizes NTFS, type:
cat /proc/filesystems

After scanning the output you should see ntfs listed as the last entry.

When things go wrong
If for some reason your installation fails and you need to uninstall the package, use the following shell command in a terminal window:
rpm -e kernel-ntfs

The -e switch means "erase." During testing, it seemed that after uninstalling the package, a second attempt to install kernel-ntfs resulted in the message "package already installed," yet the driver didn't function. If you experience a similar problem, you can force reinstallation with the shell command:
rpm -ihv —force kernel-ntfs-2.4.18-14.i686.rpm

For more information on using rpm, see the Red Hat 8.0 documentation or the documentation for your Linux distribution.

Mounting the NTFS volume
Now that you have the driver loaded, you'll want to mount an NTFS drive or partition and read it. First, find the partition or drive on which the NTFS file system is located. Use the fdisk command with the -l (list) command-line switch:
/sbin/fdisk -l

The result of the command for my dual boot system shows four partitions (the list below is truncated from what you would normally see):
/dev/hda1 ... FAT16
/dev/hda2 ... HPFS/NTFS
/dev/hda3 ... Linux
/dev/hda4 ... Linux swap

In a graphic interface, open the Red Hat Hardware Browser by clicking Red Hat | System Tools | Hardware Browser (you will be asked to log on as root). When it loads, click on Hard Drives. You'll see a listing similar to the one in Figure C.

Figure C
Use the Red Hat Hardware Browser to list your hard drive's partitions.

Note the device number on which the NTFS system is installed (in the above case, hda2). Next, create a subdirectory in /mnt to use as a mount point for the NTFS partition. Use the mkdir (make directory) command. I named my directory win2k, but you can use any name that makes sense to you:
mkdir /mnt/win2k

Now mount your device, substituting your subdirectory and partition names for the ones given below:
mount /dev/hda2 /mnt/win2k -t ntfs -r -o umask=0222

The switches work as follows: -t indicates the type of file system, -r is an instruction to mount the file system as read-only, and -o (option) umask=0222 turns off the file's write permissions, which you want to remove because the package only gives read capabilities. Now comes the fun part: List the NTFS directory to see if it worked. At the shell prompt, type:
ls -l /mnt/win2k

Or open your file browser in your graphical desktop, and navigate to the /mnt/win2k directory to view your files (see Figure D).

Figure D
Congratulations, you can now read your NTFS file system.

Mount other drives
You can use this procedure to mount drives other than NTFS. For instance, if you created a dual-boot system, you probably used a small FAT partition to hold the boot loaders of both systems. You can mount this partition by giving the -t (type) as vfat (it's not necessary to add the other options).

Another handy use of this command is to mount a partition for shared read/write access across all Linux and Windows platforms. For example, you could create a FAT partition and mount it in Linux. Now you'll be able to swap data files, such as graphics and Microsoft Office documents, between operating systems. When you mount the file, however, you'll want to modify the command. Since you can only use the mount command as root, in order to give your regular logon user permission to write to the directory, run the command as follows:
mount /dev/hda1 /mnt/share-data -o uid=yourid -o gid=yourgroup

Substitute the device name on which your FAT file system lives for hda1, your user name after uid, and your group name after gid.

Permanently mounting the file system
Finally, using the procedure above will not remount NTFS after your restart Linux. To automatically mount your ntfs file system, you'll need to modify the file fstab, which contains information about file systems used by the Linux operating system. In a terminal window, log on as root using the su command, start your favorite text editor (the following examples use PICO), and open the file /etc/fstab:
pico /etc/fstab

You'll see a listing similar to the one in Figure E. Reading from left to right, the columns indicate the device, its mount point, the file system, and any special options.

Figure E
Modify the file fstab in order to automatically mount your NTFS drive during boot-up.

Add the following line, using spaces between each column, and keeping all the information on one line:
/dev/hda2   /mnt/win2k   ntfs   auto,owner,users,ro   0 0

The list of options tells the operating system to mount the ntfs file system automatically at boot-up, allow the Windows 2000 directory's owner and group users to mount the file system, and to make the ntfs directory read-only. The two zero values tell Linux not to dump the file system information, and not to run a file system check (since it's not part of Linux). When you restart the computer, the ntfs file system should be automatically loaded. In a graphical interface, it will be indicated with a hard drive icon on your desktop. If you try to open the win2k directory and receive a message that you lack permissions to read this file, edit the fstab file again and add the following to the comma-separated list of options:

Replace yourid with your login user name. That option will give your login ownership of the file system rather than root, which created the mount point.

Editor's Picks

Free Newsletters, In your Inbox