Click to See Complete Forum and Search --> : Adding additional space to server.


linlin
10-27-2006, 02:21 AM
ok so heres my deal, I have a 1U rackmount box colocated at a datacenter in Miami. My current hard drive configuration is as follows:

hdc(1,2,3) = Master IDE drive, 20GB, Mountpoints: /boot, swap, and /
hdd(1) = Slave IDE drive, 30GB, Mountpoint: /home

pretty much ignore the 20GB drive, thats not going anwhere. My concern is with my 30GB drive, which contains my /home directories. I am buying a 300GB IDE drive on ebay to replace this drive. So with the prerequsites out of the way, heres my questions.

The machine is hosted remotely. I have a friend in Orlando that may be willing to make the drive to swap my new drive in. If I ship him the drive, brand new out of the box, no partition, no formatting, etc, what would be the process to remount this new drive to /home just as the old drive was. The old 30GB would be sent back to me. I can make backups of a few gigabytes of the users home directories while the transitions are in place, but most of the crap is just that, dormant crap, so I have no problem deleting it. I do however still need all the users to be able to log in again without issue, minus the fact that all thier crap is gone.

So, it boils down to this:

What would be the basic process for copying the important stuff off the existing drive, unmounting the drive, (shut down box, install drive, reboot drive) and get the drive up and running. Can all the formatting be done remotely? Is there anything in the /home directory that is not repalceable or absolutly cant be moved?

I think I have a pretty good idea of how to do this, just looking for some input from the community. Thanks alot :)

Will

dkeav
10-27-2006, 10:45 AM
cfdisk (new paritition)
mkfs.somefs /dev/newdrive#
mkdir /mnt/tmphome /dev/newdrive#
cp -Rpv /home/* /mnt/tmphome/
umount /mnt/tmphome
edit fstab if needed
shutdown, swap hardware out, reboot

ph34r
10-27-2006, 11:21 AM
Go into your server, remount /home as read-only, setup new disk on local machine, rsync files over, send drive, put in, reboot box, up and going.

bwkaz
10-27-2006, 06:08 PM
cfdisk (new paritition)
mkfs.somefs /dev/newdrive#
mkdir /mnt/tmphome /dev/newdrive#
cp -Rpv /home/* /mnt/tmphome/
umount /mnt/tmphome
edit fstab if needed
shutdown, swap hardware out, reboot Well, I'd do it more like this:

put new drive in
cfdisk (new paritition)
mkfs.somefs /dev/newdrive#
mkdir /mnt/tmphome
mount /dev/newdrive# /mnt/tmphome
cp -Rpv /home/* /mnt/tmphome/
umount /mnt/tmphome
edit fstab if needed
shutdown, swap hardware out, boot

Also note that you should not put /mnt/tmphome into fstab (because it'll only be mounted once). And when you do edit fstab, don't use /dev/newdrive# for the /home partition -- make sure you use the device that corresponds to where the new drive *will* be, after it gets swapped out in the last step.

And log in as root first, to ensure everything's where it should be. (Do this locally if possible -- i.e., go along if you can, or give your friend the root password if you can't go. If you don't want to give your friend the root password, and you can't go, then you'll just have to hope the box comes all the way up even if /home is hosed.)

dkeav
10-27-2006, 06:49 PM
heh thanks bwkaz

linlin
10-28-2006, 12:59 AM
Thanks guys, bookmarking this thread so when the plan goes through I have a good starting point

DrChuck
10-28-2006, 03:27 PM
cp -Rpv /home/* /mnt/tmphome/Bwkaz, I'm not sure that this will get all the hidden files, links, etc often found in home directories. For cloning a complete directory tree, I suggest using rsync, with the "a" for archive flag:rsync -av /home/ /mnt/tmphome
Regards,
drChuck

crow2icedearth
10-28-2006, 11:16 PM
I would either use rsync or i would use the dd command .The dd command is a much better choice when copying a partation then the copy command. Primary because it copys bit for bit.One good thing with linux is you can do the same thing many different ways.

rsync -av /home/ /mnt/tmphome


cp -Rpv /home/* /mnt/tmphome/

bwkaz
10-29-2006, 02:53 PM
Bwkaz, I'm not sure that this will get all the hidden files, links, etc often found in home directories. Hmm, you are correct, it may not (I'm not sure). I just used the same cp command that dkeav used. However, I'd use cp's -a flag instead (because I don't have rsync installed, and I don't plan on it when cp can do what I need anyway ;)). From the cp manpage:

-a <...> Equivalent to -dpPR. And:

-d Copy symbolic links as symbolic links rather than copying the files that
they point to, and preserve hard links between source files in the copies.

-p Preserve the original files' owner, group, permissions, and timestamps.

-P Do not follow any symbolic links, neither those that occur in the parameter
list nor those encountered during the recursive copy. Just copy them as
symbolic links.

-R Copy directories recursively, and do the right thing when objects other than
ordinary files or directories are encountered. (Thus, the copy of a FIFO or
special file is a FIFO or special file.) So -a should work fine.

However, from the "expansion" of -a, it appears that dkeav's -Rpv would work mostly OK -- it would be recursive, and preserve owner/group/permissions and times. It would not necessarily do the right thing with symlinks or hard links though.

The dd command is a much better choice when copying a partation then the copy command. Primary because it copys bit for bit. Um, copying bit for bit won't work when the new partition isn't the same size as the old partition, though. ;)

(Well... it would, but your bit-for-bit-copied FS won't be able to hold any more files when you get it up on the new larger partition. Not until you unmount and resize2fs it, anyway.)

dkeav
10-29-2006, 03:22 PM
* will get hidden files, i just assumed you didnt have many/any sym/hard links in a home directory, but sure why not if that were the case then yea use -d