Search code examples
linuxmountownership

Linux: simulating/masking user ownership upon mount of 'external' partitions?


This is my problem: I have a partition on my Ubuntu system, let's call it myhdrive, which is not automounted upon boot (so I use disk mounter applet, or Nautilus to mount it manually). When it is mounted, listing this partition looks like this in Ubuntu:

$ ls -la /media/myhdrive/
total 5743740
drwxr-xr-x  8 myusername myusername       4096 2011-07-21 08:19 .
drwxr-xr-x  4 root          root                4096 2011-07-21 04:13 ..
-rw-r--r--  1 myusername myusername      98520 2011-07-21 08:19 file1.txt
-rw-r--r--  1 myusername myusername       3463 2011-07-21 08:19 file2.txt

Now, let's say I shutdown the Ubuntu OS - and boot, let's say, OpenSUSE from a USB key on the same machine. The myhdrive partition will again not be automounted, and then I have to mount it manually (again from the file manager there). The thing is, when mounted under OpenSUSE, the same drive displays the following listing:

$ ls -la /media/myhdrive/
total 5743740
drwxr-xr-x  8 1000 1000       4096 2011-07-21 08:19 .
drwxr-xr-x  4    0    0       4096 2011-07-21 04:13 ..
-rw-r--r--  1 1000 1000      98520 2011-07-21 08:19 file1.txt
-rw-r--r--  1 1000 1000       3463 2011-07-21 08:19 file2.txt

Obviously, myusername has uid of 1000 in the Ubuntu system, and there it is recognized - while the same username is not present in the OpenSUSE system, and so the uid is not replaced with a filename.

The problem is, of course, that I cannot write to the myhdrive from OpenSUSE by default - I'd first have to chown the entire partition - and then, when I get back to the Ubuntu system, I'd have to chown it back again.

It's quite clear to me that this will not be possible using the GUI tools - but is there a method or a command line switch, such that I can "fake ownership": mount this partition in such a way, that the real uid of 1000 is interpreted as 'the currently logged-in user' in the USB-booted case (including that, when writes are made to the partition by 'the currently logged-in user', they are recorded under the uid of 1000)?

Thanks in advance for any answers,
Cheers!


Solution

  • No. Either keep the authdb files in sync, or use an external auth server.