LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-27-2012, 05:42 PM   #1
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Rep: Reputation: 30
Hard Link Directory


I know you can't (at least from what I've read) hard link a directory, but I'm wondering what other options I have to accomplish this:

I want to copy a directory, for example, /foo/bar.0/ to /foo/zoo/ but assume the copy takes 24 hours. And during the copy /foo/bar.0/ is renamed to /foo/bar.1/

How can I do this? Is it even possible?

The first thing I thought of was a hard link to the directory, but like I said that didn't seem possible.
 
Old 01-27-2012, 06:17 PM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
It depends on filesystem, but ext4 does not support hard link to directory. You can use bind mount if you do not need to make a real copy:
Code:
mount --bind /foo/bar.0 /foo/zoo
And of course you can use symbolic link.

Last edited by eSelix; 01-27-2012 at 06:20 PM.
 
1 members found this post helpful.
Old 01-27-2012, 06:38 PM   #3
pyroscope
LQ Newbie
 
Registered: Jan 2012
Distribution: Debian / Ubuntu
Posts: 15

Rep: Reputation: 2
You can also use "cp -rl" which is something inbetween (namely, hardlinks for all the files in the tree), and quite fast, thus there is much less danger of race conditions.
 
Old 01-27-2012, 10:29 PM   #4
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
Thanks! Actually that "mount --bind" idea might be perfect. I really don't need another copy of the directory contents, I just need to keep a "pointer" to the directory that I'm acting on (even though it may be renamed by another process).
 
Old 01-30-2012, 07:08 AM   #5
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by podollb View Post
I know you can't (at least from what I've read) hard link a directory, but I'm wondering what other options I have to accomplish this:
Not possible, you can add one vote from my side

Quote:
Originally Posted by podollb View Post
I want to copy a directory, for example, /foo/bar.0/ to /foo/zoo/ but assume the copy takes 24 hours. And during the copy /foo/bar.0/ is renamed to /foo/bar.1/
What on earth does that means?
You were copying something while copy was under process you changed the name of the directory bar.0 to bar.1?

or you want to rename it?

If you can clear me this thing I might look forward to give a stress on your problem.
 
Old 01-30-2012, 08:29 AM   #6
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
This thread was already answered. In my last post I also gave a bit more explanation.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference Between Soft Link & Hard Link rajaniyer123 Solaris / OpenSolaris 16 09-30-2012 03:42 AM
how do you "hard link" a whole directory? isaaclw Linux - Software 11 04-06-2011 11:25 AM
create soft link and hard link in RHEL5 ramadas88 Linux - Server 6 09-15-2010 04:32 AM
need to link a home directory to an apache directory Melsync Linux - Server 3 09-30-2006 05:08 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:52 PM.

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
Open Source Consulting | Domain Registration