OMP: Red Hat: A quick way to enable NTFS Support 一種讓紅帽子7.3能支持ntfs的快速方法 Red Hat: A quick way to enable NTFS Support (text only version) 文本版 Created: June 9, 2002 Modified: June 20, 2002 Author: Jim Hayward Author E-mail: [email protected] Copyright 2002, Jim Hayward. All Rights Reserved. Distro Specific: Red Hat Linux Relevant Links: http://www.redhat.com http://linux-ntfs.sourceforge.net Title: Red Hat: A quick way to enable NTFS Support Section: Distribution Specific Sub-Section: Red Hat Linux What is NTFS? 什麼是NTFS NTFS is the filesystem used by Windows NT, windows 2000, and Windows XP. NTFS是Windows NT, Windows 2000, 和 Windows XP所使用的文件系統 Why didn't Red Hat enable NTFS support in their kernels? 為什麼紅帽子不在其內核中直接支持NTFS? Editors note: Anton Altaparmakov, the ntfs maintainer, took offense to my stating that read only support can cause data corruption problems. You can read his e-mail to me here 編者按:安東 艾爾塔帕馬科夫,ntfs的維護人員,對我關於只讀支持能造成數據損壞問題的說法感 到憤怒。這裡你可以讀到他給我的妹兒。 My prior statement was not in any way meant to be offensive to him, so I have removed the passage he objected too. However, in the past even while using read only support the ntfs module has been known to cause filesystem corruption. Enabling write support for the ntfs module, WILL EAT YOUR DATA! 我先前的陳述沒以任何方式激怒他,所以我刪了他反對的一段。可是,在過去一段時間,ntfs模塊甚至 在使用只讀模式時也曾造成文件系統的崩潰。如果打開它的寫支持,將吃掉你的數據! Why is NTFS support poor under Linux? 為什麼NTFS在linux中支持得這麼差? Microsoft chooses not to release the information necessary to write a driver to Access the NTFS filesystem for operating systems other then Windows. This basically makes writing a driver a case of trial and error. 微軟不發布在windows以外的其他系統中支持ntfs的驅動程序所必需的信息。這是使為其寫的驅動容易造成 很多錯誤的最根本的原因。 This may lead you to ask the question, "Then why is Linux support for FAT and FAT32 filesystems any good?". The NTFS filesystem is a lot more complex then FAT and FAT32, thus making it harder to write a driver. 你可能因此問到:為什麼linux支持FAT和FAT32很好呢?NTFS文件系統比FAT和FAT32要復雜得多,所以使得給 它寫驅動要復雜得多。 Alternatives to using NTFS support 使用NTFS的替代方法。 Create an FAT32 (vfat) partition and store the data you need to access from Linux on it. 建立一個FAT32分區。把你需要從linux訪問的數據放在這個分區裡。 Is your system up to date? 你的系統是最新的了嗎? I am going to assume you have updated your Red Hat 7.3 install with all of the currently available updates. Kernel version 2.4.18-5 is the latest official kernel available for Red Hat 7.3 我打算假定你已經把你的紅帽子7.3升級到目前所能得到的最新的內核。目前最新的是2.4.18-5(譯者注: 不升級也完全可以這樣做,我在自己機器測試過了,而且目前最新版為2.4.18-10) Installing the kernel sources. 安裝內核源文件 First check and see what kernel you are running. You must use the kernel source for the same kernel you are running. 首先檢查看看你在用什麼內核在運行你的系統,你必須用和你的內核相同的源文件。 [jimh@garfield jimh]$ uname -r 2.4.18-5 Check to see if you already have the kernel source installed with: 檢查看看你的內核源文件的版本: [jimh@garfield jimh]$ rpm -q kernel-source-2.4.18-5 kernel-source-2.4.18-5 If you don't have the kernel-source installed you will see: 如果你沒裝內核原文件你將看到這樣的: [jimh@garfield jimh]$ rpm -q kernel-source-2.4.18-5 package kernel-source-2.4.18-5 is not installed If the kernel source is not installed, download the source from your favorite Red Hat mirror site. You will need to be logged in as root to install the kernel source. Install the kernel source with: 如果內核源文件沒裝,從Redhat的站點下載一個,你需要用root權限裝它。用如下命令: rpm -ivh kernel-source-2.4.18-5.i386.rpm If you are registered with The Red Hat Network you can also use up2date to install the kernel. This will download and then install the kernel-source for you. 如果你已經是redhat網的注冊用戶,你可以用up2date命令來安裝kernel,這樣的命令將下載並安裝kernel source up2date kernel-source Preparing the kernel source 准備內核源文件 Login as the root user. 以root用戶登錄 Change to the /usr/src/linux-2.4.18-5 Directory 換到/usr/src/linux-2.4.18-5目錄 [root@garfield root]# cd /usr/src/linux-2.4.18-5 "make mrproper" [root@garfield linux-2.4]# make mrproper "make xconfig" [root@garfield linux-2.4]# make xconfig Load the default Red Hat kernel config that was used to compile the kernel you have installed. 載入RedHat用於編譯你所安裝的內核的內核配置文件(作者這個是athlon速龍) [root@garfield linux-2.4]# rpm -q --qf '%{ARCH}\n' kernel-2.4.18-5 athlon Click "Load Configuration from file" 點擊"Load Configuration from file" Side note: Red Hat did not ship an i586 uniprocessor kernel with 7.3. If you have a uniprocessor i586 system the command above will probably return i386. Use the i386.config if it does. 旁記:RedHat沒發行7.3的i586 uniprocessor內核,如果你用了i586 uniprocessor上面的系統將返回i386.這種情況 下就用i386.config You can look in /usr/src/linux-2.4.18-5/configs to see what the default kernel configs Red Hat uses to compile their kernels. 你可以看看/usr/src/linux-2.4.18-5/configs來看看紅帽子都有哪些缺省的內核配置 [jimh@garfield jimh]$ ll /usr/src/linux-2.4.18-5/configs total 564 -rw-r--r-- 1 root root 39830 May 2 14:36 kernel-2.4.18-athlon.config -rw-r--r-- 1 root root 39858 May 2 14:36 kernel-2.4.18-athlon-smp.config -rw-r--r-- 1 root root 49146 May 2 14:36 kernel-2.4.18-i386-BOOT.config -rw-r--r-- 1 root root 40020 May 2 14:36 kernel-2.4.18-i386.config -rw-r--r-- 1 root root 39960 May 2 14:36 kernel-2.4.18-i386-smp.config -rw-r--r-- 1 root root 39957 May 2 14:36 kernel-2.4.18-i586.config -rw-r--r-- 1 root root 39897 May 2 14:36 kernel-2.4.18-i586-smp.config -rw-r--r-- 1 root root 40021 May 2 14:36 kernel-2.4.18-i686-bigmem.config -rw-r--r-- 1 root root 39968 May 2 14:36 kernel-2.4.18-i686.config -rw-r--r-- 1 root root 40414 May 2 14:36 kernel-2.4.18-i686-debug.config -rw-r--r-- 1 root root 39966 May 2 14:36 kernel-2.4.18-i686-smp.config -rw-r--r-- 1 root root 35944 May 2 14:36 kernel-2.4.18-i686-uml.config -rw-r--r-- 1 root root 40170 May 2 14:36 kernel-2.4.18-x86_64.config -rw-r--r-- 1 root root 40170 May 2 14:36 kernel-2.4.18-x86_64-smp.config In the dialog box type the full path to the config file you want to use. Example: /usr/src/linux-2.4.18-5/configs/kernel-2.4.18-i686.config 在對話框輸入你要用的全路徑文件名, 比如:/usr/src/linux-2.4.18-5/configs/kernel-2.4.18-i686.config Click "Ok" to load the config and exit the dialog box. 點"Ok"來載入配置並退出對話框。 Click "File Systems" Scroll down and find "NTFS filesystem support (read only)" 點"File Systems"然後找到"NTFS filesystem support (read only)" Click "m" to build NTFS support as a module. 點m來把NTFS支持編譯成一個模塊。 Click "Main Menu" 點"Main Menu" Click "Save & Exit" 點"Save & Exit" An informational dialog box will popup telling you to run "make dep" Click "Ok" 一個信息對話框將蹦出來,告訴你運行"make dep",點"Ok". Open the toplevel Makefile in a text editor. This would be /usr/src/linux-2.4.18-5/Makefile Look at the first four lines in the Makefile. 用文本編輯器打開最上層的Makefile。就是/usr/src/linux-2.4.18-5/Makefile VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 18 EXTRAVERSION = -5custom Remove the Word "custom" from the end of the EXTRAVERSION line. Save the changes and exit 可以看到如上內容,把EXTRAVERSION這行的"custom"刪掉「變成EXTRAVERSION = -5」。 "make dep" [root@garfield linux-2.4]# make dep Compile the the ntfs module. 編譯ntfs模塊。 "make modules SUBDIRS=fs/ntfs" [root@garfield linux-2.4]# make modules SUBDIRS=fs/ntfs Create a directory for the ntfs module 建立ntfs模塊的目錄。 mkdir /lib/modules/2.4.18-5/kernel/fs/ntfs Copy the ntfs.o module to the directory you just created. 把ntfs.o模塊拷貝到剛建立的目錄內。 cp /usr/src/linux-2.4.18-5/fs/ntfs/ntfs.o /lib/modules/2.4.18-5/kernel/fs/ntfs Set the permissions on the ntfs.o module to make sure they are correct. 加上訪問許可。 chmod 0644 /lib/modules/2.4.18-5/kernel/fs/ntfs/ntfs.o Update your modules.dep 更新你的modules.dep /sbin/depmod -a Thats it. You are now ready to use the new ntfs.o module. 結束了,你現在就可以用新的ntfs.o模塊了。 Accessing your NTFS partitions 訪問你的NTFS分區 You will have to create a mount point and add an entry to /etc/fstab for the NTFS partitions you want to access. 你應該建立一個安裝點(mount point, 其實就一目錄),並在/etc/fstab中加入一條記錄來訪問你要訪問的NTFS分區 There are many different options you can use to mount the partition depending upon your needs. 你可以按照自己的需要來決定你的訪問NTFS的選項。 If you have a single user system or don't need to give others access to the partition, you can use this. Replace "xxx" on uid and gid with your userid and group id. 如果你是單用戶系統並不需要給其他人訪問權限:你可以: /dev/hdc2 /mnt/windows ntfs noauto,user,uid=xxx,gid=xxx,umask=007 0 0 You can find out what your userid and groupid is with: 你可以用如下命令找到你的用戶id和組id $ cat /etc/passwd grep username username:x:500:500:realname:/home/username:/bin/bash If you were using the above user, the /etc/fstab entry would be: 如果你正在使用如上的用戶,那麼命令如下: /dev/hdc2 /mnt/windows ntfs noauto,user,uid=500,gid=500,umask=007 0 0 『以下沒什麼關系我就不翻譯了,我測試一下發現可以用iocharset=cp936選項,但 codepage=936不好使』 Description of the options above. noauto = Don't mount at boot user = Allow an ordinary user to mount, but only the user who mounted it can unmount the drive. uid = sets owner for the partition and the files on it. gid = sets group for the partition and the files on it. umask = sets the permissions on the partition. The above mount options will not be correct for all situations. This is just an example. For more information you should read the manpage for the "mount" command. This manpage explains the mount options available for the NTFS and other filesystems. -->Additional Information The Linux-NTFS Project http://linux-ntfs.sourceforge.net All software titles and services are copyrighted by their respective owners.