LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-03-2012, 02:27 AM   #1
rpowell
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
Maintaining symbolic links


Hi,

I have the following:

/media/disk1/myPictures
/media/disk2/myPictures

What I want to do is to have a folder in my home dir with the contents of both folders sym-linked out to disk

i.e:

ln -s /media/disk1/myPictures/* /home/ryan/myPictures
ln -s /media/disk2/myPictures/* /home/ryan/myPictures


However is there a tool like rsync but for maintaing symbolic links. As in if the contents of the disks change, the symbolic links also change?

That or perhaps a better setup

Thanks,
Ryan
 
Old 02-03-2012, 02:38 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 192Reputation: 192
Manually create a fstab entry for the drives. Using the UUID rather than device name, so the right filesystem gets mounted to the right point (/home/ryan/myPictures).

Im not sure on mounting two filesystems to the same mount point though. I think that will break.
 
Old 02-03-2012, 02:56 AM   #3
rpowell
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fukawi1 View Post
Manually create a fstab entry for the drives. Using the UUID rather than device name, so the right filesystem gets mounted to the right point (/home/ryan/myPictures).

Im not sure on mounting two filesystems to the same mount point though. I think that will break.
but the problem is that /home/ryan/myPictures will contain the contents of multiple folders (fstab wont fix this as my / disk isn't big enough to hold the contents of these disks)

Is there a program to maintain symlinks? Otherwise a crontab & repetitively removing all symlinks and re-establishing them is the only way I know how to
 
Old 02-03-2012, 03:27 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
What are these disks? Thumbdrives? Memory cards? In other words, drives that you will plug in to access? Or are they almost always plugged-in/mounted?

EDIT:
If they are removable, you might consider creating some udev rules. In a nutshell, a udev rule would allow you to launch an executable whenever a specific device is connected or removed. The idea would be that you run a script that creates symlinks when the device is connected, and then remove symlinks when the device is removed.

If they are always mounted... not sure if there's an easy solution. I know there has to be one or more filesystem-monitoring daemons out there. I say that because inotify exists. Unfortunately, I don't know the name of any of them. Though, such a daemon should be able to trigger a script/program whenever specific changes are detected.

EDIT2:
I found this page:
nixCraft: How To Track Changes in Your Linux Filesystem

It references a filesystem monitoring daemon. Two of the replies also refer to filesystem monitoring tools as well. Perhaps you could use one of them to help you write a script or something to add/modify/delete symbolic links in your "merged" pictures directory.

Last edited by Dark_Helmet; 02-03-2012 at 03:58 AM.
 
Old 02-03-2012, 11:16 AM   #5
Shiba
LQ Newbie
 
Registered: Feb 2012
Distribution: Ubuntu
Posts: 2

Rep: Reputation: Disabled
I suggest that you create a symbolic link to the mount points, rather than the individual files:

ln -s /media/disk1/myPictures /home/ryan/myPictures/disk1
ln -s /media/disk2/myPictures /home/ryan/myPictures/disk2

However, the more modern distros will make the disks easily available from the GUI file browser. I suggest just using that instead of trying to maintain such symlinks.
 
Old 02-03-2012, 11:45 AM   #6
rpowell
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks guys for the replies. I will look into the above three suggestions.

I did also stumble across mhddfs FYI
hxxp://romanrm.ru/en/mhddfs

Thanks,
Ryan
 
Old 02-03-2012, 12:05 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
I suggest that you create a symbolic link to the mount points, rather than the individual files:

ln -s /media/disk1/myPictures /home/ryan/myPictures/disk1
ln -s /media/disk2/myPictures /home/ryan/myPictures/disk2
But that is not what the OP wants. The OP wants the contents of two separate directories to appear in a single, consolidated directory. If you notice, the original command places the symbolic links for both disk1 files and disk2 files into one directory. In effect, the commands "merge" the contents of the two disks.

Switching gears... back to the suggestions I made earlier. I think the only solution that will fit your needs would be a filesystem monitor--if you will be manipulating images and need the symbolic links updated as you work (e.g. creating new images, deleting images, etc.). The udev rule approach will work if the contents of the two disks are static. Otherwise, you'll need to disconnect-reconnect whenever you want the links updated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help with symbolic links cmfarley19 Linux - General 2 08-25-2010 10:30 AM
Symbolic links Vs Hard links sulekha Linux - General 2 10-02-2008 07:03 AM
Symbolic links? TongueTied Linux - Newbie 3 08-27-2003 06:00 AM
symbolic links winger Linux - General 5 04-06-2002 05:16 PM
Symbolic links Valerie Linux - Newbie 12 03-31-2002 01:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration