[MLB-WIRELESS] HD cloning.

Craig Sanders cas at taz.net.au
Wed Aug 29 17:52:19 EST 2007


On Wed, Aug 29, 2007 at 01:43:45PM +1000, Daryl Knight wrote:
> Node-IUV has a HD thats going south in it.  Anyone got a method of cloning
> or making an .iso of this thing, so I can just drop it onto a new HD and
> replace the one in the box.  Its running FC3.

this is a very common procedure, and it's pretty easy - and low risk if
you're careful, methodical and not prone to rushing or panicking.



stick another drive in the machine (doesn't have to be the same size),
partition and format it as required, mount it under /mnt (or anywhere
else convenient) then copy over all the files from the failing drive
using 'cp -ax'

note: some people will say to use "tar cf - / | (cd /mnt ; tar xf -)".
that's the OLD way of doing it on unix systems without GNU cp.

if the filesystem or partition layout has changed, you will need to edit
/etc/fstab and either /etc/lilo.conf or /boot/grub/menu.lst on the new
drive....remember that you have to edit the file under the new drive's
mount point, not the original file. e.g. /mnt/etc/fstab, not /etc/fstab.
obvious when you think about it but still a very easy mistake to make.

make sure that you have empty directories for /proc, /dev and other
pseudo-filesystems that wont be copied due to the '-x' (aka
'--one-file-system') given to 'cp'....i can't remember if cp will create the
empty dirs or not.  they're easy enough to create with mkdir, anyway.

populate the new /dev tree with essential entries:

cd /mnt/dev
/dev/MAKEDEV generic

note: if MAKEDEV isn't in /dev on FC3, it may be in /sbin.


once you've copied the files over and edited any files that need
editing, you need to make the new disk bootable. probably the easiest
way is to boot off a rescue CD, mount the file systems under /mnt,
"chroot /mnt", and then run lilo or grub-install.


and that's pretty much it.

a google search will reveal several web pages, blog entries and HOWTOs
describing this procedure in more detail, and with examples. probably
worth doing a bit of research first if the above isn't completely clear.




a useful variant of this is to convert to a raid-1 array at the same
time. get two identical drives. put ONE in the system and set it up as
a degraded RAID-1 arrays (i.e. missing its second drive). follow the
procedure as above, substituting /dev/md0 for /dev/sdb1 and /dev/md1
for /dev/sdb3. when you get to the point of rebooting into the new
system, power down and install the second new drive. boot up, get a root
prompt, partition the second drive identically to the first, and add
the partitions from the second new drive to the raid arrays. the array
will be rebuilt in the background, and the system can operate normally
(albeit a bit slower than normal while the array is rebuilding).

the swap partition on the second drive can be used as extra swap space
with mkswap, or you can use it to install an emergency rescue system
(i.e. a minimal linux install with a swag of rescue tools).

NOTE: your kernel *MUST* have raid support compiled in for this to work.


craig

ps: if the old drive is really on its last legs, it may be a good idea
to remove it from the case (but still leave it connected), prop it
up on something (e.g. a small cardboard box or something similarly
non-conductive) so that there's good airflow all around it, and put a
bloody big fan in front of it so that it doesn't overheat and die during
the copy (which will be the biggest workload it's had to suffer in a
long time).



-- 
craig sanders <cas at taz.net.au>



More information about the Melbwireless mailing list