This is a problem I'm having when using Ubuntu: I have two computers that have Ubuntu installed on them (comp1 and comp2). I create a document with Ubuntu on comp1 and then copy the file onto a FAT formatted USB flash drive. Via the flash drive I paste the document onto comp2. The problem is that the file-permissions are never preserved during the transfer. I'm assuming because the FAT is not supporting the permissions.
Is there a solution to this? Should I continue to use FAT file system for USB flash drives (because FAT is best for flash drives) and just live with this permissions issue? Or is it recommended to reformat my flash drive with a more "Ubuntu Friendly" file system that will preserve the permissions?
ext4 is a journalling filesystem which means that if the device is unplugged prematurely it stands more of a chance of recovering the damaged filesystem. The journal part of the write contains information about what is about to be done and it gets cleared after the operation is completed. If it is found that there is an uncompleted journal on a device when it is mounted, the filesystem can be reverted to it's previous state thereby preserving its integrity.
While there is some extra overhead in terms of space involved in having a journalling filesystem on a USB stick, it's actually a good choice for most things.
Obviously, if you need a device that can also plug into any computer at any time then FAT would be the way to go. If you want a device that needs to be plugged into one Windows computer only occasionally, then it's possible to install ext2 device drivers in Windows that will allow it to read any and all ext(x) drives. Of course, since Windows doesn't know about Linux permissions and ownership these will not be handled as well.
You can try formatting your drive as UDF(Universal Disk Format). It is the format for use on CD's and DVD's. Most modern OSes will be able to read and write to it.
Right now, looking at my data on UDF formatted drive, Linux file permissions seem to be preserved. So far, it's worked for me.
Another good thing about UDF formatted drive is that it can store a single large file of up to 16 Exabyte(correct me if I'm wrong.), whereas Fat32 can only store a file of size 4GB or less and MAX partition size for FAT32 is only 2TB.
It works good on Win7 and 8. For older Windows OSes like XP and 2000, you can read from the drive but you have to install some sort of driver to write to it.
For Mac, OS X 10.5 and above has full compatibility. Here's a full compatibility chart. UDF Compatibility Chart
On Ubuntu, follow these steps to format a drive as UDF.
Okay, now you want to delete the current partitions in the target drive. You can either use a GUI tool like Disk Utility, or do the following.
Find your drive in the output. (they look something like /dev/sdb or /dev/sdc) Now do the following, but replace the 'x' in /dev/sdx to point to the drive that you want to clear its partition. Do this for both lines of code.
You could alter where it says 'DriveLabel' to your liking.
That should be it.
Actually, I do this slightly differently, but decided that this method was easier to follow. I referenced this method from this site.
I hope this helps someone out there.
When using a filesystem which preserves user IDs on a USB drive you may face problems caused by the fact that user IDs are assigned in the order user accounts are created, and the filesystem actually stores numeric IDs of file owners, not usernames. So if, say, machine A has
alice
andbob
accounts, and machine B hasbruce
,zoe
andalice
accounts then it likely that when Alice copies her files to an ext(2/3/4)-formatted USB drive, walks to machine B and tries to access the files she will discover that the files are all owned bybruce
and are read-only foralice
.Of course, if you only have one user on both machines then this won't be a problem.
Transferring files packed in a
tar
archive, as proposed by @FSMaxB may solve this problem because when you unpack an archive the files will be created owned by your user ID.If you use your flash drive only with linux systems, you may use one of the ext-filesystems e.g. ext4 but when using with other systems, FAT is the only compatible file system.
One way of using FAT and preserving permissions (not ownership) would be the usage of tar-Archives!
I'm using reiserfs for years on USB-Sticks without problems. Well - just that they aren't readable from windows systems which might not be bad, if they get lost.
If you partition a stick, to use parts with Windows for data exchange, make sure the windowspartition is the first one - else it won't be identified (at least for XP I made the experience).
You can build a fat-filesystem (aren't they pretty limited for todays stick sizes?) and add an big but empty file to it, and mount that file as a loop device in Ubuntu. Then you will be able to preserve your file permissions, and to increase or decrease the reserved space without partitioning or formatting.
As already mentioned: Tars, Zips and so on are another possibility.