# Updating kernel from Gentoo 3.7.8 to latest version

## chuckm

Hi All,

As part of a migration project, I am migrating a Gentoo 3.7.8-pbx+ server to AWS, however, AWS does not like the kernel. In order for me to complete the migration, I need to find a way to update the current kernel, which I believe is a custom kernel.

One of the biggest problems I have is I've only been involved with Linux properly for the past 2-3 years and I still have gaps in my knowledge.

My understanding is that to update the current kernel, I will need to connect to the repository specific for the kernel to pull the data I need, however, this version is no longer supported by the platform either so it is not an option.

How can I update the kernel from the current version to a newer version while keeping this server intact?

All help is much appreciated.

----------

## Jaglover

Welcome to forums!

Assuming rest of the system is also outdated. A fresh installation is the fastest and best solution in such a case. 

If you really want to upgrade only the kernel ... there is a good chance emerge will not work after you sync the portage tree. But you can get the kernel sources from kernel.org and use the old .config with new sources. However, 'make oldconfig' may fail to produce a working configuration since the version jump is too great. You could use the oldest kernel version AWS agrees with, with some trial and error it should be possible to build a working kernel.

----------

## NeddySeagoon

chuckm,

What Jaglover said but you can cut corners with the reinstall.

Follow the Gentoo handbook to install on AWS, as far as rebooting into the new install.

At this point you have a Gentoo that can do little more than build more software.

Copy over /var/lib/portage/world to the AWS install. That's all the things that were explicitly installed on the old system.

Migrate your USE flags to the new install. Some will have gone, others added, its not going to be copy/paste.

Once you are happy, run 

```
emerge -e @world --with-bdeps=y --keep-going
```

.

This will rebuild everything already installed, all the packages listed in /var/lib/portage/world and everything that the list in /var/lib/portage/world depends on.

It probably won't work first time. Post the command and the entire output.

Once that completes, you have an up to date Gentoo install that mimics your old install as far as possible but missing your data and configuration.

How you migrate that is application specific.

If you really want to do it the hard way.

That's a valuable educational experience but it will take a lot longer.

----------

## chuckm

I have skipped the native migration tool and using DD to copy and move the image of the server to AWS, move it to a secondary disk, take a snapshot and use the snapshot to start up an instance. If this works, I believe my problem then will be drivers with hard drives as this Gentoo version is old.

If this fails, I like this hard way method but before I try that, I am curious to test a theory. I came across a forum that talked about deleting unused kernels. My assumption is you can have multiple kernels installed and you can activate them. If this is correct, could I not just install a more recent kernel and migrate the server that way?

----------

## pietinger

 *chuckm wrote:*   

> [...] My assumption is you can have multiple kernels installed and you can activate them. If this is correct, could I not just install a more recent kernel and migrate the server that way?

 

Your assumption is correct. It is possible to install manually a new kernel and configure it. But this is not possible, if ...

 *chuckm wrote:*   

> One of the biggest problems I have is I've only been involved with Linux properly for the past 2-3 years and I still have gaps in my knowledge.

 

Because it is a server of your company I think downtime is an important factor and you will kill the server if you try what you want.

 *chuckm wrote:*   

> [...] I am curious to test a theory.

 

Yes, you should be.

As all others said before:

Take a second machine. Install a modern Linux with a recent kernel. Port your pbx+ to this server. Test it and make your boss happy  :Wink: 

----------

## NeddySeagoon

chuckm,

That old install is full of security problems. It should never be on the net.

Your old gcc probably won't build a modern kernel and if it did, the modern kernel and your old glibc probably won't work together.

If you really want to try sliding a new kernel under your old install. build the kernel elsewhere.

Copy its bzImage to the /boot on your old AWS install. Rename it if you want.

Edit /boot/grub/grub.config to add it as a boot option.

On the kernel build host, install the modules to some random location.

This will get you a directory /some/random/location/' uname -r'/.

Copy  'uname -r' to /lib/modules/ an the AWS instance. You must not change its name.

Now you have all the bits in place, reboot and choose the new kernel.

I expect to hear the crash in Scotland. :)

-- edit --

dd is unlikely to just work. The bits of grub that are installed outside of any filesystem will need to be reinstalled. Not rebuilt, just reinstalled for their new home.

/etc/fstab probably points to the the wrong things.

The kernel command line(s) in /boot/grub/grub.conf root entries will likely be incorrect.

----------

## chuckm

To clarify, the current server is hosted on an ESXi host and I have a clone of the server in question to run my tests.

I have no installation media, no upgrade path or support from the provider and the server has been running for at least for 6 years, without any updates. And that's 6 years I've been at the company.

What I am trying at the moment is to try and get this server working on AWS without much intervention which is why I am attempting the DD method. Otherwise, I agree, the ideal solution is to have a new host with updates version of Gentoo and migrate the application to that. I just wouldn't know where to begin. I assume I need to search for all installed packages and migrate anything relevant. The next problem might be compatibility with pbx and a more recent version of the packages.

My brain hurts...

----------

## Hu

If you are in a hurry to get this working, you could try booting an AWS VM with one of their standard Linux systems, and running your application in a chroot on that machine.  That would use their kernel, which they presumably keep current and correct for their virtual hardware.  You do run the risk that Neddy mentioned about glibc versus kernel, but I think that will probably not be an issue.  The Linux kernel is very good about backward compatibility, and a new kernel with old userspace is supposed to work.  Once you have the system running that way, you could duplicate it to have an AWS-hosted test platform, and update the packages in the chroot at your leisure.  This may be more convenient than updating your ESXi guest and repeatedly synchronizing successful results to the AWS VM.

However, I feel obliged to reiterate a point from above: if your system has been unmaintained for this long, it probably has at least some known security exploits due to old unpatched packages, so you should keep strict control over who can access it until you have it updated.

----------

## chuckm

OK. Progress. I have imaged the server, copied to AWS S3, added it to a Gentoo instance, dd'ed it onto another disk, took a snapshot of that disk and launched an instance from that. It boots BUT when I check console, I get;

Could not find the root block device in ...

Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skill...

I assume that the bootloader is messed up? Is there a way of me adding this disk to another instance and fixing this?

----------

## NeddySeagoon

chuckm,

The boot loader did it thing and loaded the kernel and initrd.

It passed root= ... to the kernel and the kernel started.

Could not find the root block device in ...  should give you a list of devices that he kernel can see.

The empty list reads  *Quote:*   

> Could not find the root block device in .

 is confusing.

In the boot loader configuration file the kernel command line root= needs to be changed.

How you do that depends on your boot loader.

Go back to your device list in 

```
Could not find the root block device in ...
```

Is one of then your root filesystem?

If not the kernel is missing a hardware driver.

I suspect your boot loader is grub. It has a command line editor and tab completion.

Select your kernel entry from the grub menu, then press 'e' for edit.

Follow the on screen instructions.

This is completely safe as only the in memory copy is being changed.

----------

## Jaglover

 *chuckm wrote:*   

> ...
> 
>  I need to find a way to update the current kernel, which I believe is a custom kernel.
> 
> 

 

Connecting the dots, custom kernel and no boot device found on new hardware. Missing kernel driver for new HDD controller.

----------

## chuckm

It was a driver issue but instead of editing GRUB, I changed the instance type to a different CPU architecture and it booted.

In summary, DD the disk to an image file, move to S3, move to instance, DD to another disk and snapshot that disk. Using the correct instance type, in my case T2.Small (It didn't work on T3), I was able to boot. I have some other problems but not relevant plus I can work them out since it's booted now.

Thanks for the help. Much appreciated.

----------

## chuckm

It turns out I can't.

The instance boots but now I am getting;

"ERROR: interface eth0 does not exist"

Ensure that you have loaded the correct kernel module for your hardware

ERROR: net.eth0 failed to start

ERROR: connect start netmount as net.eth0 would not start"

Is there a way to download the NIC drivers that AWS supports onto my cloned VM then image it or do I have to recompile the kernel to include supported drivers? If it's latter, can I build a kernel on AWS so I know it's compatible and import that onto my cloned VM and image the VM that way?

I've also read udev could be the reason why eth0 is not found and this might help with that, "touch /etc/udev/rules.d/80-net-name-slot.rules", but I had no luck.

The below link is to compile a kernel for AWS. Instead of going through that, I want to believe there is a way to add the AWS NIC drivers (or module?) to the current kernel?

https://www.artembutusov.com/gentoo-on-aws/

EDIT: Or, maybe more appropriate would be if I can use the current kernel as a baseline to create a new one as this is a custom kernel I am working with. Is this possible?

----------

## Jaglover

Your device may be renamed, 'ifconfig -a' will tell.

----------

## chuckm

```
eth0      Link encap:Ethernet  HWaddr 00:50:56:ab:8e:62  

          inet addr:172.16.1.224  Bcast:172.16.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:80887 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2762 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:5149056 (4.9 MiB)  TX bytes:387980 (378.8 KiB)

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:297 errors:0 dropped:0 overruns:0 frame:0

          TX packets:297 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:8200 (8.0 KiB)  TX bytes:8200 (8.0 KiB)
```

I believe that's not the case.

----------

## Jaglover

Well, it does exist, but it has private address which generally is given when there is no working connection. At this point you should be able to activate it by hand. It is weird, though, how comes interface not in use has transferred several megabytes.   :Confused: 

----------

## chuckm

This is on my cloned VM of the working production server at our datacentre. I've set it static IP, .224, and I am testing a few stuff on this cloned VM which explains the transfers. I have no console access at AWS so if NIC drivers for AWS is not working when I image this VM, I have to come back to this clone, make changes and reimage to AWS.

Although this is a custom kernel, Gentoo 3.7.8-pbx+, a kernel is just a layer between application and hardware so as long as I have a new working kernel with AWS supported hardware, it should interfere with my application right?

----------

## chuckm

For instance, on AWS, I have a working Gentoo instance with when I check kernel list "linux-4.19.86-gentoo *". Can I download the files for this kernel, add it to my clone and select this as the active kernel?

----------

## Jaglover

I've no experience with AWS, all I can tell you is if there is eth0 then the kernel driver is loaded and your problem lies elsewhere. You can see the driver loaded with 'lspci -k'. What is happening to your NIC is all in dmesg, maybe the net.eth0 runs too early, can't tell from here.

----------

## chuckm

I don't think you understood me. My bad for the bad explanation. 

- Current "Cloned VM" is on an ESXi host. Everything works fine.

- I use DD to image this VM to a "disk.img" file and using this file, I create an AWS instance.

- When the instance starts, the drivers that used to work on the ESXi host are not found for the network interface.

So, although eth0 is fine on the ESXi host, once imaged and moved to AWS, the same drivers are not what AWS supports which is why I get the error I get (eth0 does not exist. Ensure that you have loaded the correct kernel module for your hardware"

What I want to do now is to get a working kernel from an instance from AWS and move that to my VM on the ESXi host, reimage and move to AWS. I assume that would solve the NIC driver issue. The problem is, I am not sure how to go about doing that so I might try and build a kernel on a separate test VM just to understand the process and that might explain how to migrate a working kernel from one server to another.

----------

## Jaglover

Drivers must be compiled for running kernel and preferably by using the same toolchain which was used to compile the kernel. To see what driver is needed take the PCI ID from 'lspci -nn' output and find the correct driver at cateee.net, it is kernel driver database. Then reconfigure, rebuild and reinstall the kernel. If configured as a module you may get away easier, even reboot won't be needed. But you have to work with sources for kernel you are using. I recite, if the device node eth0 appears then the proper driver for it has been loaded. No driver - not eth0. In case your NIC is virtual you need to build a driver for this emulated hardware, not for real hardware. That's all I can tell you. You are correct, I do not understand what you are doing there.

----------

## chuckm

```
Ethernet controller [0200]: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) [8086:100f] (rev 01)
```

This is used on the VM on the ESXi host.

AWS instances need the following driver;

```
Ethernet controller [0200]: Amazon.com, Inc. Elastic Network Adapter (ENA) [1d0f:ec20]
```

I found the driver I need to include in the kernel: https://packages.gentoo.org/packages/net-misc/ena-driver

Any sources you can direct me to show me how to add this to my current kernel?

----------

## Jaglover

Normally you should just emerge it 'emerge ena-driver', emerge will build it against your kernel sources and install it properly. All you have to do is to load it by hand to start using it right away. Then add it to your system configuration to make it auto-load at boot. Since your system is so old I do not know what exactly you need to do for auto-load. 

The main problem here for you is - does emerge work? If emerge does not work then you need to get the driver sources from Amazon and build it by hand, I'm sure they have instructions for it.

----------

## Hu

As I read drivers/net/ethernet/amazon/Kconfig, the upstream Linux kernel has support for Amazon's Elastic Network Adapter, at least in the 5.9.x version that I checked.  There is no need to download sources separately.  Just enable ENA_ETHERNET in menuconfig, rebuild, and go.

Even so, I think you ought to do like I suggested above: start with an AWS instance and upload to it a chroot containing your legacy Gentoo system.  This will get you a fully functioning AWS instance that knows how to use all the features that Amazon provides.  Even if you are determined to use your custom kernel, I think you could iterate much faster if you used an AWS instance like we would normally use a LiveCD:Create a helper AWS instance, call it aws-01.Name the to-be-production AWS instance aws-p.Name your local ESXi clone vmw-01.Grant vmw-01 the ability to ssh to aws-01 as root.Attach to aws-01 the root drive for aws-p.Make a change in vmw-01.Rsync your changes to aws-01, thus updating the root drive of aws-p.  Since aws-01 is built off Amazon Linux, you can get it to boot and use the network easily.Sync the changes to the drive, and unmount the filesystem.Detach the drive from aws-01.Attach the drive to aws-p.Try to boot.  If it fails, halt the instance, move the drive back to aws-01, and go to step "Make a change".This avoids the need to dd the entire drive twice every time you need to make a change.

----------

## chuckm

hu, I don't need to use this old kernel as long as my application works. As I mentioned above, my downfall is my Linux experience so I am having to learn much of it as I go along so chroot is a foreign term for me. However, I did some research and I understand how it works, I think. With that said, I have the following set up on my current VM;

```
   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        3906      203125       99610   83  Linux

/dev/sda2          203126     4298828     2047851+  83  Linux

/dev/sda3         4298829    24777343    10239257+  83  Linux

/dev/sda4        24777344   524287999   249755328   83  Linux

/dev/sda1: LABEL="BOOT1" UUID="dc302d25-31f9-450c-8de6-09466fdc78ba" TYPE="ext2" 

/dev/sda2: LABEL="SWAP1" UUID="b8a6063f-2242-4d27-a45e-1fbfa1764cce" TYPE="swap" 

/dev/sda3: LABEL="ROOT1" UUID="b9a7ab74-480d-4d35-8227-8d2e8397af9f" TYPE="ext4" 

/dev/sda4: LABEL="HOME1" UUID="8a4938c9-4a39-4280-831a-bf2e5639b8cb" TYPE="ext4" 
```

sda4 is where the application is installed. At least it's where the data is. How do I ensure I keep the same partition structure with chroot?

----------

## NeddySeagoon

chuckm,

You put the filesystem tree together by hand inside what will become the chroot.

Finest gentoo tradition says you do

```
mkdir /mnt/gentoo
```

this will become the root of your gentoo. 

Mounting order is important.

/dev/sda3 is root, so that gets mounted first at  /mnt/gentoo

All the other mount points are below that.

/dev/sda1 is boot so that gets attached at /mnt/gentoo/boot

/dev/sda2 is swap. If you want to use it its 

```
swapon /dev/sda2
```

There is no filesystem there so it cannot be mounted.

The next one is a guess but keep reading.

/dev/sda4 is /home ... maybe.

It gets mounted at  /mnt/gentoo/home

You will have a file  /mnt/gentoo/etc/fstab after root is mounted.

It will tell you what goes where. Its normally read by the localmount service to do what you have just done.

With everything in the right place, you can do 

```
chroot /mnt/gentoo /bin/bash
```

and everything at the /mnt/gentoo/ level will vanish and you are in your gentoo.

You will want to do

```
source /etc/profile

env-update
```

if you intend to use emerge.

```
export PS1="(chroot) ${PS1}"
```

is useful to remind you that you are in the chroot.

----------

## chuckm

I don't fully understand the chroot method so I won't attempt that until I can get my head around it, however, I found this https://www.man42.net/blog/2017/07/how-to-migrate-a-debian-server/, which I believe might do the trick. Attempt one has partially failed as on Gentoo, the NIC is names eth0 and I cannot find a way to change that. So plan 1 is to find a way to change the NIC name.

Plan 2 is to install a new version of Gentoo on a separate VM and try what's on the article. Since it's an updated version, I believe I can download and install AWS NIC drivers.

Let's see how that goes.

----------

## chuckm

So, I have installed the latest version of Gentoo on a VM after some tinkering with the kernel. All works fine.

The problem is when I run rsync from the old Gentoo to the new one as below;

```
rsync -a --delete --numeric-ids --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/etc/fstab","/etc/udev/rules.d/*","/etc/network/*","/lib/modprobe.d/*"} /mnt/readonly/ root@172.16.1.66:/mnt/new_server/
```

Once restarted, my network access is gone. "Interface eth0 does not exist".

The interface name before rsync was eno16780032 so I must be coping over network folders which is breaking it.

ifconfig returns "lo" only. ip a returns eno16780032 but is down.

Is there a folder to exclude or copy out of the folders I am synchronising to copy back in? Can I rename interfaces from eth0 to eno16780032? Can I remove network related configuration and reload from kernel drivers which was already working?

----------

## NeddySeagoon

chuckm,

What does 

```
dhcpcd eno16780032
```

do?

It should bring up eno16780032 until the lease expires.

I suspect your network starup scripts try to start eth0 instead of eno16780032 or vice versa.

Its a feature of udev that swapped one set of corner cases for another and upset most udev users on the way.

What does 

```
rc-update -v show | grep net
```

tell?

----------

## chuckm

```
dhcpcd: command not found
```

I believe this is because the rsync command I am running is overwriting these libraries?

rc-update -v show | grep net

```
net.eth0 | 

net.lo  | boot

netmount |       default
```

Just to clarify, anything from my old Gentoo server apart from below is being written to my new gentoo server with rsync

```
"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/etc/fstab","/etc/udev/rules.d/*","/etc/network/*","/lib/modprobe.d/*""
```

----------

## Tony0945

Just want to interject that if you have only one ethernet card (or built-in), the usual case in a PC, you can add "net.ifnames=0" to grub or to the kernel's internal command line and that interface will be eth0.

```
 $ zgrep ifnames /proc/config.gz

CONFIG_CMDLINE="net.ifnames=0 mitigations=off"

```

 The "mitigations=off" part is unconnected. You probably don't want to do that. I'm squeezing all the performance I can from this old CPU.

----------

## NeddySeagoon

chuckm,

Odd, net.eth0 is not in any runlevel ... so how did it get started?

It should be in the default runlevel

You can either go with what Tony0945 suggested and put net.ifnames=0 on the kernel command line, so the interface is not renamed, or track down everywhere that eth0 is used and change in to the new name. 

The dhcpcd command is optional. Its unusual but not wrong for it to be missing. Lets try busybox.

```
busybox udhcpc eno16780032
```

should do the same thing.

That eno16780032name is dynamic. It's fixed on any install (mostly) but when you image an install from one place to another it will change.

----------

## chuckm

```
busybox udhcpc uno16780032

udhcpc: SIOCGIFINDEX: No such device
```

No luck. 

The issue must be due to the age of the old server. I am rsync'ing from a 7-year-old Gentoo server that has not been updated or maintained in any way. Could this affect libraries, portage, grub udev etc?

----------

## NeddySeagoon

chuckm,

```
busybox udhcpc uno16780032 
```

There is a typo there. You show uno1... its eun1...

----------

## chuckm

My bad. That was a typo on the forum. I am having to use vmware console so I can't copy paste -_- I did "busybox udhcpc eno16780032"

----------

## NeddySeagoon

chuckm,

```
No such device
```

say that the interface called eno16780032 does not exist.

What does 

```
ifconfig -a
```

show?

Try the network interface name listed there.

----------

## chuckm

I have sit0 and lo additionally

EDIT: I get the same response if I try lo and sit0 too

----------

## NeddySeagoon

chuckm,

It that case the driver for your network card is missis from the kernel, or its a module and not loaded.

lo is the 'hardwired' interface that your system uses to talk to itself on the network.

sit0 is the end point for a IPv6 tunnel over IPv4. Its not a real interface.

What does 

```
lspci -nnk
```

 say about ethernet?

```
lspci -nnk | grep -A4 -i ethernet

09:06.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller [10ec:8169] (rev 10)

   Subsystem: Realtek Semiconductor Co., Ltd. RTL8169/8110 Family PCI Gigabit Ethernet NIC [10ec:8169]

   Kernel driver in use: r8169
```

I think your Kernel driver in use: line will be missing.

I only need the numbers in square brackets at the end of the first line. Here that's  [10ec:8169].

That's the Vendor and Device IDs.

You can do this  :) 

Put 

```
10ec:8169 linux kernel
```

into google. You use your own numbers.

Look for a hit at cateee.net, which is the kernel database.

Read the Help Text.

For me it says

```
Say Y here if you have a Realtek 8169 PCI Gigabit Ethernet adapter.

To compile this driver as a module, choose M here: the module will be called r8169. This is recommended.
```

Now you know what the module is called, what does modprobe <module_name> do?

The right answer is it silently returns to the prompt.

Now try 

```
ifconfig -a
```

again.

----------

## chuckm

```
Ethernet controller [0200]: VMware VMXNET3 Ethernet Controller [15ad:07b0] (rev 01)

        DeviceName: Ethernet0

        Subsystem: VMware VMXNET3 Ethernet Controller [15ad:07b0]

        Kernel driver in use: vmxnet3

      VMware's vmxnet3 virtual ethernet NIC
```

Here is what I get and the cateee.net id is same as kernel driver in use.

Before rsync from the old server, the network device worked fine. So the kernel is loaded correctly which is why I think it's the rsync I run that overwritten some of the network folders. The flags I used for rsync would have deleted any files/folders that was not in the source(7 year old Gentoo)

----------

## NeddySeagoon

chuckm,

With the driver loaded and no errors in dmesg related to eth0, or its new name, the interface should appear in 

```
ifconfig -a
```

Until it appears there, it cannot be configured. 

Try 

```
dmesg | grep eth0
```

if it never appears, that's a kernel problem. 

It will appears as eth0 before it gets renamed, so there should be at least two hits.

Use 

```
dmesg | less
```

to read around the timestamps for the eth0 hits, looking for errors.

----------

## chuckm

That's it. dmesg confirmed that the NIC was being renamed. I found a forum from one of my already open tabs and created an empty /etc/udev/rules.d/80-net-name-slot.rules, rebooted and problem solved. it's infuriating because I've created 20- or 70- of these files and it didn't help. I assume that these are different versions of udev?

Thanks a lot! Now that network is running, let's see if my web application is accessible.

----------

## NeddySeagoon

chuckm,

Yeah. That's probably it very old udev bound names to MAC addresses,

As the MAC address is the clones new home would be different to the old one, if it was eth0 in its old home it would become eth1 in its new home as udev would spot that the MAC address had changed.

New udev does naming by PCI bus,slot and function. An least, it starts out that way. I don't know where that eno16780032 name came from.

I turn off "Persistent Device Names" here anyway, so I don't suffer from them.

----------

## Tony0945

The udev empty rules file works too. I prefer the kernel command line method.

A third way us to use a udev rule to rename it, not to eth anything, but another name that you use as a convention like lan0, or wan0 or (probably) mylan0. I'm pretty sure a number is needed (that's zero not Oh). I can get an example if you want. Right now that computer is shut down and physically far. If you google NeddySeagoon,k6,  tony0945, formus.gentoo and "PC as a router" You might find the thread that has it in it.  Thread contains many words of wisdom from neddyseagoon of general interest also.Or find another example on the web. If really interested, I'll fire up that computer. 

I have found that using a name like Eth0 is not good. Apparently somewhere it's case insensitive.

----------

## Hu

 *chuckm wrote:*   

> That's it. dmesg confirmed that the NIC was being renamed. I found a forum from one of my already open tabs and created an empty /etc/udev/rules.d/80-net-name-slot.rules, rebooted and problem solved. it's infuriating because I've created 20- or 70- of these files and it didn't help.

 If I recall correctly, udev treats files in that directory as higher priority replacements for files of the corresponding name in its shipped directory.  Therefore, if you want to override a shipped udev rule, you must create the replacement file with exactly the same name as the file to be overridden.  In your install, the file to be overridden started with 80-, which is why your earlier attempts had no effect.

----------

## chuckm

Tony0945, I failed at kernel command line. Not sure if it was me doing something wrong or system corruption somewhere as I do have issues with some functions still. 

Is there a way of me testing core functionality? I believe with rsync, portage also synced from my old server to the new. 

For example, I can't emerge anything at the moment. I get;

```
/etc/make.profile is not a symlink and will probably prevent most merges. !!! It should point into a profile within /usr/portage/profiles/
```

And running "eselect profile list" returns nothing.

This is just one of the problems I just started working on but I am sure there will be others.

----------

## NeddySeagoon

chuckm,

Is this on your old install or the new one?

/etc/make.profile suggests that its the old one an that moved to /etc/portage/make.profile years ago.

There was no eselect profile then either. The profile was changed by using the ln command.

That still works.

What version of portage do you have installed?

```
emerge --info
```

will show it in the first line unless portage shouts at you about a needed update.

```
portage 3.0.8 (python 3.7.9-final-0, default/linux/amd64/17.0/no-multilib, gcc-10.2.0, glibc-2.32-r2, 5.9.2-gentoo x86_64)
```

----------

## chuckm

here is the output;

```
Portage 2.1.11.50 (unavailable, gcc-4.5.4, glibc-2.15-r3, 5.4.72-gentoo x86_64)
```

----------

## NeddySeagoon

chuckm,

The unavailable in your output is a placeholder for your profile.

That predates 

```
eselect repository
```

You should have profiles in 

```
/usr/portage/profiles
```

That assumes that your PORTDIR is set to the default location.

If you manage to 

```
emerge --sync
```

then you old system will not be able to read new ebuilds.

You won't be able to get a new portage because that needs a newer python, which you old portage won't understand.

Updating an old system like you have is a wonderful learning opportunity. It can be done.

Before we get into the how, what do you want to do with this old system that now has a  5.4.72-gentoo under it?

Once we know that, there may be more time efficient way to get the same result. It won't be as much fun nor so educational but that not always at the top of the list.

What does 

```
grep -i started /var/log/emerge.log | tail -n20
```

tell?

I'm looking for a date several years ago to knom when your system war last maintained.   Use larger numbers of -n if you need to. 

/var/log/emerge.log is a root only file.

----------

## chuckm

```
eselect repository
```

returns nothing

The main reason for using rsync from the old Gentoo to the new one I built is because I needed a newer kernel to migrate to AWS. That's why I built a Gentoo kernel so it would allow me to emerge AWS NIC drivers. However, that seems to be an issue now since emerge doesn't work after rsync.

With that said, the application I am running uses httpd and I believe all application data is on a separate partition, /home/opt/. httpd is here, and my application is here. I wonder if I could have just moved this partition to a new Gentoo I built without rsync, find all dependencies and install separately. I didn't think rsync would move system data over that would cause problems.

Either way, I have learnt a massive amount since I started this  :Smile: 

```
grep -i started /var/log/emerge.log | tail -n20

1361803150: Started emerge on: Feb 25, 2013 14:39:10

1361803176: Started emerge on: Feb 25, 2013 14:39:36

1361803208: Started emerge on: Feb 25, 2013 14:40:08

1361803256: Started emerge on: Feb 25, 2013 14:40:55

1361803267: Started emerge on: Feb 25, 2013 14:41:07

1361803283: Started emerge on: Feb 25, 2013 14:41:22

1361803302: Started emerge on: Feb 25, 2013 14:41:42

1361803315: Started emerge on: Feb 25, 2013 14:41:55

1361803321: Started emerge on: Feb 25, 2013 14:42:01

1361803364: Started emerge on: Feb 25, 2013 14:42:44

1361803391: Started emerge on: Feb 25, 2013 14:43:10

1361803407: Started emerge on: Feb 25, 2013 14:43:26

1603923713: Started emerge on: Oct 28, 2020 22:21:52

1606210510: Started emerge on: Nov 24, 2020 09:35:10

1606211723: Started emerge on: Nov 24, 2020 09:55:23

1606211916: Started emerge on: Nov 24, 2020 09:58:36

1606214500: Started emerge on: Nov 24, 2020 10:41:39

1606214612: Started emerge on: Nov 24, 2020 10:43:32

1606214657: Started emerge on: Nov 24, 2020 10:44:16

1606214757: Started emerge on: Nov 24, 2020 10:45:57
```

----------

## NeddySeagoon

chuckm,

Your install, or most of it, is from or just before Feb 25, 2013 14:43:26.

What does 

```
ls /usr/portage/profiles/default/linux/amd64/
```

tell?

I get

```
$ ls /usr/portage/profiles/default/linux/amd64/

17.0/             eapi              parent            

17.1/             package.use.mask
```

but my last emerge --sync was only a week or two ago.

That 17.0 directory is a list of 17.0 profiles, now obsolete and in the process of being removed.

17.1 is the replacement profile.

What does 

```
readlink /etc/pofile
```

 say?

Is it missing entirely or is it present but dangling, pointing to a profile that has been removed?

Hopefully its the latter. We need to know what it points to so it can be updated.

If its a normal healthy symbolic link, 

```
ls /etc 
```

will show in is cyan.

When it points to something that does not exist, its flashing red.

----------

## chuckm

```
ls /usr/portage/profiles/default/linux/amd64/
```

there is nothing in the /usr/portage directory

```
readlink /etc/pofile
```

returns nothing

```
ls /etc
```

returns

```
DIR_COLORS            eclean            iproute2        make.conf           profile.env       snmp

asterisk              eixrc             issue           make.conf.catalyst  protocols         ssh

bash                  env.d             issue.logo      make.profile        rc.conf           ssl

beecrypt.conf         environment       issue2.logo     man.conf            resolv.conf       ssmtp

ca-certificates       etc-update.conf   kernel          mdadm.conf          revdep-rebuild    sudoers

ca-certificates.conf  filesystems       layman          mime.types          rmt               sudoers.d

conf.d                fstab             ld.so.cache     mke2fs.conf         rpc               sysctl.conf

config-archive        gai.conf          ld.so.conf      modprobe.d          rsyncd.conf       sysctl.d

cron.d                genkernel.conf    ld.so.conf.d    mtab                runlevels         syslog-ng

cron.daily            gentoo-release    local.d         nanorc              sandbox.conf      sysstat

cron.deny             gpm               locale.gen      networks            sandbox.d         sysstat.ioconf

cron.hourly           group             localtime       nscd.conf           sangoma_mgd.conf  terminfo

cron.monthly          group-            login.defs      nsswitch.conf       screenrc          udev

cron.weekly           grub.d            lognot.conf     ntp.conf            securetty         vim

crontab               gshadow           logrotate.conf  ntpd.conf           security          vmware-tools

csh.env               gshadow-          logrotate.d     pam.d               services          vservers

default               host.conf         lvm             passwd              sgml              wanpipe

dispatch-conf.conf    hosts             lxc             passwd-             shadow            wgetrc

dmtab                 init.d            lynx.cfg        pbxware.version     shadow-           xdg

drbd.conf             initramfs.mounts  lynx.lss        portage             shells            xinetd.d

drbd.d                inittab           mail            profile             skel              xml

e2fsck.conf           inputrc           mailcap         profile.d           slsh.rc
```

make.profile is an archive file... highlighted red.

I still have a snapshot of the new Gentoo before the rsync and it's the same thing, however, emerge works, even though I get "masked by amd64" error but I assume that I can find the way to unmask that. Not sure if this info helps

----------

## chuckm

I am able to solve "masked by amd64" by adding the category/packagename to the accepted keywords

----------

## chuckm

Also, emerge --info returns the following on the Gentoo pre rsync;

```
Portage 3.0.9 (python 3.7.9-final-0, default/linux/amd64/17.1/hardened, gcc-9.3.0, glibc-2.32-r2, 5.4.72-gentoo x86_64)
```

----------

## NeddySeagoon

chuckm,

```

Portage 3.0.9 
```

is the current portage.

You previously posted 

```
Portage 2.1.11.50 
```

portage-3.0.9 expects to find all its configuration files in /etc/portage.

portage 2.1.11.50 uses a mix of /etc and  /etc/portage

The default location for the gentoo repo changed too.

On old installs its /usr/portage/

On new installs its /var/db/repos/gentoo/

You are also free to set your own locations.

On old installs, its defined by PORTDIR= in make.conf.

make.conf will either be in /etc/ or /etc/portage. A few unlucky people may have both. Portage used to flag that.

On newer installs its defined in /etc/portage/repos.conf/gentoo.conf

I'm not sure what was rsynced any more.

make.profile should not be a file, wherever it is.

What are the permissions on /etc/make.profile ?

```
ls -l  /etc/make.profile
```

=== edit ===

Paste the entire output.

----------

## chuckm

NeddySeagoon, I was just trying to give you some information of the system before I run the rsync to copy root from old to the new server.

Before I run the rsync, the Portage version was showing as 3.0.9.

After I run rsync, it changed to 2.1.11.50 which was copied along with root and probably the cause of many problems. Maybe I should have excluded more folders for Gentoo as I used a debian rsync tutorial.

The ls -l /etc/make.profile returns

```
lrwxrwxrwx 1 root root 46 Jul 22  2014 /etc/make.profile -> ../usr/portage/profiles/default/linux/x86/13.0
```

/etc/make.profile and ../usr/portage/profiles/default/linux/x86/13.0 is highlighted red

----------

## NeddySeagoon

chuckm,

```
/etc/make.profile -> ../usr/portage/profiles/default/linux/x86/13.0
```

is a relative symbolic link.

When portage goes to  /etc/make.profile to find your profile its redirected to ../usr/portage/profiles/default/linux/x86/13.0.

The ../ means the parent directory, in this case /

So the redirect is to  /usr/portage/profiles/default/linux/x86/13.0 which is missing. It was removed when the migration to the 17.0 profiles was completed.

The x86 tells that you have a 32 bit install. a 64 bit install would be amd64 there.

A 32 bit install on top of a 64 bit kernel works but it can't build its own kernel as the 32 bit compiler cannot emit 64 bit code.

That was common on some architectures but not an AMD/Intel You needed a special kgcc to build the kernel.

You say that  /usr/portage/profiles/ does not exist?

What about /var/db/repos/gentoo/profiles ?

There should be a  default/linux/x86/17.0 in there.

On your original old install, what does 

```
gcc -v
```

 output?

----------

## chuckm

ls /var/db return

```
Makefile  pkg  sudo
```

EDIT: gcc -v

```
Using built-in specs.

COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.5.4/gcc

COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.5.4/lto-wrapper

Target: i686-pc-linux-gnu

Configured with: /var/tmp/portage/sys-devel/gcc-4.5.4/work/gcc-4.5.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.5.4 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.5.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.5.4/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.5.4/python --enable-checking=release --disable-libgcj --with-arch=i686 --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.4 p1.0, pie-0.4.7'

Thread model: posix

gcc version 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7) 

```

----------

## NeddySeagoon

chuckm,

```
COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.5.4/gcc
```

Confirms that its a 32 bit install.

When you did the AWS install was that x86 or amd64?

AMD 64 installs have a different on disk layout to x86, so copying one onto the other is not a good idea.

I'm starting to loose track. CAn you post a summary of what you have done so far please and where you want to get to?

----------

## chuckm

Let's not worry about AWS right now because that was my attempt to migrate with just DD but I run into the problem with network adapter not being recognised.

So, I started from scratch.

Old Gentoo - This is a clone of the production server. It has not been updated for the past 7 years. 

- 32-bit Gentoo

- Portage 2.1.11.50

New Gentoo - This is a Gentoo that I installed from scratch.

- AMD64

- Portage 3.0.9

Now, I needed to migrate data from the "Old Gentoo" to the "New Gentoo". To do this, I followed this blog. https://www.man42.net/blog/2017/07/how-to-migrate-a-debian-server/ - The last step, "Install grub on your new server" I couldn't complete because grub-install fails. Though, I don't think this is a problem?

I've changed the rsync command that I needed to run. I also run the command from the "Old Gentoo" server instead of the "New Gentoo" as the blog recommended. I just changed the source/destination in the command.

The command I used is;

```
rsync -a --delete --numeric-ids --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/etc/fstab","/etc/udev/rules.d/*","/etc/network/*","/lib/modprobe.d/*"} /mnt/readonly/ root@172.16.1.66:/mnt/new_server/
```

Once the command run, I rebooted the server and run into the problem with eth0 not found which we were able to rectify by creating an empty rules file /etc/udev/rules.d/80-net-name-slot.rules.

This is where we are.

I am not able to access the web console of my application and it seems to be working fine.

However, I just wanted to confirm the functionality of this server as rsync seems to have copied over system files that confused me and the "New Gentoo". Although everything seems to be working on my application, commands like "eselect profile list" returns nothing. Though, I was able to emerge NTP client.

----------

## NeddySeagoon

chuckm,

You have copied over /etc/ and /etc/portage from the old server to the new server as well as all of /var anu /usr,

That pretty much wiped out the new install.

You copied over /usr and /var. /usr is where most of the binary bits of your install live, so most of your new install is gone.

/var is where portage keeps track of what is installed. Your profiles are there in the new install but not in the old one.

Your app will be quite happy as everything it needed was coped over, destroying the new install.

Its probably not possible to just copy over from a x86 to amd64 install because of the changed on disk layout.

Some thing are just bound to break because they have internally hard coded paths that will be incorrect after the move. 

You need to do your amd64 install, then build your application there. If you are really really lucky, there will be an ebuild for your application in a local overlay on the old install.

Look in the old make.conf for an entry  

```
PORTDIR_OVERLAY="...
```

If you know all the filenames to move, you can try moving only those files, taking into account the on disk layout changes.

Rather than an exclude list, you need to copy only what is needed.

```
lddtree /path/to/your/executable/file
```

will tell all the libraries it needs.

Don't copy them if they are provided by portage.

Well behaved applications, not installed by the package manager, should go into /usr/local, or possibly /opt.

The applications data can be anywhere. /home, /var, /etc, /usr/local ...

If the app runs as its own user, /home/<app_username> is worth looking at.

----------

## chuckm

Would this rsync have overwritten the new built Gentoo kernel? If so, what folder is the kernel data saved? 

Since the application is working, I can try and sync again without the portage and kernel folders.

 *Quote:*   

> You need to do your amd64 install, then build your application there

 

I don't feel too comfortable with that. I know that the application is installed under /home/opt as I can see folders for httpd and my web application but there are many dependencies and web configuration. I remember looking at the rc logs and many services start that I am not familiar with. This is why I was hoping to be able to sync or clone in some way to avoid manually building the application on a new server.

----------

## NeddySeagoon

chuckm,

The kernel sources live in /usr/src

There can be lots of kernel source trees there. The one of interest is usually pointed to by the linux symlink.

```
$ ls -l /usr/src/

total 12

lrwxrwxrwx  1 root root   18 Oct 31 20:32 linux -> linux-5.9.2-gentoo

drwxr-xr-x 21 root root 4096 Sep 28 21:03 linux-5.7.4-gentoo

drwxr-xr-x 25 root root 4096 Oct 29 20:46 linux-5.8.0-gentoo-r1

drwxr-xr-x 25 root root 4096 Nov 16 21:28 linux-5.9.2-gento
```

Its unusual but not impossible to load the kernel from there.

The kernel binary is usually installed into /boot, since that the default location for the boot loader to find it.

The kernel modules go into  /lib/modules/`uname -r` which your rsync will have deleted.

Well it will have removed the and64 kernels modules anu put the old kernel modules into /lib/modules instead.

Its safe to copy over /home/opt and try to run the app from its new home. It will tell what it can't find, one piece at a time.

Hence 

```
lddtree /hom/opt/<app_name>
```

is a good place to start. 

We can check that everything the binary wants can be found.

----------

## chuckm

Sorry, I didn't write back sooner but I am testing migration through their backup/restore feature. This was not an option before because they said they do not provide installation for the application as it's old so I found it in their archives!

Just installed it on AWS and about to test backup/restore. I don't see why it shouldn't work as it's the same version.

I really appreciate taking your time to help. I was close to paying you to see if you could do figure it out over SSH   :Very Happy: 

----------

## NeddySeagoon

chuckm,

I don't do Gentoo for money, its all for fun and I enjoy a challenge. Your migration is a challenge. :)

I suspect that your old binaries will not play nicely with modern libraries but you won't know until you test.

----------

