[ILUG] Copying directory trees

Chris Higgins chris.higgins at darach.ie
Tue Jan 27 10:08:54 GMT 2004


On 27 Jan 2004 09:19:25 +0000
Brendan Halpin <brendan.halpin at ul.ie> wrote:

> Say I want to move /usr/local to a new partition: what's the least
> error-prone way of doing the copy?
> 
> cp to the new location, delete old, edit fstab, mount new partition?
> tar /usr/local, delete old, edit fstab, mount new partition, untar?

mkdir /usr/local2
mount /dev/hda-new /usr/local2

cd /usr/local
tar -cf - * | ( cd /usr/local2 ; tar xf - )

sync

umount /usr/local2
umount /usr/local

mount /dev/hdanew /usr/local

You can add a 'v' argument to the second tar to see the progress
if you want. ( it adds comfort the first couple of times you do this )
I'm also assuming that there are no '.' hidden files in the /usr/local
directory itself because the first tar matches "*", so it won't catch
hidden files.

I'm also assuming that /usr/local is an existing partition and can be 
unmounted. If it is a directory of the current /usr, then a simple

umount /usr/local2
mv local local.old
mkdir local
mount /dev/hda-new /usr/local

will work. Any processes still using files in the old /usr/local will
continue to write to /usr/local.old until they restart.

Don't forget to update your /etc/fstab so that it all sticks together
on reboot.

> Brendan
> -- 
> Brendan Halpin,  Department of Sociology,  University of Limerick, 
> Ireland Tel: w +353-61-213147 f +353-61-202569 h +353-61-390476; Room
> F2-025 x 3147 mailto:brendan.halpin at ul.ie 
> http://www.ul.ie/sociology/brendan.halpin.html
> -- 
> Irish Linux Users' Group
> http://www.linux.ie/mailman/listinfo/ilug/
> 


--

Chris Higgins                              Cisco Learning Partner
Darach Technology Ltd                      tel: +353-1-6204370
email: chris.higgins at darach.ie          fax: +353-1-6204371
http://www.darach.ie



More information about the ILUG mailing list