LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1487|回复: 8

红旗4。1如何对ntfs格式的分区有写的权限。此外还有如何更改一个ntfs个时下的文件夹

[复制链接]
发表于 2004-12-15 11:16:55 | 显示全部楼层 |阅读模式
红旗4。1如何对ntfs格式的分区有写的权限。此外还有如何更改一个ntfs个时下的文件夹的可执行读写的属性
发表于 2004-12-16 20:38:52 | 显示全部楼层
好象不能读写吧,偶也是正在为这个犯愁
发表于 2004-12-16 21:09:05 | 显示全部楼层
内核中有对ntfs写的选项
不过编译后好像没有什么用
发表于 2004-12-16 21:44:49 | 显示全部楼层
目前为止,所有linux内核都无法实现ntfs安全写入。
2.6内核的那个“写入”选项不是普通的写入,请仔细阅读内核中的说明。
发表于 2004-12-25 19:16:46 | 显示全部楼层
redflag as4.1不是2.6内核的。
发表于 2004-12-26 08:12:59 | 显示全部楼层
2.6也不能寫入。
发表于 2004-12-27 14:11:23 | 显示全部楼层

How to write to NTFS in Linux-2.6

How to write to NTFS in Linux-2.6

Here are the steps to be done in order to transfer files from a Linux filesystem (JFS/XFS/Reiserfs/EXT3/whatever you prefer) to a Windows filesystem (NTFS).

Table of contents

How to write to NTFS in Linux-2.6
Create an image in Windows
Reboot to Linux
Testing NTFS write support
Compiling the NTFS driver
Writing
Reboot to Windows
Verify the filesystem
Open the archive
Other methods
Captive NTFS
Running Linux under Windows



Create an image in Windows

The NTFS support in Linux-2.6 is very limited (because Microsoft doesn't disclose the technical bits about how NTFS works). Specifically, it does not support these operations:
Creating/deleting files
Growing/shrinking files
It only allows writing over existing files.

For this reason, you have to use Windows to create an image you'll write over.


Say, you're going to copy 5 gigabytes of files to your NTFS partition. You must create a 5 gigabyte file to your NTFS partition, using your Widows. In Linux (or any unix system in general), you would do it with a

  dd if=/dev/zero bs=1m count=5000 of=file

command, but in Windows, it's not that simple.

You can create it in any way you want ? the contents of the file do not matter. If you can't think of anything, I recommend using WinRAR to compress a couple of anime episodes together.


When you have created the big file, rename it as something.tar.gz. Ensure the filename ends with .tar.gz (dot tee ay ar dot jee zed).


The file may be bigger than the source files together, but it must not be smaller.


Reboot to Linux

For some reason, the evil corporation has made it sure that it's approximately impossible to write a filesystem driver for Windows.
They don't want to support other systems. They want everyone to use Windows, Windows, Windows.

If your subject is an EXT2 / EXT3 filesystem, you can google for a shareware Windows program that lets you read those filesystems in Windows. For the other ones mentioned, there's no such choice.


So, ironically, in order to mount a JFS/XFS/Reiserfs/whatever filesystem to copy files to Windows, you must boot into Linux.


In order to boot into Linux, you need to have Linux installed somewhere. I won't cover Linux installation & starting in this document ? I'll just assume you have it somewhere. If you're lazy and lucky, a non-permanent Linux installation such as a "livecd" is probably enough.


Testing NTFS write support

Prerequirement for understanding the rest of this document: ability to use a terminal (xterm, aterm, gnome-terminal, console, whatever you prefer).

The tricky part is that your NTFS driver in Linux must have been compiled with WRITE SUPPORT -- otherwise it won't write anything.


Try mounting your NTFS partition (remember to be root!):

  mkdir /mnt/d
  mount /dev/hda5 -t ntfs /mnt/d -o rw

Replace /dev/hda5 with your partition location. If the mount command fails and you didn't type anything wrong, you don't have NTFS support at all. Do a modprobe ntfs and try again. If it still fails, you need to compile the NTFS driver. See below.

If the mount command worked without problem, next do this:

  grep /dev/hda5 /proc/mounts

If the line you get contains "rw,", you can skip the following chapter and read about how to write.
If the line contains "ro,", mount cheated you; there is no NTFS write support in your kernel. You need to rebuild the driver.
If the line doesn't contain either of those, you probably did something wrong or your /proc filesystem is not mounted or it is something that I can't diagnose within one sentence.

Compiling the NTFS driver

You need to get the kernel source and configure it. I don't detail the instructions on how to do that (because it's impossible for me to cover all different distributions and preferences).

Notes:

If you use NTFS as a module, you need to handle the same version of kernel source as is the kernel you're currently running (type uname -r to see it).
If you use a "livecd", you might experience great obstacles in attempting to affect its configuration.

When you're in the menuconfig (make menuconfig),

go to File systems -> DOS/FAT/NT Filesystems
ensure there's a M or a * in NTFS filesystem support
ensure there's a * in the NTFS write support
Then exit, exit, exit and answer Yes to the "do you want to save" question.
Recompile your kernel (you should know how) and install the modules.

If you compiled NTFS as a non-module, you need to reboot now.


After done, unload the old NTFS driver:

  rmmod ntfs

If it complains it's busy, unmount all NTFS mounts (umount -a -t ntfs) and try again.
Then load the new NTFS driver:
  modprobe ntfs

Now go back to the mounting test.

Writing

At this point:
you have verified that your kernel has NTFS write support
you have mounted the target filesystem
the target filesystem contains a file to copy over
Mount the source filesystem (or have it already mounted), and proceed:

For the sake of clarity, we'll use now these assumptions. Adjust the instructions in your mind if these are not exactly your cases:


The files we're copying are: /mnt/b1/anime/FMA/*.avi
The 5 GB file in NTFS filesystem we're writing into is: /mnt/d/Animet/FMA.tar.gz

Copypaste this to your shell prompt (don't care about the emphasis):


  cd
  cat > ntfs-filter.c <<EOF
  #define _LARGEFILE64_SOURCE /* allow unistd.h to introduce O_LARGEFILE */
  
  #include <unistd.h>
  #include <stdio.h>
  #include <fcntl.h>
  
  int main(int argc, const char*const *argv)
  {
      int fd = open(argv[1], O_RDWR | O_LARGEFILE); /* open the target  */
      if(fd < 0) { perror(argv[1]); return -1; }
      lseek(fd, 0, SEEK_SET);             /* position to beginning      */
                                          /* make it our stdout         */
      if(fd != STDOUT_FILENO) { dup2(fd, STDOUT_FILENO); close(fd); }
      execl("/bin/cat", "cat", NULL);     /* let /bin/cat do the rest   */
      perror("/bin/cat");                 /* if execl failed, report it */
      return -1;
  }
  EOF
  gcc -o ntfs-filter ntfs-filter.c
  cd /mnt/b1/anime/FMA
  tar cvfz - *.avi | ~/ntfs-filter /mnt/d/anime/FMA.rar

This should work. Did you get error messages? Sorry, I can't help you there. You'll have to resolve it yourself.

So what happened?

We wrote a program.
We compiled the program.
We created a .tar.gz archive and passed it to the program which wrote it into the NTFS file.

The program does something I couldn't figure out how to do otherwise: it opens the file without attempting to create it and sets the writing position to the file beginning.


Reboot to Windows

Now reboot to Windows.

Verify the filesystem

As the first thing, run a filesystem check on the NTFS filesystem. Ensure it's not broken.

Open the archive

After you have verified the filesystem, go and open the .tar.gz file (the one you created in the beginning of these instructions) with WinRAR or your favourite archiver program.
After you have decompressed it, you may safely delete it.

Other methods


Captive NTFS

There supposedly exists a NTFS driver for Linux which uses the Windows NTFS driver directly. I tried it once but I couldn't figure out how to get it working in Linux-2.6.
It should be able to use an NTFS volume without restrictions.

Running Linux under Windows

As crazy as this sounds, it's possible using the Cooperative Linux.

I won't cover colinux installation here, but I'll cover the steps to transfer files using this method:

Start colinux and mount your Linux filesystem (readonly if you wish).
If colinux doesn't allow mounting partitions, you can first create a partition image of the filesystem and mount the image under colinux.
Start a web server under colinux and create a website that links to those files.
Download the files using your Windows. It will be very fast because it all goes through a virtual network interface which has no speed limits.
This method requires no NTFS support in Linux. I have succesfully ran colinux, but I haven't tried mounting production filesystems with it.

Link:http://bisqwit.iki.fi/story/howto/ntfs/
发表于 2004-12-28 14:18:37 | 显示全部楼层
我用make menuconfig打开了读ntfs的模块,打算把它编译进内核,出错了。还不知道该咋办~
发表于 2005-5-14 23:20:11 | 显示全部楼层
所有的linux都不能写啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表