[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Adding a new HDD - how do I move / everything ?



[This message has also been posted to linux.debian.user.]
In article <7D6gb-4wO-11@gated-at.bofh.it>, Abu Zaher wrote:
>
> I'm currently running my Sid on a 40GB hdd which is running out of life, In
> a few days I'll buy a new 80GB. Now what is the best way 2 dump my whole /
> to my hdd so that I can boot and do all my stuff from that hdd? I mean the
> above discussion is for /var/lib/mysql, will the same work for / ?

I've copied whole Debian installations.  There are many ways;
I'll just show one.
I assume your whole system is on one drive /dev/hda, and you're
replacing it, and the "slave" (/dev/hdb) on the first ATA channel 
is where you have temporarily attached the new drive.

1.  Boot your old system with the new drive at hdb.
2.  Observe your old partition table with fdisk -l.
3.  Observe your disk utilization with df.  Write it down.

4.  Partition the new drive the same way, except make
the partitions bigger.  I like cfdisk for this.
Keeping the same partition table assignments means you won't
have to edit /etc/fstab on the new drive.

4a. If you have time, run badblocks over each new partition.
It won't report any errors, but this gives the drive a chance
to spare out any sectors which may have gone bad in shipment
and storage.  It also brings it up to operating temperature.

5.  Build file systems and a swap area on the new drive.
Swap area should be at least twice the size of the real
RAM you expect to have over the life of this drive.
More than three times is a waste.
If you're using a customized kernel, make sure it knows how
to mount the type of file systems you chose.

6.  (optional) Format a brand new floppy disk and make a selfcontained
GRUB disk out of it.

     fdformat /dev/fd0
     cd /usr/lib/grub/i386-pc
     cat stage1 stage2 > /dev/fd0
     floppycontrol -f
     cat stage1 stage2 | cmp - /dev/fd0

Floppies are often defective so you have to verify them like that.
7.  Insert your Debian install CD and reboot.

     shutdown -r now

At the boot prompt, hit Enter.  When the installer asks you
to select a language, ignore it and hit F2, Enter.  You should
get a root shell prompt.

8.  For each file system on disk, make temporary mount points,
mount the old and new file systems, copy the old to the new,
and unmount both.
Let's say you have root on hda2, /usr on hda6. and /home on hda7.
This may look like a shell script, but you can just type
it carefully into the shell prompt.

     for i in 2 6 7
     do
        mkdir /mnt/hda$i /mnt/hdb$i
	mount /dev/hda$i /mnt/hda$i
	mount /dev/hdb$i /mnt/hdb$i
	cd /mnt/hda$i
	cp -a . /mnt/hdb$i
	cd /
	umount /mnt/hdb$i /mnt/hda$i
     done

9.  Now you have a complete copy but it's not bootable.
Shut down your computer and move the new drive to the "master"
position on the first ATA cable.  You'll probably have to
adjust the jumper.

10.  Boot the CD again.  This time type

   rescue

at the boot prompt.  The installer will set up in RAM and turn
on the network, but then you will get an Enter Rescue Mode
dialog where it will ask you where your root file system is.
Select the appropriate partition (part2 in this example)
and hit Enter.  The next dialog offers to reinstall the GRUB
boot loader.  Select that and it will give you some options
to make the new drive bootable.  Install GRUB to the master
boot record.

11.  Reboot without the CD.  GRUB should find your menu.lst,
kernel and initrd, and your new system should come up just
like the old one.  You might want to run grub-install
and update-grub just so you have the same version as before,
but it's not really necessary.


Cameron




Reply to: