View previous topic :: View next topic |
Author |
Message |
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 9:49 am Post subject: need to make new initramfs for new CPU. How to do it? |
|
|
So, I messed up everybody! I built a new computer -- new CPU, new mobo, etc., but with old drives -- and didn't recompile the initramfs for the new CPU architecture. Now I can't boot, because it gives me a kernel panic ("bad opcode," etc. etc.), I have a laptop, so I'm downloading an ISO of SystemRescueCD to boot into. Here's my problem:
I have /use and /var both inside a RAID array on an LVM. From what I've seen, "better initramfs" (here) does not support pre-mounting /var from separate LVM.
So once I'm booted into SystemRescueCD, what initramfs do I need to use? From what I've seen, busybox no longer works, because some of its dependencies can no longer be built with static-libs (am I wrong about that?). What other options are there?
Thanks for the help!
EE |
|
Back to top |
|
|
soundrolf Tux's lil' helper
Joined: 08 Sep 2016 Posts: 122 Location: Cologne / Germany
|
Posted: Wed Nov 24, 2021 11:45 am Post subject: |
|
|
You can do it with:
Code: |
genkernel --install initramfs
|
Regards
soundrolf _________________ Regards
soundrolf
Mobo: ASUS PRIME B550M-K BIOS 3302 08/01/2023
CPU: AMD Ryzen 7 5800X 8-Core Processor (16) @ 3800 MHz
GPU: AMD Caicos Radeon HD 6450/7450/8450 / R5 230 OEM 1GB DDR3
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 12:42 pm Post subject: |
|
|
Here's the problem: I upgraded from an AMD FX chip to a Ryzen. The new machine won't boot. I've booted onto a SystemRescueCD on a USB drive, but I can't chroot into the old environment because /bin/bash doesn't work on the new machine. Is there a way to chroot into the old filesystem while still using the /bin/bash from the usb drive? I need to re-emerge … well, probably my entire system set, but I can't do that on a different machine (nor can I do it on the old machine, because the HDDs and some other parts are in the new one now).
Thanks!
EE |
|
Back to top |
|
|
soundrolf Tux's lil' helper
Joined: 08 Sep 2016 Posts: 122 Location: Cologne / Germany
|
Posted: Wed Nov 24, 2021 12:58 pm Post subject: |
|
|
Quote: |
Is there a way to chroot into the old filesystem while still using the /bin/bash from the usb drive?
|
No. You have to use /bin/bash from new system. Only then you are in the new system.
I think it's better to setup a complete new system, with a minimal-install cd gentoo.
Because the old system with a new motherboard and cpu may wipe you out of chroot.
Regards
soundrolf _________________ Regards
soundrolf
Mobo: ASUS PRIME B550M-K BIOS 3302 08/01/2023
CPU: AMD Ryzen 7 5800X 8-Core Processor (16) @ 3800 MHz
GPU: AMD Caicos Radeon HD 6450/7450/8450 / R5 230 OEM 1GB DDR3
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 12:59 pm Post subject: |
|
|
ExecutorElassus wrote: | The new machine won't boot. | Then ExecutorElassus wrote: | I've booted onto a SystemRescueCD on a USB drive, | So did your new machine able to boot with SystemRescueCD? ExectorElassus wrote: | but I can't chroot into the old environment because /bin/bash doesn't work on the new machine. | Are you saying once you booted with SystemResueCD, the /bin/bash on SystemResueCD not able to run with your new machine?
SystemResueCD have boot options to run in ram. You can try with option break in kernel boot command line, this should bring up and shell prompt and let you recover from there. |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 1:11 pm Post subject: |
|
|
I can boot the machine from SystemRescueCD and get to a prompt. I can mount all the drives and everything. What I can't do, at this point, is chroot into the old filesystem on the new architecture.
what changes do I need to make to [newroot]/etc/portage/make.conf for the new architecture? What tools do I use to find this information?
Assuming I just do a fresh install: I can download the stage3 tarball and just unpack it into /mnt/gentoo, right? How much of my old config do I need to back up? Or is it enough just to unpack the tarball, and use that to emerge the system files to get it to the point where it's bootable?
Cheers,
EE
Follow-up: is this guide a reliable one? Because if that's the case, I can also just rebuild system packages on a rescue partition and copy them over. Or is it better to unpack a stage3 tarball onto my broken system? |
|
Back to top |
|
|
soundrolf Tux's lil' helper
Joined: 08 Sep 2016 Posts: 122 Location: Cologne / Germany
|
Posted: Wed Nov 24, 2021 2:14 pm Post subject: |
|
|
Quote: |
What I can't do, at this point, is chroot into the old filesystem on the new architecture.
|
New architecture. Not the old one.
Quote: |
what changes do I need to make to [newroot]/etc/portage/make.conf for the new architecture?
|
Copy your old make.conf onto a usbstick. Change the CPU_FLAGS to your Ryzen CPU
Install app-portage/cpuid2cpuflags to get your CPU_FLAGS from your Ryzen CPU
Quote: |
How much of my old config do I need to back up?
|
Copy your /etc/portage directory onto a usbstick and have a look what you need for your new system and edit files to your need
Quote: |
I can download the stage3 tarball and just unpack it into /mnt/gentoo, right?
|
Yes unpack it into /mnt/gentoo
Read the handbook https://wiki.gentoo.org/wiki/Handbook:AMD64
Regards
soundrolf _________________ Regards
soundrolf
Mobo: ASUS PRIME B550M-K BIOS 3302 08/01/2023
CPU: AMD Ryzen 7 5800X 8-Core Processor (16) @ 3800 MHz
GPU: AMD Caicos Radeon HD 6450/7450/8450 / R5 230 OEM 1GB DDR3
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 2:38 pm Post subject: |
|
|
Hi sounroif,
I can't install programs (in this case, cpuid2cpuflags) until I can chroot. Should I just comment out the line for the CPU_FLAGS in make.conf? Is CFLAGS="-mtune=native -O2 -pipe" correct?
so, copy /mnt/gentoo/etc/portage somewhere safe
cd /mnt/gentoo
wget [tarball]
'tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner'
restore /mnt/gentoo/etc/portage
and then I should be able to chroot?
Cheers,
EE |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 2:45 pm Post subject: |
|
|
- Boot into SystemRescueCD shell
- Mount old drive's rootfs to /mnt/getoo
- cp -rp /mnt/gentoo/etc/portage to /some/where/writable/
- Mount rest partitions
- Mount all pseudo file systems, i.e. /proc, /sys, /dev (if you use devtmpfs)
- untar stage3 into /mnt/gentoo
- cp -rp /some/where/writable /mnt/gentoo/etc/porage
- update /mnt/gentoo/etc/portage/make.conf, set COMMON_FLAGS="-march=native -O2 -pipe"
- cp /etc/resolve.conf /mnt/gentoo/etc/resolve.conf
- chroot /mnt/gentoo
- emerge -a @world
- emerge genkernel
- genkernel all --menuconfig
- verify /boot got the new kernel and initramfs
- configure boot loader use new kernel with initramfs
- reboot
Use -march=native should give you correct CPU setting for your new CPU. |
|
Back to top |
|
|
soundrolf Tux's lil' helper
Joined: 08 Sep 2016 Posts: 122 Location: Cologne / Germany
|
Posted: Wed Nov 24, 2021 3:05 pm Post subject: |
|
|
This is my make.conf
Code: |
# Compiler Settings
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
# CPU FLAGS: AMD FX(tm)-6100 Six-Core Processor CPU Family: 21
CPU_FLAGS_X86="aes avx fma4 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop"
CHOST="x86_64-pc-linux-gnu"
# USE flags
USE="truetype elogind -consolekit -ipv6 -kde -gnome -systemd -pulseaudio
smp usb alsa v4l -aim -infiniband -cjk -qt4 icu -oci8 -oscar -joystick
-libav ffmpeg dbus dvd dvb cdr nls sockets twolame usb X udev udisks
libnotify thunar xinerama qt5 -xscreensaver vdpau ${CPU_FLAGS_X86}"
# USE_EXPAND flags
PORTDIR="/usr/portage"
PORTAGE_LOGDIR="/var/log/portage_log"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
MAKEOPTS="-j6"
GENTOO_MIRRORS="http://mirror.netcologne.de/gentoo/ https:ftp.halifax.rwth-aachen.de/gentoo/"
ACCEPT_LICENSE="*"
ACCEPT_KEYWORDS="amd64"
LINGUAS="de"
L10N="de"
LC_MESSAGES="C"
GRUB_PLATFORMS="pc"
LLVM_TARGETS="X86-64 AMDGPU"
VIDEO_CARDS="fbdev radeon nouveau v4l vesa amdgpu"
ALSA_CARDS="hda-intel"
INPUT_DEVICES="evdev synaptics"
KDIR="/usr/src/linux"
XFCE_PLUGINS="menu clock trash"
RUBY_TARGETS="ruby26 ruby27"
# EMERGE_DEFAULT_OPTS="--quiet-build"
# EMERGE_DEFAULT_OPTS="--with-bdeps=y"
|
Do it like pingtoo wrote
Don't forget before reboot to do Code: | grub-mkconfig -o /boot/grub/grub.conf |
Regards
soundrolf _________________ Regards
soundrolf
Mobo: ASUS PRIME B550M-K BIOS 3302 08/01/2023
CPU: AMD Ryzen 7 5800X 8-Core Processor (16) @ 3800 MHz
GPU: AMD Caicos Radeon HD 6450/7450/8450 / R5 230 OEM 1GB DDR3
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 6:40 pm Post subject: |
|
|
quick question about genkernel: can the initramfs it generates deal with /var (in addition to /usr) being on a software RAID LVM? The preamble here suggests it can, but the page for genkernel itself doesn't mention it.
I don't want genkernel to configure/build the kernel, nor configure GRUB. I do that myself manually. Can genkernel work like that?
Cheers,
EE |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Wed Nov 24, 2021 7:11 pm Post subject: |
|
|
ExecutorElassus,
You will need to rebuild most of the system set for the new hardware.
busybox is still good with static linking but. lvm is not.
You can't chroot in with a broken system, but you can rebuild things with a parallel system to make binpkgs, then install the binaries.
You need Fix My Gentoo. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 7:12 pm Post subject: |
|
|
Yes, genkernel generated initramfs can mount /usr, /var. But you will need to create a file name /etc/initramfs.mounts in /mnt/gentoo and the content are Code: | # Each line name a mountpoint for initramfs to mount
/usr
/var |
genkernel can let you manually configure kernel. That is --menuconfig option is for. You can add --kernel-config=/path/to/your-old-config-file option to reuse existing .config file
Edit: you also need to create matching /mnt/gentoo/etc/fstab. I mean matching /usr and /var entries for how normal /etc/fstab work. |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 7:26 pm Post subject: |
|
|
Hi Neddy!
is the method outlined by pingtoo and soundroif not going to work for my use-case? If I can unpack a stage3 into my mounted filesystem, shouldn't that provide me with a working bash and gcc, from which I can then emerge all the rest? (after, of course, I copy /mnt/gentoo/etc/portage back over from the backup).
Cheers,
EE |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 8:41 pm Post subject: |
|
|
update: I unpacked the tarball onto /mnt/gentoo, chrooted, and then tried emerging world. This failed on bzip2, which gave the error that there was an illegal instruction in libbz2.a.
So what did I do wrong? I'm chrooted into the new system, but can't emerge anything. What next?
Thanks for the help,
EE |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 9:07 pm Post subject: |
|
|
Could you please chdoot into newroot and do and post the output. |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 9:50 pm Post subject: |
|
|
.a (dot a) file usually content elf object files. It is a passive archive file, so I have hard time to imagine how is illegal instruction in libbz2.a error. Is this a link produced error?
have your tried with? and please post the build log. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Wed Nov 24, 2021 9:55 pm Post subject: |
|
|
ExecutorElassus,
Unpacking a stage3 into your existing install will destroy your world file and all your settings.
You can unpack a stage3 somewhere else and quickpkg the packages you need.
Illegal instructs or symbol version error?
I've seen the latter with bzip2 because the underlying glibc was too old. It only happens with binary mix and match.
You are doing a binary mix and match. The stage3 is running on top of boot media glibc and so on.
It its really an illegal instruction, there will be more info in dmesg. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Wed Nov 24, 2021 10:08 pm Post subject: |
|
|
Hi Neddy,
oh dear. well, then I've lost my world file and settings. I don't mind the world file, but it's going to be annoying trying to recover settings.
So now I'm following the Fix My Gentoo instructions, but I don't know how much stuff I actually need to build (since I no longer have my old world file). I did preserve /etc/portage, but nothing else.
My worry now is that I'm going to run out of space on /var before I can build enough packages to get a bootable system. What packages (or set) do I minimally need to get it bootable and able in install the rest?
Cheers,
EE |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Wed Nov 24, 2021 10:18 pm Post subject: |
|
|
ExecutorElassus,
You need the system set, kernel and initrd and a boot loader to be able to boot.
I guess that your /var/db/pkg/ has been overwritten too?
Do you still have the original /var/log/emerge.log?
That's every every emerge the box ever did. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Wed Nov 24, 2021 10:42 pm Post subject: |
|
|
@ExecutorElassus, I am sorry I miss the world file.
NeddySeagoon wrote: | ExecutorElassus,
Unpacking a stage3 into your existing install will destroy your world file and all your settings. |
@NeddySeagoon, What are those settings you refer to? I want to make sure I will not make same mistake in future. |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Thu Nov 25, 2021 6:06 am Post subject: |
|
|
Hi Neddy,
I tried installing the kernel using the Fix My Gentoo instructions, /var filled up to 100%, and when I chrooted back to /mnt/gentoo to try `emerge -K sys-kernel/gentoo-sources` it seemed to work, but now I can't emerga anything else. I get an error that emerge can't find libffi.so.7.
So now what do I do? Do I have to install packages with tar? What package would I need to install with tar to get emerge working again?
/var/db/pkg is still there, but I can't read /var/log.emerge.log. ls reports it has a filesize of 37585896, though.
Thanks for the help. What should I do next?
Cheers,
EE
update: I tried using the tar command on a few files, getting "trailing garbage after EOF" notices for them. Now ls doesn't work, because it can't find glibc-2.34. So now the system is horribly broken. I can emerge binpackages on the live environment, but I can't use emerge to install them from the chrooted /mnt/gentoo. What exact order of packages do I need to install (using tar from Fix My Gentoo) to get it into a workable state?
update2: I had a binpkg of glibc, so I could use tar on that and get ls working. So now what should I do? I have a sizable number of binpkg files, but can't use emerge. should I use tar on the ones I have first, and then clear out /mnt/gentoo/var/cache/binpkgs/, and then emerge the system set on the rescue partition? Or should I proceed in some other way? |
|
Back to top |
|
|
pingtoo l33t
Joined: 10 Sep 2021 Posts: 926 Location: Richmond Hill, Canada
|
Posted: Thu Nov 25, 2021 12:16 pm Post subject: |
|
|
ExecutorElassus wrote: | I can emerge binpackages on the live environment, but I can't use emerge to install them from the chrooted /mnt/gentoo.
update2: I had a binpkg of glibc, so I could use tar on that and get ls working. So now what should I do? I have a sizable number of binpkg files, but can't use emerge. |
Risk of me being ignorant again I think you can use Quote: | env PKGDIR=/where/binpkgs/location emerge --root=/mnt/gentoo --usepkgonly something | from your live environment to install binpkgs into /mnt/gentoo. I am not sure if that something should be set or individual package, However please wait for NeddySeagoon to confirm,
I been working on design my own initramfs so did more research on how Gentoo way of thingy and I have tried many time to rebuild system so I learn a few gentoo tricks however this may be yet another bad suggestion. |
|
Back to top |
|
|
ExecutorElassus Veteran
Joined: 11 Mar 2004 Posts: 1435 Location: Berlin, Germany
|
Posted: Thu Nov 25, 2021 1:37 pm Post subject: |
|
|
well, what I think I need to do is wipe /var/cache/binpkgs/, chroot back into the rescue partition, emerge all of @system, and then libffi-compat just in case, exit back out, chroot into /mnt/gentoo, and try using tar to install all of that stuff manually. Last time I checked it was about 50 packages, so it should be possible without too much suffering.
But I'm not sure if this is the right way to proceed. Maybe Neddy has other suggestions.
Cheers,
EE |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Thu Nov 25, 2021 6:14 pm Post subject: |
|
|
ExecutorElassus,
The idea of a the rescue install is that it uses your existing distfiles, so it does not need to download anything and your existing binary packages space.
The rescue install, its distfiles and binary packages can be anywhere you have space.
Using your original or corrected /etc/portage makes like easy as portage will reject binaries built with the wrong USE flags.
Scatter the bits of the rescue install where you have space. As long as you tell portages where they are.
A long time ago I did unpick the liveDVD
The relevant bit here is section 5 and what was needed to get a working chroot. That page is from 2009, so versions will have changed.
Bash just needs ...
Code: | $ lddtree /bin/bash
/bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
libreadline.so.8 => /lib64/libreadline.so.8
libtinfow.so.6 => /lib64/libtinfow.so.6
libtinfo.so.6 => /lib64/libtinfo.so.6
libc.so.6 => /lib64/libc.so.6 | if all that works, you can chroot. You may not be able to do much but you can get in and look around.
Its left as an exercise for the reader to determine the packages. bash itself, glibc and readline stand out.
Don't go overboard with fixing things with tar. Its incomplete and risky. You will set up problems with file collisions for later.
Fix bash. Chroot, then see what fails. dmesg will tell where the illegal instruction was.
FIx that, rinse and repeat. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|