第1楼
让Linux挂载NTFS
Windows 2000/XP/2003操作系统的分区格式是NTFS。NTFS格式支持高达2TB的大硬盘,而且性能不会随着磁盘容量的增大而降低。但是,因为这个格式在Linux下不能直接使用,所以Linux用户不能充分利用NTFS格式的硬盘空间。
因为Linux没有将挂载NTFS格式这项功能编译到内核里面,所以用户必须重新编译内核。但是编译完成后,很难保证一定能够挂载NTFS分区。下面介绍怎样才能正确、可靠地把NTFS安装、编译和挂载到Linux之中。
安装
1.RPM
在Linux下安装软件一般使用RPM组件管理程序。首先使用下面的命令查询目前所使用的Linux的内核版本:
#uname -r
得到版本信息后,到http://Linux-ntfs.sourceforge.net/网站下载系统所需的kernel-ntfs-2.4.28-27.8.0.i686.rpm组件。下载完成就可以使用下面的命令安装该组件:
#rpm ivh kernel-ntfs-2.4.28-27.8.0.i686.rpm
2.光盘
首先以root身份登录Linux,将Linux的第二张安装盘放入光驱,找到/redhat/RPMS目录下的kernel-2.4.xx-x-i386.rpm(这里x代表数字)文件,输入下面的命令:
#rpm ivh kernel-2.4.xx-x.i386.rpm
编译
用户安装好NTFS软件包后,就来进行编译的工作。首先进入/usr/src/linux-2.4.xx-x/configs目录,直接选择kernel-2.4.xx-x.i686.config,将该文件复制到/usr/src/linux2.4.xx-x目录下。接着用文本编辑器打开,把“#CONFIG_NTFS_FS is not set”这一行改为“CONFIG_NTFS_FS=m”。
然后到/usr/src/linux-2.4.xx-3目录,输入下面的命令编译NTFS模块:
#make modules
编译完成后,到/usr/src/linux-2.4.xx-x/fs/ntf目录下找到一个ntfs.o文件,将其文件复制到 /lib/modules/2.4.xx-x/kernel/fs目录。最后回到/usr/src/linux-2.4.xx-3目录,输入如下命令即可:
#depmod
#modprobe ntfs
挂载NTFS
当安装和编译完成后,便可以自行在/mnt下建立一个目录当作挂载点。以笔者而言,挂载点设为windows1。然后使用“mount”命令挂载,示例如下:
#mount t ntfs /dev/hdc1 /mnt/windows1
当顺利将NTFS挂载起来后,便可以切换到所建立的挂载点目录下(例如切换到/mnt/windows1下),运行如下命令来查看NTFS分区下的文件:
#ls -l
在用RPM方式安装可以挂载NTFS分区的组件后,此时的Linux只能在所挂载的NTFS分区内读取和运行相关文件,而无法写入任何信息或存储任何文件到NTFS分区中。
此时,一般的用户无法使用NTFS分区内的东西,因为挂载的权限只有系统管理者root才拥有。在默认值上挂载后的分区,其拥有者(UID)和拥有群组(GID)都是root。如果想让一般的用户也能使用挂载后的文件,就必须重新设置。具体做法如下:
首先,root在运行“mount”命令前,须先考虑有几位用户将使用NTFS分区内的文件,例如abc用户需要使用,就可以输入下面的命令:
#mount /dev/hdc1 /mnt/windows1 t ntfs r o uid=abc
挂载完成后,可以看到windows1的拥有者已经变为abc。此时,abc这位用户便可以使用windows1目录下的任何文件了,从而实现了利用NTFS磁盘空间的目的。
红颜如月有园缺,君名逍遥莫想切
昨日总总心深重,他夜梦里现芳踪
2005-7-28 05:20 PM
moremore50
☆社区管理员☆
欢迎光临我的BLOG
积分 0
发贴 703
注册 2003-12-3
性别 男
来自 天上人间
状态 离线 第2楼
Instructions
Key
In the following instructions, the following notation is used:
NB - Note carefully
Commands or output
Which RPM
It is important to install exactly the same version of NTFS kernel module as the kernel you have installed. Below are some simple instructions to help you find the file you need.
A quick way to find the version is to use the whichrpm script. Save the file and run it. Then go to the install section.
chmod 700 whichrpm
./whichrpm
The script, above, just automates what we will do next. First we need to decide which release you have. Run this command:
cat /etc/redhat-release
and you will probably see one of the following responses:
Fedora Core release 1 (Yarrow)
Fedora Core release 2 (Tettnang)
Fedora Core release 3 (Heidelberg)
Fedora Core release 4 (Stentz)
Red Hat Linux release 9 (Shrike)
Red Hat Linux release 8.0 (Psyche)
Next find out your kernel version:
uname -r
You should see a response something like one of these:
2.4.18-3
2.4.18-17.7.x
2.4.22-1.2115.nptl
2.6.8-1.521
The version might also have one of the following suffixes:
smp
bigmem
hugemem
BOOT
NB If the result ends with smp then you have a multi-processor computer (you probably already knew that).
Next find out what sort of processor you have. This command will ask which kernel rpm was installed for you.
NB If your version number had a suffix, then use it here, e.g. replace kernel with kernel-smp, or kernel-bigmem.
rpm -q --queryformat "%{ARCH}/n" kernel
Most people will have an i686 processor (a recent Pentium computer). Other options are athlon, i586 or i386.
Next download the RPM. Follow the links for
* Fedora 4 (Stentz)
* Fedora 3 (Heidelberg)
* Fedora 2 (Tettnang)
* Fedora 1 (Yarrow)
* RedHat Enterprise 4 (Nahant)
* RedHat Enterprise 3 (Taroon)
* RedHat 9 (Shrike)
* RedHat 8.0 (Psyche)
* RedHat 7.3 (Valhalla)
When you have downloaded the RPM, we will continue with the installation instructions.
Install
You must be root for the rest of the commands. The examples will continue as if you downloaded kernel-ntfs-2.4.18-14.i686.rpm.
NB Newer NTFS RPMs have names like kernel-module-ntfs-2.6.8-1.541-2.1.17-0.fc.1.2.i586.rpm
Next install the rpm:
rpm -ihv kernel-ntfs-2.4.18-14.i686.rpm
Preparing... ############################### [100%]
1:kernel-ntfs ############################### [100%]
There should be no errors, just #'s. Note: newer NTFS RPMs will also print a message telling you if install succeeded. If something goes wrong see the Help Section.
This is the only command we actually needed, but we'll go on and test what we have done.
Next load the kernel module
/sbin/modprobe ntfs
There should be no output. If there are a lot of error messages see the Help Section.
The next command, dmesg prints the kernel logs. We search them for NTFS using grep.
dmesg | grep NTFS
NTFS driver v1.1.22 [Flags: R/O MODULE]
We can now check that the kernel really understands NTFS. The output may vary slightly, but you are looking for the entry ntfs.
cat /proc/filesystems
nodev rootfs
nodev bdev
nodev proc
nodev sockfs
nodev tmpfs
nodev shm
nodev pipefs
ext3
ext2
nodev ramfs
nodev devpts
ntfs
Mount
Mounting an NTFS Volume is covered in more detail in Section 4 of the FAQ.
First you need to know which device your NTFS Volume is on and you need to create a directory as a mount point.
/sbin/fdisk -l
The output might look like:
Disk /dev/hda: 64 heads, 63 sectors, 4465 cylinders
Units = cylinders of 4032 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 2125 4283968+ 07 NTFS/HPFS
/dev/hda2 2126 19851 35735616 0f Win95 Ext'd (LBA)
/dev/hda5 * 2126 4209 4201312+ 83 Linux
/dev/hda6 4210 4465 516064+ 82 Linux swap
mkdir /mnt/windows
mount /dev/hda1 /mnt/windows -t ntfs -r -o umask=0222
ls -l /mnt/windows
...
-r-xr--r-- 1 root root 9719 Aug 24 1996 ansi.sys
-r-xr--r-- 1 root root 15252 Aug 24 1996 attrib.exe
-r-xr--r-- 1 root root 28096 Aug 24 1996 chkdsk.exe
-r-xr--r-- 1 root root 5175 Aug 24 1996 choice.com
...
Hopefully everything is working for you now.
NB Now, please read the NTFS FAQ (Frequently Asked Questions), especially if you want to know:
* How to change the owner or permissions of the mounted partition
* How to have Linux mount the partition automatically at boot time
Uninstall
If you wish to remove the NTFS RPM, first list all the RPMs with ntfs in their name. You output might look something like this:
rpm -qa | grep -i ntfs
kernel-module-ntfs-2.6.9-1.667smp-2.1.20-0.fc.1.2
Then, cut and paste the name into the rpm erase command:
rpm -e kernel-module-ntfs-2.6.9-1.667smp-2.1.20-0.fc.1.2