Web lists-archives.com

Re: File ownership problem using removeable media




On 12/23/2018 03:06 PM, David Christensen wrote:
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:


https://www.pearson.com/us/higher-education/program/Bach-Design-of-the-UNIX-Operating-System/PGM81513.html

I'll check the local library to browse it's presentation. That reminded me I have a couple of Linux books. They didn't answer the questions I had a decade ago, but my background and questions have changed ;}


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


https://www.pearson.com/us/higher-education/program/Kernighan-C-Programming-Language-2nd-Edition/PGM54487.html

Somewhere I have a copy of the 1st or 2nd printing of that edition.


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.

My formal background is spotty. An introduction to computers in 61/62 using CORC/CUPL {Cornell's predecessor of Dartmouth's BASIC}. Later I had a semester of FORTRAN IV. My experience has been as been primarily as a user although employment had me programming in 8080 assembler and dBASEII.
I started exploring system questions when abandoning Windows for Squeeze.


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.

The only time I use FAT32 is transferring data to/from my old WinXP machine.


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.

I'm basically a Intel architecture Debian user now.
My internal drives (and majority of my flash drives) are ext4.

Thank you.



David