I'm a hair confused.
Situation: You have a (more or less) complete, working system installed on a single HDD. You want to take this entire system, and move it to a new HDD.
Is that correct?
I'm going to assume the following:
/dev/hda1 is the location of the data, the "system" if you will
/dev/hda5 is the swap location assuming you have swap
You will need to do the following:
First off, you have a new HDD I presume?
Lets say your old HDD looked like this (for giggles)
hda1 = 25gb
hda5 = 5gb
- Install your new HDD (I'm going to call it 30gb total in size), this new install we'll place on the slave of your IDE0 controller, so it is now /dev/hdb
- Boot your system using a live CD, do not try and tar the system while running it, everything should be done from a live CD.
- We need to make hdb "look like" hda so we'll do the following
# sudo fdisk /dev/hdb
you will now be in the fdisk program, enter m to get a view of the menu, we will only use a handful of these flags and what-not
First things first "p" - this will display what, if anything is on your new HDD (/dev/hdb). If anything is present - wipe it off this is envoked via "d" (easy huh?)
Okay, now that your new HDD is clean, we need to make 2 (maybe just 1?) partition, one for data, one for swap. This is your game now, figure out how much space you want for them and do the math.
n - will create the new partion, give it the number "1" and it will create /dev/hda1 partition.
n - create a 2nd partion with remaining space, or ignore this step if you have no need for swap and just expand the entire disk to hda1
If you created one as swap, enter m and change the type of the partition to a linux swap partition. Play around with this program, you wont officially "do" anything to the disk until you enter this next command
w - this will do everything you configured in fdisk (Ah crap, I screwed up!! - big whoop, hit "q" and start over.
Now you have hdb1 setup (yay!) Format time! (I'd like to just point out, that some of this stuff you'll need to make decisions on, so just use my description as a general setup guide unless of course it's the same - rock on then)
format time
# sudo mke2fs -j /dev/hda1
This will create an ext3 (-j flag makes ext3 if you exclude the -j it will be ext2) on your new partion
# sudo mkswap /dev/hda5
This will create the swap format on the other partion (again, ignore this if you dont plan on swap).
Assuming all this has worked thus far, you should now have this in your computer:
/dev/hda1 - All your data
/dev/hdb1 - Blank HDD awaiting data
...
Now lets tar...
# sudo mount /dev/hda1 /olddirectory
# sudo mount /dev/hdb1 /newdirectory
# cd /newdirectory
# sudo tar -zcvpf backup.tar.gz /olddirectory/*
That is the structure of the tar command - it will tar the entire hda1 system to whatever location you specify, here I used /newdirectory by cd'ing over to it and created a file called backup.tar.gz
(Long wait)
Assuming no errors, you now have a huge tarball sitting on /dev/hdb1, go to where it resides and now do the following:
# sudo tar -zxvpf
This will untar the file onto the new system, CD over to what root should look like I'd assume it'd just be /newdirectory if all goes well (meaning, inside that folder, should look exactly like your old PC - It does? great!)
# sudo chroot /newdirectory /bin/bash
# cd /
# ls
After running ls it should look the same as your PC has always looked, almost like you're not even running the live CD.
# exit
# reboot
remove the CD
power down
open the case, and switch master/slave on your disks (hda and hdb)
reboot
Enjoy life
Now, go into all those commands, and read the man and info pages - you'll learn quite a bit. I've just always hated when people told me years ago, "Read the man, read the info, rtfm, blah blah..." and never bothered to answer a question.
I hope this helps you.
Edit:
The reason I trust this method, I've done it about 3 times in a week on my system. To make a long story short, I had a 250watt power supply, 3HDD and a burner. When my updatedb cronjob kicked in - forget it, the powersupply couldn't keep up, I cooked all 3 drives one at a time, killed a 30 gig, 15, and 13 gig. Lucky for me, I had a backup of my home directories on another 15 gig drive, as well as pictures, and random stuff, notes, scripts, stuff like that. I moved all that data to two 5gb drives, upgraded to a 400 watt power supply, and rebuilt the system on the 15gb backup drive and now use the 5 gig ones as backup and file storage. Unfortunately for me (fortunately?) I know all about this failing HDD situation