# Need help moving gentoo to its new home: hdc(from hda)

## Hamking

Ok, check it:

I got a new harddrive from my work(40GB for $50 smackers OTD. not too bad...). Its a Maxt0r 40GB 7200 ata/133 drive w/ standard 2MB buffer. Ok... this thing beats the pants off what I have gentoo installed on right now:

A peice of crap refurbished 15GB ata/33 5400rpm junk heap.

Ok, here's the delema:

How do I move the entire contents of "hda"(crap drive) to "hdc"(new drive)???

I've sucessfully formatted, and partitioned the new drive using cfdisk. I've been able to copy the /boot directory to hdc1. but when I go to

```

cp -r / /mnt/espace

(/mnt/espace being where I have hdc5 mounted on for the moment)

or 

cp -R / /mnt/espace

```

It never copies the entire contents of hda5.

Is there another way to just straight up copy hda5 to hdc5 or somthing? or am I just not passing the "cp" command the right options?

HELP!!!

I want to be rid of this crappy 15Giger for g0000000d!

thanks!

 :Very Happy: 

----------

## snkmoorthy

Hope you are  *Quote:*   

> root

  when doing that

----------

## aridhol

to copy the entire disk with bootloader and all:

```
dd -if=/dev/hda -of=/dev/hdc
```

Only negative thing here is that it takes the exact partitiontable so you must fix the partitions after the copy.

Lets say you want all the extra space on /home which is on hdx5

just remove /home /dev/hdc, create a new partition with all the space that is left (lets say it became /dev/hdc5 again), then copy only that partition

```
dd -if=/dev/hda5 -of=/dev/hdc5
```

I'm not 100% sure on this last bit since I never did it myself, but the first dd is correct. If you fail, you can always start over again. Just make sure you don't accidentally set a -of=/dev/hda

----------

## Hamking

2 things:

do I need any of the /dev/hdc drive mounted to do this? hdc1 or hdc5? Or should it be unmounted?

and then I imagine that this process is going to take a while...

Gkrellm is saying that my one crap hdd is transfering at about 2.5 to 3MB/s max. Plus there's a 1sec. pause every 5 seconds or so... yeah... 12.34GB is going to take a little bit I would assume?

Ah... one more thing??? can't I just do this instead:

```

dd if=/dev/hda1 of=/dev/hdc1

```

and after that:

```

dd if=/dev/hda5 of=/dev/hdc5

```

and then just change fstab to reflect the changes, switch my drives in thier physical positions(sadly.. my crappy old pentium2 mobo doesn't see harddrives on the second IDE channel. it see's cdroms... just not harddrives... it totally wierd. and I've tried like 3 different harddrives too).

would it be possible to also run this:

```

mv /dev/hdc /dev/hda

mv /dev/hdcx /dev/hdax

```

that way, I wouldn't even need to change fstab???

hrm... somthing to ponder on my part....

----------

## Hamking

ok

when I did:

```

dd if=/dev/hda5 of=/dev/hdc5

```

it wrote all the data... but it now says the "c" drive is only 13GB. 

how would I go about transfering the "a" drive, while keeping the larger partition(its about 39GB) on the "c" drive intact? or how can I make it larger after I transfer everything?

----------

## pilla

Make the partitions, file systems and then use this tip to clone your gentoo root.

----------

## Hamking

ok cool... just one problem. 

I must be a dummy... hehe

in the post for that script.. it says just copy it to an empty file and save it.

I just dont know how to do that.  :Very Happy:   :Very Happy: 

hehe...  :Embarassed:   :Laughing:   :Embarassed: 

----------

## Hamking

how do I make an empty file?... and what would I open it with, to save the script into it, once I make it??? hehe... 

Hamking=n00b  :Embarassed:   :Embarassed: 

----------

## fifo

Use a text editor.

----------

## pilla

as a text editor, you can use nano (or vi, if you have emerged it)

----------

## dweigert

Or easier still, just say

```

touch filename

```

This will creat a zero length file

Dan

----------

## Xhosa

dd does an exact disk-to-disk copy, i.e if /dev/hda is 13GB, then the image written to /dev/hdc will also be 13GB, even if /dev/hdc is 20GB.

There is a tool called 'parted' (emerge parted) which will let you resize the new image to fill all the remaining space on the new drive.  

Hope this helps...

----------

## xentric

There's a simple command to copy all files in a partition to another partition without breaking things... basically 3 simple steps and you're done  :Smile: 

1.first mount the partition you want to move your files to (mount /dev/hda? /mnt/temp)

2. type: cd /

3. then type command:  tar lcf - .|(cd /mnt/temp; tar xpvf -)

The command in step three will copy only the files & dirs that are on the / partition itself and won't try to copy mounted partitions that shouldn't be copied (you can get nice disk-filling-loop-effects if you try this with cp !) but using tar is simple and effective.

----------

