Web lists-archives.com

Re: File ownership problem using removeable media

On 12/23/18 4:51 AM, Richard Owlett wrote:
I use USB drives to transfer files between systems (sneakernet).
All systems have only one user(richard). It was created during installation.

The drives are either ext2 or ext4 formatted.
All files were in /user/richard on source machine

They _often_ [but not always] are seen as owned by 'root', not 'richard', by the destination system.

Why? I assume it is me in some manner.

What do I have to do to guarantee absolutely that any file/directory from /home/richard is seen by destination system as owned by 'richard'?

What should I have read?

I suggest reading "Design of the UNIX Operating System" by Maurice J. Bach:


Unix is written in C (mostly); so consider reading "C Programming Language", 2nd Edition, by Brian W. Kernighan and Dennis Ritchie:


Both of the above presume understanding of the basics of computer architecture, microprocessors, and assembly language. Wikipedia should have sufficient introductory articles. The Intel website has the hard-core information.

USB flash drives are usually factory formatted with FAT32, which tends to be the most convenient for sneakernet -- notably automatic user mounting. GUI desktop/ file manager integration. and multiple operating system support (Windows, macOS, Unix, etc.).

Understand that there are two kinds of regular files -- text and binary. (And, there are additional kinds of files.) Different operating systems have different concepts of text file encoding (ASCII, UniCode, EBCDIC, etc.) and text file end-of-line markers (CR, LF, CR-LF). Binary files tend to be OS- or application-specific. Moving a text file from one platform to another may required recoding and/or EOL translation (see
dos2unix(1), etc.).

Also understand that different operating systems have different concepts of file meta-data -- mode, ctime, mtime, atime, UID, GID, attributes, etc. -- and that moving files from a native file system to FAT32 and vice-versa involves imprecise and/or arbitrary meta-data translation. So, a file moved from, say, ext2 to FAT32 to ext4 should have identical contents, but may not have identical meta-data.

All that said, it is possible to format USB sneakernet drives with other file systems to achieve better meta-data copying accuracy, but this requires additional effort and you may lose multi-platform support. I would suggest NTFS if you want multi-platform support, or ext4 or btrfs for Linux-only.