# system copy

## digitall2000

hi how do i go about making a copy of my 3 partition

gentoo system i just installed it. it is now on a 40gig drive 

and i need to clone it to a 20gig drive

thanks

lance

----------

## freelight

Easiest way would be to:

```
cd /

tar -cf backup.tar *
```

Then recreate the partition table on the 20GB dive, mount all 3 partitions someplace, copy the file over, and:

```
tar -xf backup.tar
```

----------

## digitall2000

well i was hoping of more like a clone

----------

## freelight

dd clones a partition exactly, but you can't go from a bigger drive to a smaller drive. Also, since the Windows Registry is not involved, a simple tarball pretty much is an exact clone of your system.

----------

## flybynite

If I understand what you want, just boot from a livecd with both old and new disks in the system and

```

cd /mnt/newdisk

cp -a /mnt/olddisk/* .

```

This is a better clone because it automatically defrags the system and allows for changing the underlying filesystem too.

----------

## digitall2000

don't quite understand

cd /mnt/newdisk

cp -a /mnt/olddisk/* . 

 is the .  at the end part of the command?

 would it actually be something like this

 cd /mnt/hdb

 cp -a /mnt/hda/* .

lance

----------

## linuxtuxhellsinki

 *digitall2000 wrote:*   

> is the .  at the end part of the command?
> 
>  would it actually be something like this
> 
>  cd /mnt/hdb
> ...

 

Yes, it mean that copy all from hda to (.)=this directory where you're at that time (hdb).

----------

## flybynite

 *digitall2000 wrote:*   

> don't quite understand
> 
> 

 

linuxtuxhellsinki answered your first question, the period is a shortcut for the current dir so it is "cp -a" space "/mnt/old/*" space "."

Just to be clear, You also need to mount your old partitions on the /mnt/old and the new on /mnt/new

So if your old / partition is /dev/hda1 and your new disk partition is /dev/hdc1

Boot from the livecd and as root do this once:

```

mkdir /mnt/olddisk

mkdir /mnt/newdisk

```

Then do this:

```

mount /dev/hda1 /mnt/olddisk

mount /dev/hdc1 /mnt/newdisk

cd /mnt/newdisk

cp -a /mnt/olddisk/* .

```

Take a break.  250GB is going to take hours...

repeat for each partition you wish to copy

This only copies the partitions.  You will still need to install grub/lilo on the new disk MBR.

----------

## Element Dave

I would not trust cp, but would instead pipe the data between two instances of tar.  E.g., 

```
tar -cpf - /src | tar -C /dest_root -xpf -
```

----------

## digitall2000

boy that sounds good !!!

??but it sounds like greek to me??

would you mind showing me that code 

snippet in a more concrete fashion?

lance

----------

## drescherjm

I recommend you do what flybynite said. I have done steps similar to this a dozen times or more...

There may be a few problems with this though. You did say the new disk is 20GB? I am not sure if your gentoo system will fit as mine will not. The other problem is you have to substitute the real drives in his directions and partition and make a filesystem on the 20 GB disk. If any step is too difficult for you please ask. And give us some details of your config like what are your drives hda? sda?

----------

## digitall2000

well this is a very light weight system

week old install

and  is a simple gateway/router

i did as in the install handbook 

/dev/hda1 boot ext 2

/dev/hda2 swap

/dev/hda3 rest of system ext 3

xdiskusage says i have 37.07G total w/ 31.44G free

so that should fit on a 20G drive

so i take it i should just set up the 20G the same

as the 40G boot and swap the same size and let 

/dev/hda3 take up the slack of the drive

will this copy everything?

do i have to setup grub? fstab? 

i just really need to be sure on the directions

as i do not have the time to start from scratch 

right now

thanks again

lance

----------

## drescherjm

 *Quote:*   

> so i take it i should just set up the 20G the same
> 
> as the 40G boot and swap the same size and let
> 
> /dev/hda3 take up the slack of the drive 

 

Yes. Do that.

----------

## drescherjm

 *Quote:*   

> will this copy everything? 

 

No you will have to partition and format the 20GB drive hda1 and hda3. And run mkswap on hda2. 

This assumes you installed the 20 gb disk as hda. 

And then use these commands to copy each partition separately.

And finally you will have to use grub to install a new boot on the smaller disk.

Have you installed the 20gb disk in the pc yet?

----------

## digitall2000

not yet

i just broke something

could you look at

https://forums.gentoo.org/viewtopic-t-539919-highlight-.html

it's late here need some sleep

maybe you might help me on my most immediate problem

thanks so far

lance

----------

## drescherjm

I am not sure of what that other problem.

BTW, Another simpler way to clone your system is to download a copy of sysrescuecd and use GParted to do the copy and resize operations.

http://www.sysresccd.org/Main_Page

----------

