[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does mv Preserve Hard Links?
From: |
Bob Proulx |
Subject: |
Re: Does mv Preserve Hard Links? |
Date: |
Wed, 22 Jun 2005 09:55:07 -0600 |
User-agent: |
Mutt/1.5.9i |
address@hidden wrote:
> mv /mnt/fs1/dir /mnt/fs2/dir
>
> where /mnt/fs[12] are two different ext3 filesystems, /mnt/fs2/dir
> doesn't exist, and /mnt/fs1/dir contains many thousands of files,
> several thousand of which are reference by 3 to 6 directory entries
> compared to the normal 1.
> [...]
> I've got lots more moving to do so I'd like to determine if there are
This is an orthogonal answer. Personally I highly recommend using
'rsync' for what you are wanting to do. It has several advantages.
* You can interrupt it without issues of partial data movement
* You can restart it
* You can run it several times on the same data without issue
* It can optionally preserve hardlinks
Example:
rsync -a --hard-links /mnt/fs1/dir /mnt/fs2/
Hint: Don't specify the target directory. The rsync rule is that if
it is a directory then the result is in that directory and you get one
more directory than you probably wanted.
If you have a large amount of data but don't want to take the original
offline from users you can make a copy ahead time and then sync the
final changes quickly when you are ready to make the switch. In that
case use the --delete option to make an exact copy including removing
files that have been deleted. Deletion can be dangerous so I always
check that I have the directories lined up right with the -n option
first and then run without the -n when I am sure I have things right.
Use the --delete to make an exact copy, testing with -n first.
rsync -n -av --delete --hard-links /mnt/fs1/dir /mnt/fs2/
After verifying that is what I want then run without the -n.
rsync -av --delete --hard-links /mnt/fs1/dir /mnt/fs2/
Bob