Is NTFS under linux able to save a linux file, with its chown and chmod settings?

6,520

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.

Share:
6,520

Related videos on Youtube

DrBeco
Author by

DrBeco

Computer Scientist, Cognitive Scientist, Philosophy of Mind, Painter, Poet, Biker and Judoka (that I remember) I just created a nice clone (fork actually) of the Urban Muller language, called BrainForce (now I can keep my job as professor and still uses the language to teach Turing Machines and nice properties). Still don't have a website for it, but I can mail you if you want. All source code available. Translate BF to C. The release is at your disposal here. Lots of options to generate different code for various situations. Blog Beco cc

Updated on September 18, 2022

Comments

  • DrBeco
    DrBeco over 1 year

    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.

  • DrBeco
    DrBeco about 13 years
    Thanks Keith, but just "you can use ntfs-3g" will actually not help too much. You say it is stable, so I can use it without concerns? That is good. One doubt down. But now: how to do it is the question! :) About the ext2 image file, I can't mount it under windows, so that is not possible. Also, I can't create a tarball under windows without installing software. The backup is not only from linux to HD, but also from windows to HD.
  • DrBeco
    DrBeco about 13 years
    @caleb I don't have the conditions to create tarballs under windows without installing some "tar" file. Remember, I'm not using only linux, but booting linux and windows, bringing the external USB HD with me, some places saving info, other places just using the info. I would use info also in computers that is not even mine, like for presentation, class teaching, etc. So, I need plain NTFS. Thanks
  • Keith
    Keith about 13 years
    @Drbeco hm, I use ntfs-3g and haven't had any problems with it (once I figured out the mappings file). I guess it's still not clear to me what you are trying to do. Do you also need Windows to access your Linux backup files?
  • DrBeco
    DrBeco about 13 years
    They are just files, I would not categorize them as being linux files or windows files. They are my projects, source codes (portable codes that compile and run in both SO), presentations, etc. So, yes, I need them to be available under both SO. Kind of trick, isn't it? What I don't know is how to enable linux to use correclty NTFS.
  • Andrew Lambert
    Andrew Lambert about 13 years
    I've used NTFS-3g extensively and under heavy load with zero problems. I've even been able to delete files which for one reason or another could not be deleted from within Windows.As for using an EXT2 image, you can access EXT2 filesystems from Windows using Ext2 IFS (warning: EXT2 and EXT3 only, not EXT4!).
  • DrBeco
    DrBeco about 13 years
    Dear @Keith, I see some hope here. My first simple test using only a text.txt file show user and permissions ok. I need to test it under other circustances. I'll keep you updated. The only problem is that the command mount -t ntfs-3g -o defaults,nls=utf8 /dev/sdc2 /home/carl/ntfs/ mount the partition as owned by root. Is that the case of just using another option? Maybe umask? or gid? Thanks for now!
  • Keith
    Keith about 13 years
    @Drbeco That is normal. Most files will be owned as Administrator/root on the NTFS file system. Only those in your User directory will yours. The gid, etc. are not used when a UserMapping is in use.
  • DrBeco
    DrBeco about 13 years
    @Keith, I've a problem creating UserMap. From the question: need to copy to/from linux/windows to this same HD. Although all machines and all SO's have carl as username, one windows has a code and other has another. How can I map 1:n? Do I need to create groups? Say file1.txt is SID-11 from machine capivara/windows, file2.txt is SID-22 from machine mico/virtualbox-WinXP, and file3.txt is SID-33 from a third machine. Can I make carl:carl:SID-11, carl:carl:SID-22 and carl:carl:SID-33. When I save one file to NTFS, how linux would know, based on carl which SID to use? :/
  • Falmarri
    Falmarri about 13 years
    I scanned through all this. But is there a reason you can't use Dropbox? You might end up having to duplicate the data across your hard drives. But it's the bets solution I've found.
  • Keith
    Keith about 13 years
    That's an equivalent problem you would have just using Windows in a non-AD (standalone workstation) environment. Each user is unique. You would have to provide a system with single sign on that provides the same user/SID globally. With AD, you would have carl/SID always the same in the domain, and ntfs-3g maps that one user/SID to your Linux account.
  • DrBeco
    DrBeco about 13 years
    +1. I'll keep trying and if you don't mind I'll keep you updated, as you are being really helpful with your tips. Anycase, I already closed the answer as accepted. Thanks a lot. @Keith