Gentoo Archives: gentoo-user

From: daid kahl <daidxor@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Booting a Kernel-2.4 with glibc-2.9?
Date: Sat, 11 Jul 2009 10:49:37
Message-Id: 3ac129340907110349i5c3e9606s31e35592bc144401@mail.gmail.com
In Reply to: Re: [gentoo-user] Booting a Kernel-2.4 with glibc-2.9? by Alan McKinnon
1 >
2 > On Wednesday 08 July 2009 17:13:16 daid kahl wrote:
3 > > Hello,
4 > >
5 > > I'm working on upgrading a very old Gentoo system for my work.
6 > >
7 > > Some software is only running well in 2.4.x kernels, and when doing other
8 > > updates I inadvertently updated past glibc-2.3.5, and so now the 2.4
9 > kernel
10 > > does not boot (Fatal error, kernel too old). Fortunately there is a 2.6
11 > > kernel on the system so I can still boot.
12 >
13
14 > > Is there any known workaround for booting a 2.4 kernel on a system with
15 > > glibc-2.9 installed?
16 >
17
18
19 >
20 > In the time it takes you to sort that mess out (including doing the
21 > necessary
22 > research), I reckon you could do the following:
23 >
24 > 1. Backup all user data, configs and critical files
25 > 2. Download a recent stage that suits your needs
26 > 3. Rebuild world plus add all the extra packages you use
27 >
28 > and do the whole lot three times.
29
30
31 > alan dot mckinnon at gmail dot com
32 >
33
34 I have successfully installed a Gentoo system from source that is capable of
35 booting a 2.4 kernel. Although such a task relies on deprecated source code
36 and is officially unsupported, I'll give a brief outline of how I tackled
37 this task in case another person faces a similar problem and needs a fresh
38 system for running Gentoo with a 2.4 kernel.
39
40 The first thing is we need a stage that is 2006.0 or earlier, since all the
41 later Gentoo stages use versions >=glibc2.4 which won't be friendly with 2.4
42 kernels. The oldest stage available at gentoo.org is 2006.1, so one needs
43 to find an old and outdated Gentoo mirror. Such a mirror exists as of this
44 writing: http://linux.mirrors.es.net/gentoo/releases/
45
46 As I have a functional 2.6 kernel on the target machine, I don't bother with
47 a Live CD, but one could also use any Gentoo Live CD for the task. Using a
48 free partition, we can install the new system for linux-2.4 and tell Grub to
49 mount the 2.4 kernel using this different root filesystem. This allows for
50 the peaceful co-existence of an up-to-date linux-2.6 system and a 2.4 system
51 on different partitions. I assume for this you can properly set up the
52 fstab file correctly on each system.
53
54 So, I mount my target partition for 2.4 at /mnt/gentoo and unpack
55 stage3-x86-2006.0.tar.bz2 (or the corresponding stage for your architecture)
56 as with any Gentoo install. Before you chroot, you'll also want to download
57 an old portage snapshot (I used portage-20060123.tar.bz2) before you emerge
58 --sync. The reason is that newer portage has some slightly different
59 layouts, and some trouble is encountered going straight from a 2006.0 stage
60 to a new portage system, particularly in the realm of make.profile. The
61 last thing before chroot is to create a bash-3.1_p17 overlay. So on your
62 up-to-date Gentoo system, emerge --fetchonly =app-shells/bash-3.1_p17 and
63 then copy the necessary source code into, say,
64 /usr/local/portage/app-shells/bash/files and put the ebuild in
65 /usr/local/portage/app-shells/bash, and then tar and zip this directory and
66 copy it over to /mnt/gentoo.
67
68 Now we can copy our network settings such as /etc/resolv.conf
69 /etc/conf.d/hostname and /etc/conf.d/net to the appropriate locations in
70 /mnt/gentoo, unless you want to manually configure all that after you
71 chroot.
72
73 Mount dev and proc to /mnt/gentoo/proc and /mnt/gentoo/dev and (assuming you
74 can write or copy /mnt/gentoo/etc/make.conf with the settings you want from
75 somewhere) chroot, env-update, and source /etc/profile.
76
77 To make sure you never accidentially update glibc so that kernel 2.4 will
78 refuse to boot:
79 # echo ">=sys-libs/glibc-2.4" >> /etc/portage/package.mask
80
81 Before emerge --sync, you want to upgrade bash through an overlay. I'm not
82 clear as to why we can't just emerge --sync and update portage, but there
83 was a lot of trouble with make.profile, bash, and some other things when I
84 omitted this step and I couldn't get a functional system. It could have
85 been user error, but this step is fairly painless, and because updating from
86 an old version of portage to a newer version is blocked by bash anyway, this
87 is already a necessary step one way or the other.
88
89 Edit /etc/make.conf and add a PORTDIR_OVERLAY which I use as
90 /usr/local/portage, and untar the bash-3.1_p17.tar.gz into
91 /usr/local/portage/app-shells. Then you can easily emerge
92 =app-shells/bash-3.1_p17 and update bash.
93
94 Now emerge --sync, and then toy around with make.profile symlinks until you
95 find something that will work with your achronisitic system (a lot of
96 profiles will complain about ARCH settings or missing keywords, and I found
97 /usr/portage/profiles/hardened/x86/minimal to work for the next steps)
98
99 In principle, the next goal is to simply upgrade portage, but it's not
100 entirely trivial. Since we only have python-2.4, and because portage-2.1.4.5
101 is still in the portage tree (and does not require python-2.5 as a
102 dependency), I go for this version of portage. I had tried to upgrade to
103 python-2.5, but this is a circular dependency as it needs a version of
104 portage newer than portage-2.0.54 included in the 2006.0 stage.
105
106 There will be three dependencies that need to be upgraded first before
107 portage:
108 lzma-utils
109 pax-utils
110 sandbox
111
112 lzma-utils and pax-utils are fine, except that with the sync'd portage tree
113 and old portage, we have to ebuild digest the packages by hand and emerge
114 again for sucessful install.
115
116 The sandbox source is packaged as a .tar.lzma, but older portage will not
117 suppot .lzma, so emerging sandbox is a little more work. I updated tar
118 after lzma just to be safe, but I can't confirm it's necessary.
119
120 Emerging sandbox is similar to those instructions posted at
121 http://www.void.gr/kargig/blog/tag/lzma/ , but since the 2006.0 stage has an
122 even older version of portage, it's not exactly done as written there and I
123 explicity write the differences here.
124
125 First you can emerge --fetchonly =sys-apps/sandbox-1.6-r2, and then:
126
127 # mkdir /var/tmp/portage/sandbox-1.6-r2 && cp
128 /usr/portage/distfiles/sandbox-1.6.tar.lzma /var/tmp/portage/sandbox-1.6-r2/
129
130 The sandbox ebuild needs to be modified so that it reads:
131
132 src_unpack() {
133 unpack ${A}
134 cd /var/tmp/portage/sandbox-1.6-r2/
135 tar --lzma -xvf sandbox-1.6.tar.lzma -C
136 /var/tmp/portage/sandbox-1.6.2-r2/work/
137 cd "${S}"
138 epatch "${FILESDIR}"/${P}-disable-qa-static.patch
139 epatch "${FILESDIR}"/${P}-disable-pthread.patch
140 epatch "${FILESDIR}"/0001-libsandbox-handle-more-at-functions.patch
141 }
142
143
144 The only difference is that I've added the second and third lines (starting
145 with cd, tar, respectively). Then manually digest the ebuild, emerge.
146
147 At this point, we can emerge portage, which will also require a manual
148 digest and emerge again for success! Since there are some other files the
149 portage will want to upgrade (but are not explicit dependencies), I emerge
150 --nodeps on my version of portage. This is mainly because I didn't want to
151 switch to the newer coreutils at this point, but I do this later (not
152 detailed here, since it's standard).
153
154 I had to change the make.profile symlink once again to its final
155 destination, but now there will be no problems for updating any files with
156 portage, and you can do whatever you need (also likely including an update
157 of python and portage to the most recent stable versions).
158
159 Only one thing remains besides the steps outlined in the Gentoo Handbook for
160 finishing the install: we need devfsd, otherwise linux-2.4 will not be able
161 to find critical devices like the harddrive.
162
163 But sys-fs/devfsd is effectively hard-masked in portage since it has no
164 keywords. So download the ebuild and source code to the portage overlay
165 directory, and then edit the ebuild to include the keyword for your
166 architecture (in my case x86). Then I can emerge devfsd, and when I finally
167 reboot into the system, it is working correctly.
168
169 At this point you can just do the usual steps for finishing the install.
170
171 Hope this is clear for anyone in a similar plight in the future.
172
173 Regards,
174 daid