[plug] Migrate HDD on headless server

Andrew Furey simpware at yahoo.com
Sat Jun 28 10:58:53 WST 2003


> The ssh requirement makes it hard. The usual method
> I use is to boot "linux init=/bin/bash" and DD the
> root filesystem over to the new partition while it's
> in RO mode. I then DD all the other partitons and 
> "resize2fs" or "reiserfs_resize" them up to the size
> of the new host partition. Then I shutdown, swap
> disks, boot up off a GRUB floppy and install GRUB on
> the new primary disk. It's easy and fuss free IMHO.


Alternatively rather than copy the partition with dd,
you could copy the files to a newly-created filesystem
on the new disk. Something like:

* Create the new partitions with fdisk (whatever size
you want) and format with mke2fs/mkreiser?/foo. Mount
to wherever.

* Stop everything that you can, so there's as little
writing to the disk as needs to be. This includes
samba, apache, syslog, and definitely cron. You should
be able to get a "ps ax" list down to init, various
other kernel-type processes (k*, also bdflush maybe),
a few getty/mingetty/foo processes (don't matter), and
sshd. (If you're feeling lucky you could even stop
sshd, and hope your currently-logged-in session
doesn't die... :)

* Use something like cp -ar?, tar, or my personal
choice (mc) to copy everything from / to /mntpoint.
Make sure you exclude lost+found/, proc/, and
mntpoint/, but don't forget to create a proc/
directory on the new filesystem. Other requirements
may differ if you have a separate /boot partition,
etc.

* You'll have to play around with lilo/grub to make
sure you write the correct info to the correct disk.
You should be able to confirm the latter with dd
(check the start of the new disk to make sure one of
them is mentioned), and the former with probably the
Verbose mode of whichever one you use. I know lilo has
a "-r /mntpoint" option for specifying the root
filesystem to use (the distro installation uses this),
grub may have similar.

* If you're fairly sure it's got everything, shut
down, swap the new drive in as primary master, and
cross your fingers :)


Yes, I have done this before (on production servers
with software RAID1), but no, I haven't done it
headless. It shouldn't be a problem as long as you
check everything.

Oh, and I assume that you _are_ actually doing it on a
local machine (LAN), and not actually over the Net?
Because the ssh output from mc will send your traffic
count fairly high (draws nice bar graphs).

CraigR did make a good point, putting the drives in
another machine would make things _much_ easier...

HTH
Andrew


=====
Linux supports the notion of a command line or a shell for the same
reason that only children read books with only pictures in them.
Language, be it English or something else, is the only tool flexible
enough to accomplish a sufficiently broad range of tasks.
                          -- Bill Garrett

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.



More information about the plug mailing list