Operating System - HP-UX
1833847 Members
2000 Online
110063 Solutions
New Discussion

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

 
SOLVED
Go to solution
Steve Post
Trusted Contributor

howto sync from A:/mydir to A:/tmp/chroothome/mydir

I want to have any changes in hostA:/mydir show up automatically in hostA:/tmp/chroothome/mydir for user X. This user X has a chrooted ssh-sftp connection. He can't see hostA:/mydir. But I want them to see it in read only mode. Any ideas?


I have a some ideas. I'm looking for opinions on which way to go. If you have another idea, go ahead and present it. These are not in any particular order.

idea1: Rsync is supposed to syncronize directories from one host to another. But I don't want that. This is on one and only one host. So I don't think this is the way to go. I could easily be wrong. I know hardly anything about rsync.

idea2: Rdist is an old hpux command that appears to not be used by anyone. It also is assuming I go over a network to sync up two separate computers. Only one box. I don't think this one is right either.

idea3: I could run this once a day on hostA:
cd /mydir
find . -mtime -1 -print | cpio -pdumvc /tmp/chroothome/mydir/.

But I would rather have it so the spot automatically updates anytime the files change. I could change the syntax to run it for changes every minute. But maybe this is overkill too.

idea4: I could use a symbolic link?
/tmp/chroothome/mydir -> /mydir.
But this doesn't work because when user X ssh's in, they can't see /tmp/chroothome. If it was seen, their version would be /tmp/chroothome/tmp/chroothome. Kinda confusing, and not really useful.

So I don't have any ideas that would quickly update /tmp/chroothome/mydir to constantly match the real directory /mydir. Do you have any?
12 REPLIES 12
Geoff Wild
Honored Contributor
Solution

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

Easiest and probably the best - NFS:

Then you export /mydir as RO to /tmp/chroothome/mydir

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steve Post
Trusted Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I tried nfs. It didn't work. I bet I did something dumb. I tried to mount /home/mydir to /home/me/mydir.

I log into host: hostA.
I run command: cat /etc/exports
/home/mydir -anon=65534, root=hostA,access=hostA

I run command: "exportfs -a"
I run command: "mount -F nfs -r hostA:/home/mydir /home/me"
It said: "nfs mount: mount_nfs: mount: /home/me: Device Busy"
Please realize on am on hostA trying to NFS mount hostA:/home/mydir to hostA:/home/me/mydir.
I'm not really using the network.
This does not seem right.

I can imagine myself standing on a rug. Reaching down. Grabbing the edge of the rug. And pulling real HARD. Is that what I'm doing here? Am I trying to remotely mount a filesystem I am standing on?

Well I tried the same stuff with "mount -F nfs hostA:/tmp /home/me". I get the same error.
Geoff Wild
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

How to do it:

in /etc/exports

/mydir -ro


Then exportfs -a

Then mount it:

mount hostA:/mydir tmp/chroothome/mydir

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Geoff Wild
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

Forgot the leading / should be:

mount hostA:/mydir /tmp/chroothome/mydir

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steve Post
Trusted Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I KNEW it was something stupid. I was mounting to a directory that already existed. So it already was in use.

You can't mount host:/A to /home. That one is in use. You have to mount host:/A to /home/A, not /home. ....duh.


V. Nyga
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

Hi,

you should add your mount to /etc/fstab so you'll have it again after a reboot!

mount hostA:/mydir /tmp/chroothome/mydir nfs ro,bg,hard 0 0

Nevertheless the symbolic link should have worked too - you have to do it as root at the server, but the user would need read permissions to the original directory.

ln -s /mydir /tmp/chroothome/mydir

/tmp/chroothome/mydir may not exists before!

Volkmar
*** Say 'Thanks' with Kudos ***
Steve Post
Trusted Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I agree with the fstab mod (once I set the ideas in stone).

I disagree with the link idea.

"ln -s" properly redirects me to a location. But the location is completely invalid because I am in a chrooted environment. So it fails. (It's like standing on air. There is no directory under my feet).

"ln" might have worked, but hard linking directories is not allowed. And I would be forced to have the stuff on the same filesystem.
Geoff Wild
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I wouldn't put it in fstab file at all - I would use the automounter instead.

# cat /etc/auto_master
/- /etc/auto.direct proto=tcp


In /etc/auto.direct

/tmp/chroothome/mydir -ro hostA:/mydir

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dennis Handly
Acclaimed Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

>ln(1) might have worked, but hard linking directories is not allowed.

It is allowed for root on some file systems but you need to be careful, link(1M). Backup tools may dump it twice?
Steve Post
Trusted Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I think I'll just use rsync. I tried it on my test box. As long as the number of files do not get excessive, it should be ok. The reason why I didn't look into it sooner was I didn't know how to use it to sync directories locally. It's not instant. But that's ok.


TwoProc
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

I'd go with rsync. I use it for that same purpose (same host). The reason I like this tool best is because it only updates changed files, so I can run it hourly if necessary w/o problems.
We are the people our parents warned us about --Jimmy Buffett
Heironimus
Honored Contributor

Re: howto sync from A:/mydir to A:/tmp/chroothome/mydir

A symlink actually should work, you just did it in the wrong direction. The chroot is like a piece of one-way glass. Things inside the chroot can't see the rest of the system, so a symlink inside can't point at something outside. The rest of the system sees the chroot directory as an ordinary directory, so a symlink outside a chroot can point at something inside.