# Copying gentoo to another PC

## taedium

Hi

I need to install gentoo on a notebook, but I have a working gentoo installation on another notebook, which I'd like to duplicate. 

What I thought of is to create the needed partitions and compile the kernel as explained in gentoo handbook; then copy over my gentoo installation, check the configuration, install grub and reboot. I don't expect everything to just work, but it should be feasible.

My doubt is if the programs compiled on a notebook will run on another hardware. The working gentoo notebook is an intel core i5, while the "new" system is an intel core duo. My CFLAGS are:

CFLAGS="-march=native -O2 -pipe"

and on gcc man page I read:

Using -march=native will enable all instruction subsets supported by the local machine (hence the result might not run on different machines).

Anyway, reading the list of possible choices for -march, I think "core2" is the best candidate for both core duo and core i5 architectures. So the question is: will software compiled on core i5 run on core duo?

Thanks for your help!

----------

## i92guboj

 *taedium wrote:*   

> Hi
> 
> I need to install gentoo on a notebook, but I have a working gentoo installation on another notebook, which I'd like to duplicate. 
> 
> What I thought of is to create the needed partitions and compile the kernel as explained in gentoo handbook; then copy over my gentoo installation, check the configuration, install grub and reboot. I don't expect everything to just work, but it should be feasible.
> ...

 

core2 should be fine for both. However, software compiled for i5 might use some sse instructions that are not legal in the core2 duo cpus. I am not 100% sure. There are too much processors nowadays to keep track of them all.

Even if the binaries are not 100% compatible, they might work most of the time, except when doing some very specific tasks. In any case, I think you should be able to boot, then just recompile on the notebook with native to be sure. If you don't want that, then set -march=core2 in the big machine, recompile everything and use that for both. All you need is to make sure that the kernel in the little toy has support for the relevant chipset(s) and filesystems, and it should boot. You can polish it afterwards.

----------

## taedium

well, complete mess.

Thanks for your reply, but I tried and I failed  :Very Happy: 

The system indeed booted with the software of the other machine, but there was a program not working: gcc!

I copied over the one from stage3 and I was able to compile. So I thought: "let's compile a new compiler!". How ingenuous. The new compiler compiled, but then, automatically and unexpectedly, portage started to remove several packages from the system, with the result that it is now unusable, not even the login works. I think I could restore copying the missing packages by hand, but it looks like too much work for a solution which I thought of to save time.

This is blocking me and pushing me away. I think I should go through a normal install. It's a pity because it almost worked, I was just about to compile intel graphic drivers and start X.

----------

## cach0rr0

have you stumbled upon this? http://en.gentoo-wiki.com/wiki/Custom_Stage4

NB: if you build on the i5 using -march=core2 it should work fine on the core2duo machine. Also, if you ever b0rk something completely, and need a prebuilt binary package to save your ass, Tinderbox is your friend - http://tinderbox.dev.gentoo.org/

----------

## taedium

I cautiously created a, say, "stage3.5", that is, I made a tar after compiling and installing the kernel on the core2 and just before copying the i5 binaries over, so it was easy to restore to that point and proceed with a normal installation (that's to say a "normal" two-days non-stop compilation). Obviously, I copied over all of my configuration and user files (/etc and /home) so at least the only human intervention was to issue emerge commands.

Anyway, as I stated, the core2 booted with the binaries of i5 (compiled with -march=native), but gcc was not working - when launching it, even on a simple hello world program, it stated "internal compiler error" - so I copied from stage3 all files listed by

```

equery files gcc

```

to have a working compiler. The real problem is that, as I said in my previous post, emerging gcc with the compiler from stage3 had a strange behaviour: it compiled and installed correctly, but then unmerged a lot of packages, even @system packages, rendering the system unusable, and I really don't understand why. Would be interesting to understand this, in case I need to try again (for example when I'll buy another pc). Any idea?

----------

## Ant P.

The safest thing to do is get the CFLAGS off the core2:

```
echo $(gcc -v -march=native -x c /dev/null 2>&1 | grep -- '-march' | egrep -o -- '-+(m|param )\S+')
```

...then use those on the i5 to emerge -e world, and just copy the hard disk contents via a liveCD.

----------

