Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sharing a home directory but not its config files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Varuna
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jun 2004
Posts: 97
Location: Connecticut, United States

PostPosted: Mon Mar 13, 2006 4:16 am    Post subject: sharing a home directory but not its config files Reply with quote

I have several gentoo installations on the same computer and need access to my work, music, movies, etc. from any of them. However, the installations are otherwise very different, and my user needs separate config files for each. So I'd like my user's config files on each installation kept on its respective root filesystem but have everything else in my /home on a common shared partition. The trick is to get file modifications and new files saved to the right partition: basically, anything matching the regex "/home/varuna/\." going to the system partition and everything else to the shared one.

Mounting the shared partition on a subdir of ~ would work but adds an extra level to the hierarchy to click/cd through every time, and other static setups like simple symlinking couldn't deal transparently with new files/dirs being created in the "root" of ~. Unionfs would work except that, so far as I can tell, it can't write to two underlying filesystems at the same time.

Security isn't a major concern - there aren't any other users - and convenience is. Any ideas?
Back to top
View user's profile Send private message
ayqazi
Apprentice
Apprentice


Joined: 10 Apr 2005
Posts: 164

PostPosted: Mon Mar 13, 2006 6:49 am    Post subject: Reply with quote

mount --bind? Read the mount manual page for more:

mount(8):
       Since Linux 2.4.0 it is possible to remount part  of  the  file  hierarchy
       somewhere else. The call is
              mount --bind olddir newdir
       After  this  call  the same contents is accessible in two places.  One can
       also remount a single file (on a single file).

       This call attaches only (part of) a single filesystem, not  possible  sub-
       mounts. The entire file hierarchy including submounts is attached a second
       place using
              mount --rbind olddir newdir

       Note that the filesystem mount options will remain the same  as  those  on
       the  original  mount point, and cannot be changed by passing the -o option
       along with --bind/--rbind.


This allows you to mirror a directory tree at a mount point. You could mount --bind all the directories you want to have shared between the two partitions.

A way to do this automatically would be to possibly use fam (that is used by GNOME file manager to detect filesystem changes, I think.) I'm not sure about how to do this, but I'm sure its possible to write an app/script that uses fam to detect when a directory is in one location, but not in another, and then create the directory and mount --bind to it.

I know it isn't much, but hope that gives you some ideas,
Asfand Yar
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Mon Mar 13, 2006 6:55 am    Post subject: Reply with quote

What speaks against a /data mountpoint? Besides that you are too lazy to change the default directory of filemanager startup?
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
Varuna
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jun 2004
Posts: 97
Location: Connecticut, United States

PostPosted: Tue Mar 14, 2006 5:42 am    Post subject: Reply with quote

ayqazi wrote:
This allows you to mirror a directory tree at a mount point. You could mount --bind all the directories you want to have shared between the two partitions.

A way to do this automatically would be to possibly use fam (that is used by GNOME file manager to detect filesystem changes, I think.) I'm not sure about how to do this, but I'm sure its possible to write an app/script that uses fam to detect when a directory is in one location, but not in another, and then create the directory and mount --bind to it.

I know it isn't much, but hope that gives you some ideas,
Asfand Yar
Hmm... so sounds like you mean to mount the shared partition at /mnt/shared, then bind-mount all the directories DIR in /mnt/shared to /home/varuna/DIR... that part sounds good! :) However, if I later create a new empty non-hidden directory (or file) /home/varuna/NEW -- so on the root partition -- the idea is to have Inotify/gamin/fam create an empty directory /mnt/shared/NEW and bind-mount it to /home/varuna/NEW so that any data gets written to there -- the shared partition -- instead? What would happen if, say, a non-empty directory were copied from somewhere to the "home root" /home/varuna? How would you make sure that the new dir is mounted-over before the first of its contents is copied in? Is that how copying even works: create an empty dir, then copy in its contents and recurse? Would instead syncing /mnt/shared with /home/varuna at leisure by copying to the latter, then deleting the former and replacing it with a bind-mount of the latter be any more practical? What would happen if one of the bind-mounted dirs in /home/varuna was moved: would it just fail? At least a crash by the monitoring program shouldn't cause data-loss. These mounts seem kinda like cross-filesystem hardlinks.

OTOH, reversing this so that new files "default" to creation on the shared dir... i.e. mount the shared filesystem at /home/varuna and bind-mount the root fs's /home/varuna at /mnt/config, then sync /home/varuna/\..* to /mnt/config and use Inotify to sync /mnt/config to /home/varuna/\..* thereafter... might be a performance problem, copying files between partitions like that all the time? Both approaches seem a bit complicated or frail, but they are a better starting point than I had before; thanks for the ideas!

fangorn wrote:
What speaks against a /data mountpoint? Besides that you are too lazy to change the default directory of filemanager startup?
For better or for worse, more programs than just filemanagers use ~ as a default directory, and going through 2000+ packages over several independent installations, making changes where possible and attempting workarounds elsewhere, and repeating for each new installation, is unappealing enough to look for another solution. It is also partially the aesthetic sensibility (though not quite elegance) of being able to put your files where they should be in this rather ordinary setup. And since I don't have the lifetime of the Onodrim, I might as well spend that which I do have learning and exploring and doing quantum field theory while the computer does the monotonous stuff. :)
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Tue Mar 14, 2006 9:33 am    Post subject: Reply with quote

Thats why I do linux 2 years exclusive. Got bored booting every 2 weeks to restore windows from image :twisted: :wink:

Besides it is nice to invest 5 minutes in a script that keeps the computer busy for 2 weeks and do other things in this time 8)


but back on track:

I do not know of many programs which do not save the default location once you set it for one time. OK, dont use much gui apps :twisted: just a little OOo, firefox, ...

But the nice thing is, all the setting should go in ~, so you dont have to do it for more than one installation. And as I keep ~ when I change computer (why should I do all the settings again :wink: ), you will mostly do this settings once and for all (unless you use software which changes its settings format with every release :twisted: )
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
Varuna
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jun 2004
Posts: 97
Location: Connecticut, United States

PostPosted: Tue Mar 14, 2006 6:00 pm    Post subject: Reply with quote

fangorn wrote:
Thats why I do linux 2 years exclusive. Got bored booting every 2 weeks to restore windows from image :twisted: :wink:

Besides it is nice to invest 5 minutes in a script that keeps the computer busy for 2 weeks and do other things in this time 8)


but back on track:

I do not know of many programs which do not save the default location once you set it for one time. OK, dont use much gui apps :twisted: just a little OOo, firefox, ...

But the nice thing is, all the setting should go in ~, so you dont have to do it for more than one installation. And as I keep ~ when I change computer (why should I do all the settings again :wink: ), you will mostly do this settings once and for all (unless you use software which changes its settings format with every release :twisted: )


Yes, many of the settings are the same between installations, and I do just copy them over and all is good in the world. :) However, different installations have different keywords -> different package versions -> conflicting config files in some cases. Even with the same package, I sometimes want its configuration to be different in different installations. For instance, some apps get different settings when running in a different window manager/desktop environment, possibly even at a different resolution. And I try different configs to see which ones I like best... and I redo configs for some programs from scratch every couple of months on average (not all at the same time!), to "reset"/clean them, removing accumulated combinations and recreating the ones I liked while trying the new possibilities that creep in with new releases and new personal preferences. That is why I choose to have this multiplicity: some are backup snapshots of others, but others are intentionally quite different! So I do both, sharing settings and individualizing new ones.

Quite a few gui apps do need home directory location changes, and it seems that some will put their configs at the default location in addition to opening dialogs there... many others just open to the last directory that you used, which is nice except when you want a different one and going back to the top of the hierarchy needs an extra level each time, from ~ to ~/shared-stuff. But regardless, these and other problems seem like symptoms rather than causes, so I will at least try to deal with the problem before using up my supply of band-aids. :)
Back to top
View user's profile Send private message
scoon
l33t
l33t


Joined: 23 Aug 2003
Posts: 747
Location: Philadelphia, PA

PostPosted: Wed Mar 15, 2006 9:25 am    Post subject: Reply with quote

Hey there,

You may consider checking out CVS.

-scoon
_________________
Hope this helps........
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum