On Mon, 2005-08-08 at 19:03 -0700, Ajay Sharma wrote:> Hi,
> This might sound like a n00b question, but I've honestly never done
this
> with a Linux machine...  (it is running Centos3)
It's not a noob question.  It comes up regularly.
> How would you do it?
I regularly do this on Linux and Solaris (and should be applicable to
just about any other System-V UNIX flavor -- especially step #3) using
the following procedure.
I recommend you do it from run-level 1 (or even init=/bin/sh), but it's
not totally necessary (it all depends on what files are open and/or what
is running).
  1.  Slice (partition) new disk and create new filesystems
NOTE: If you're using filesystem labels (e.g., e2label), we sure you
enter them appropriate under #4 below.  If you configure software RAID,
remember your configuration files.
  2.  Create a new mount point, say /newroot, and mount new filesystem
tree under /newroot
NOTE A:  You do _not_ need a 1:1 filesystem setup, you can change your
filesystem organization if you wish.
NOTE B:  Also remember that /newroot/tmp, if a separate filesystem,
should be chmod 1777, although #3 might correct this anyway.
  3.  Copy all existing data as follows ... (pretty much universal to
all System-V UNIX flavors) ...
  for i in / /fs1 /fs2 ...; do
    cd $i
    find . -mount | cpio -pmdv /newroot$i
  done
You can make this one line with:  
  # for i in / /fs1 /fs2 ...; do cd $i; find . -mount | cpio -
pmdv /newroot$i; done
NOTE A:  The list of filesystems should be the _original_, not the new
ones.  Using the "-mount" (sometimes "-xdev" on other
implementations)
option to find does not cross filesystems, hence why you pass the
existing filesystems.  The new tree will be populated as appropriate.
NOTE B:  "Sparse files" may be expanded after this operation and take
up
more disk space, depending on the filesystem(s) in use.
  4.  Modify filesystem (e.g., /newroot/etc/fstab), bootloader
(e.g., /newroot/etc/grub.conf or lilo.conf),  etc... as appropriate,
including any LVM/MD disk organization.
  6.  Re-install bootloader (e.g., GRUB/LILO) to new disk
NOTE:  You _may_ need to boot the distro's CD and recovery mode after
you remove the former disk for proper BIOS-Linux device disk mapping.
I've been able to do so in LILO without, but GRUB always seems to never
likes the fact that my mappings don't line up until I make them actual
(so I typically use the rescue CD).
-- 
Bryan J. Smith     b.j.smith at ieee.org     http://thebs413.blogspot.com
----------------------------------------------------------------------
The best things in life are NOT free - which is why life is easiest if
you save all the bills until you can share them with the perfect woman