Linux – Can NTFS Save Linux File with chown and chmod Settings?

backupchmodlinuxntfs-3gpermissions

I'm having some doubts about how to install and allow Linux to correctly read/write to a NTFS formatted harddrive used as backup of various machines (windows included, that's how I need NTFS).

For now, I've read some pages and I have the feeling I need someone else's guidance from who already did this step-by-step, to not ruin things here.

What I need is to be able to save a Linux file, with its chown and chmod settings, to a NTFS filesystem, and be able to retrieve this information back.

What I have today is a NTFS that saves all files with the owner:group of who mounted the volume, and permissions rwxrwxrwx for all.

I read this article but it is too much information and I could not understand some things when trying to actually implement:

  • Is it stable in the current version?
  • Does Ubuntu 10.04 have all things needed already? Or do I need to install anything?
  • What is the relation of POSIX ACL to this? Do I need install anything regarding this or just ntfs-3g will do?
  • Where are Ubuntu packages to run with apt-get?
  • If I map the users (with usermap) can bring the harddrive to another computer with different users, will I be able to read them? (Under Linux/Windows)?

For one thing I noticed, usermap was not ready to use. So I downloaded and compiled (but not installed because I was afraid to mess up things here), the latest version of ntfs-3g. In the README file it says:

> TESTING WITHOUT INSTALLING
> 
> Newer versions of ntfs-3g can be
> tested without installing anything and
> without disturbing an existing
> installation. Just configure and make
> as shown previously. This will create
> the scripts ntfs-3g and lowntfs-3g in
> the src directory, which you may
> activate for testing :
> 
>         ./configure
>         make
> 
>   then, as root :
>         src/ntfs-3g [-o mount-options] /dev/sda1 /mnt/windows
> 
>   And, to end the test, unmount the
> usual way :
>         umount /dev/sda1

But it tells nothing about the mount-options that I need to use to have full backups (full == backing up / restoring files, owners, groups and permissions).

This faq says:

Why have chmod and chown no effect?

By default files on NTFS are owned by root with full access to everyone.
To get standard per-file protection you should mount with the "permissions"
option. Moreover, if you want the permissions to be interoperable with a
specific Windows configuration, you have to map the users.

Also, I did used the ntfs-3g.usermap /dev/sdb2 tools to create the map file and got this result:

# Generated by usermap for Linux, v 1.1.4
:carl:S-1-5-21-889330461-3416208041-4118870141-511
:default:S-1-5-21-2592120051-4195220491-4132615201-511
carl:carl:S-1-5-21-889330462-3416208046-4118870148-1000

Now this default was mapped because I wrote "default" to one file that was under the default user during the inquiring. I'm not sure if I did that right. I don't care for any users but carl (and root for that matter), and for any other groups but users. I saw the FAQ telling me to answer the group with the username. Isn't it the case to tell the group as "users"? And how can I check, booting Windows, if this mapping is correct?

Summary:

  1. I need rsync to save Linux files and Windows files from various computers, to a NTFS external USB HD, without losing file permissions.
  2. I don't know how to install and run the driver ntfs-3g to allow chown, chmod and anything else that is needed to make that possible. What options, and where?
  3. All computers have carl username, but that doesn't guarantee that their SID, UID or GID are the same.
  4. The environment is composed of 18 "documents" folders, 6 of them Linux, 6 of them Win7, 6 of them virtualbox Win XP. All of them will be a single "documents" folder into the NTFS external hard drive.

Reference:

  • I also read this forum, and maybe it is useful to someone trying to help me here.
  • Also thought of these other three solutions, making the filesystem ext. But the external HD may be used in Windows boxes; I could not install or have write to install drivers, so it needs to be readable easily by any Windows and NTFS is the standard.

All my Google searches was too much technical to follow.

Best Answer

You can use ntfs-3g, but make sure you place the mappings file in the right place. Once you do that you should see file ownerships in ../User/name match the unix user.

However, if you just want to use it as backup you should probably just save a big tarball onto the ntfs location. If you also want random access you can place an ext2 image file and loop mount it. That will save you from a lot of these headaches.

Ok, assuming you will mount NTFS under /ntfs

run ntfs-3g.usermap /dev/sdb1 (or whatever your ntfs partition is). Answer the questions. Then mkdir /ntfs/.NTFS-3G. Then cp UserMapping /ntfs/.NTFS-3G/UserMapping. Now put an entry in /etc/fstab:

/dev/sdb1 /ntfs ntfs-3g defaults 0 0

Then mount /ntfs. The command ls -l /ntfs/Users/Carl should show your Linux user as the owner of files there.

Related Question