[TriLUG] Moving /home and others to new partitions
Steve Litt
slitt at troubleshooters.com
Tue Jan 18 10:44:19 EST 2005
On Tuesday 18 January 2005 10:24 am, Rick DeNatale wrote:
> Some time ago, with advice from the list, I added a couple of 180GB
> IDE/ATA drives to my system which was running on two 9GB SCSI drives.
> I've now gotten to the point where one of the SCSI drives is near to
> overflowing so I need to move some stuff to one or more partitions on
> the big disks.
[clip]
> What's the best way to accomplish this safely? I know that I need to
> create a partition for each of these, temporarily mount it, cp the
> files, test the copy, delete the files from the original location and
> then remount to the (now empty) original directory.
>
> so as an example I'm thinking to move the /public directory
>
> 1) Fdisk to create partitions and make filesystems
> 2) sudo mount /dev/hdcx /mnt/temp
> 3) Stop samba, atalk, cron services
> 4) sudo cp -al /public /mnt/temp
> 5) test somehow that the copy worked. Suggestions?
> 6) sudo rm -Rf /public/*
> 7) restart services
Without addressing any of your other questions, I'd like to give some advice
on the copy. Most people accomplish this type of tree copy not with the cp -R
command, but with either tar or cpio. The reason is that these archiving
utilities really do a good job with ownership, permissions, timestamps,
hardlinks and symlinks.
The following script is my cptree command, that copies a tree from one place
to another. I've used it in my backups for years, and as far as I can tell it
works perfectly. Mine uses tar, but you can do something similar with cpio.
#=========== Start of script, delete this line ===============
#!/bin/bash
echo Tree copying $1 to $2
sleep 2
tar -cvf - $1 | tar --atime-preserve -C $2 -xf -
#=========== End of script, delete this line ===============
The sleep command is so I get a chance to see what's copying to what before
all the copying scrolls the screen, but it certainly isn't necessary to the
actual functioning of the script.
HTH
SteveT
Steve Litt
Founder and acting president: GoLUG
http://www.golug.org
More information about the TriLUG
mailing list