View previous topic :: View next topic |
Author |
Message |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Thu Dec 02, 2010 6:18 am Post subject: initramfs confusion |
|
|
Hi all
I was trying to use an initramfs so I could mount drives using a LABEL=gentoo_root parameter. I tried to follow the directions here:
https://forums.gentoo.org/viewtopic-t-850865.html?sid=d8eee5d0bd8e4282714c2937a4236ac6
and here:
http://en.gentoo-wiki.com/wiki/Initramfs
and my directory structure looks like this:
Code: |
/usr/src/initramfs
find . | sort
.
./bin
./bin/busybox
./dev
./dev/console
./dev/hda
./dev/hda1
./dev/hda2
./dev/hda3
./dev/hdb
./dev/hdb1
./dev/null
./dev/sda
./dev/sda1
./dev/sdb
./dev/sdb1
./dev/sdc
./dev/sdc1
./dev/sdd
./dev/sdd1
./dev/sde
./dev/tty
./etc
./init
./lib
./mnt
./mnt/root
./proc
./root
./sbin
./sbin/mdev
./sys
|
with /sbin/mdev -> ../bin/busybox
and then I did
find . -print0 | cpio --null -ov --format=newc | gzip -9 > /boot/labelinitramfs.gz
I have tried with an external file
Code: |
title Gentoo Linux 2.6.36-Gentoo
root (hd0,0)
kernel /boot/kernel-2.6.36-gentoo LABEL=gentoo_root
initrd /boot/labelinitramfs.gz
|
and /usr/src/initramfs compiled into the kernel
Code: |
title Gentoo Linux 2.6.36-Gentoo
root (hd0,0)
kernel /boot/kernel-2.6.36-gentoo LABEL=gentoo_root
|
Either way I get a kernel panic that says it can't find /init - but it is there....
Even stranger, when I decided to go back, I commented out the initrd line in grub.conf but forgot to undo the LABEL=gentoo_root. I also left:
Code: |
LABEL=gentoo_boot /boot ext3 noatime 1 2
LABEL=gentoo_root / ext3 noatime 0 1
...
|
in /etc/fstab and everything booted back up. So I am really confused as nothing seems to be working as I would expect. The only thing I can think of is that it is ignoring LABEL and udev is doing something under the hood that I am unaware of.
Could anyone out there help me figure out how to make an initramfs such that/init is found so I can be sure I am mounting by label? I am testing this out before I muck with a computer that has a HDD configuration that changes often.
Thanks for any help. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Fri Dec 03, 2010 3:21 am Post subject: |
|
|
What is in /init in the initramfs? What happens if you build an initramfs using the built-in support, instead of bolting one on at boot time? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Fri Dec 03, 2010 4:10 am Post subject: |
|
|
So, I decided to try back to basics. I went to the manual:
http://en.gentoo-wiki.com/wiki/Initramfs
and followed the directions up to Creating a Seperate File. My init contains:
Code: |
#!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"
# Mount the root filesystem.
mount -o ro /dev/sde3 /mnt/root
# Clean up.
umount /proc
umount /sys
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
|
/dev/sde3 is now my root because I started using the new SATA/PATA drivers - it took me a while to figure that out, which is another reason I am looking at this - so I can boot by label and not have to worry what my drives are mounted as. Anyway, no matter if I compile it in by specifying /usr/src/initramfs in the kernel menuconfig or if I try from a seperate file specified in grub.conf (initrd /boot/my-initramfs.cpio.gz)
I get:
Kernel Panic: Not syncing: No init found - try passing init= ...
(I tried that also) - no luck.
Not sure what I am missing.
Thanks. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
whig l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 27 Nov 2004 Posts: 973 Location: New Zealand
|
Posted: Fri Dec 03, 2010 7:03 am Post subject: |
|
|
Unless overridden I think we need a /sbin/init. It can be a link to another location. In your list it is missing. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Goverp Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/152613747847c6fd276c31a.jpg)
Joined: 07 Mar 2007 Posts: 2202
|
Posted: Fri Dec 03, 2010 2:42 pm Post subject: Is your init executable? |
|
|
Have you done chmod +x /usr/src/initramfs/init ? _________________ Greybeard |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
systema encephale n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 17 Apr 2006 Posts: 11
|
Posted: Fri Dec 03, 2010 4:31 pm Post subject: |
|
|
Same problem here. I have a VMWare ESX 3.0.1 environment, where I can install Gentoo VMs with kernels not newer than 2.6.20. Apparently this is the only kernel version I've found that fully supports the SCSI controller. Also, I have to use the old Gentoo 2007 minimal install live cd, otherwise newer releases don't work. The kernel modules are the Fusion-MPT mptbase.ko, mptscsih.ko and mptspi.ko, that maybe have changed since 2.6.20.
I've created the initramfs in /usr/src/initramfs and followed the steps described in http://en.gentoo-wiki.com/wiki/Initramfs. My init script is
Code: | #!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"
load_modules || rescue_shell
# Mount the root filesystem.
mount -o ro /dev/sda1 /mnt/root || rescue_shell
# Clean up.
umount /proc
umount /sys
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
rescue_shell() {
echo "Something went wrong. Dropping you to a shell."
busybox --install -s
exec /bin/sh
}
load_modules() {
MODULES="mptbase.ko mptscsih.ko mptspi.ko"
MOD_PATH="/lib/modules"
for MODULE in ${MODULES} ; do
insmod -f ${MOD_PATH}/${MODULE}
done
} |
The modules are the ones generated from the 2.6.20. My root partition is actually /dev/sda1.
I created a cpio archive as well as set the /usr/src/initramfs in the kernel config. Like tenspd137, either way I get the kernel panic, not syncing, init not found error.
If I have to use kernel 2.6.20 I have also to downgrade udev, as the current version (151-r4) is not supported by kernels older than 2.6.25.
/usr/src/initramfs/init has 755 permissions.
Thanks |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 2:08 am Post subject: |
|
|
I tried linking /sbin/init -> /init - no luck. I did chmod +x on /init. It is as though the initramfs file is just totally being ignored. I still tells me it can't find init or /sbin/init when I specify it.
Any other suggestions? Could this be some sort of bug with the 2.6.36 kernel? I dunno --- |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Sat Dec 04, 2010 3:54 am Post subject: |
|
|
I have used each of the last six major kernels (2.6.30, 2.6.31, etc.) with initramfs with no problems. My initial process is /init and is part of the kernel image, as built by CONFIG_INITRAMFS_SOURCE. It is activated automatically at boot, and transitions to my hard disk root filesystem after performing its work. I have never seen a kernel ignore an initramfs in the manner reported here.
systema encephale wrote: | Same problem here. I have a VMWare ESX 3.0.1 environment, where I can install Gentoo VMs with kernels not newer than 2.6.20. Apparently this is the only kernel version I've found that fully supports the SCSI controller. | I believe there was a VMware bug that it misreported the number of SCSI controllers. Kernels 2.6.20 and below ignored the bug. Kernel 2.6.21 was affected, but I thought that newer versions had a patch to work around that. Either way, I would expect that such an old bug should be fixed by now. Is VMware ESX 3.0.1 the latest release of ESX server? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 4:15 am Post subject: |
|
|
Sorry - just sort of grasping at straws. I followed the manual except for changing the root drive to /dev/sde3, and it isn't working. I don't know how to debug it or figure out what is happening. I tried building it directly into the kernel and that did not work. I am hesitant to do that because the only way I know to fix that is to rebuild without the image. If I keep it as a seperate file, I can at least recover by commenting out the initrd line and add root=/dev/sde3 to the kernel line.
Thanks. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 5:05 am Post subject: |
|
|
So - one thing I did find - if I omit the --format=newc option when making the cpio archive, I get a different result - it tells me it cant mount a file type / system. So, could I be doing something wrong there?
Another question - is there some way I can slow the messages down at boot so I can actually see what is going on? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 5:49 am Post subject: |
|
|
I stumbled across the dracut utility while trying to dig up more answers. I tried it out and it appears to work - ie, I can mount by Label now. I'd like to leave this open for now though because I still would like to know what I did wrong / why I can't get the instructions from the wiki page to work.
Thanks again! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Sat Dec 04, 2010 5:25 pm Post subject: |
|
|
Can you run (as root) chroot /usr/src/initramfs /bin/busybox sh successfully? If not, what error does it print? tenspd137 wrote: | I don't know how to debug it or figure out what is happening. | Without an equally broken setup, I cannot offer further advice on how to debug it.
tenspd137 wrote: | I tried building it directly into the kernel and that did not work. | That is good to know. It suggests that your initscript or one of its dependencies is broken, rather than that you are packing it incorrectly.
tenspd137 wrote: | I am hesitant to do that because the only way I know to fix that is to rebuild without the image. If I keep it as a seperate file, I can at least recover by commenting out the initrd line and add root=/dev/sde3 to the kernel line. | I no longer think building it in will solve your problem. However, if you are concerned about having a kernel with the initramfs being more difficult to control, you could build two kernels and install both of them to /boot.
tenspd137 wrote: | So - one thing I did find - if I omit the --format=newc option when making the cpio archive, I get a different result - it tells me it cant mount a file type / system. So, could I be doing something wrong there? | Yes. Only one specific format is allowed. By switching away from that format, you prevented the kernel from even unpacking your initramfs.
tenspd137 wrote: | Another question - is there some way I can slow the messages down at boot so I can actually see what is going on? | You might be able to achieve this with CONFIG_BOOT_PRINTK_DELAY. You could also try using a higher resolution (e.g. framebuffer mode) so that more lines of text are visible. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 11:30 pm Post subject: |
|
|
No - as root, it tells me:
chroot: failed to run command `/bin/busybox sh': No such file or directory
which is odd, because it is there. In fact, if I do just chroot /usr/src/initramfs, it tells me there is no /bin/bash - which is real odd and means I might have other issues. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sat Dec 04, 2010 11:50 pm Post subject: |
|
|
After a little more digging - I found it meatn that I might not have the right libraries for bash in my directory I was chrooting into. So I checked busybox:
ldd /bin/busybox
and got
linux-gate.so.1 => (0xb7834000)
libm.so.6 => /lib/libm.so.6 (0x4a09b000)
libpam_misc.so.0 => /lib/libpam_misc.so.0 (0x4a0c9000)
libc.so.6 => /lib/libc.so.6 (0x49f3f000)
libpam.so.0 => /lib/libpam.so.0 (0x4a537000)
/lib/ld-linux.so.2 (0x49f1e000)
libdl.so.2 => /lib/libdl.so.2 (0x4a0c3000)
Please correct me if I am wrong, but I set the static flag when I emerged it, so these libraries should not appear? If so, then bb is not being built statically - I think. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sun Dec 05, 2010 12:07 am Post subject: |
|
|
Yup - that seem to be the problem - I just emerge -C busy box andre-emerged it this time adding -savedconfig to packages.use, so that only ipv6, mdev, and static were enabled. After checking ldd and making sure it was static, I copied it to /usr/src/initramfs/bin/busybox and tried chrooting - worked this time. Then I repackaged the initramfs archive and tried it out with:
qemu -kernel /boot/kernel-2.6.36-gentoo -initrd /boot/initramfs.cpio.gz
( I found that in the Linux Kernel Documentation, http://www.mjmwired.net/kernel/Documentation/filesystems/ramfs-rootfs-initramfs.txt , which I thought was a slick idea I didn't have to reboot my computer)
Now it tries to kill init because it can't find sde3 - which is what I would expect. I am going to try a reboot with it right now - be back in a minute...
Last edited by tenspd137 on Sun Dec 05, 2010 12:14 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
tenspd137 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 22 Aug 2006 Posts: 391
|
Posted: Sun Dec 05, 2010 12:13 am Post subject: |
|
|
Works! Thanks again for the hints - it would have taken me a very long time - if ever - before I stumbled across that. I glossed over the part about using ldd to check busybox, I assumed that since I enabled static and disabled pam, all would be good - so I guess I didn't follow the directions to the letter. Learned my lesson - next time I will be more cognizant of that. I kind of put my faith in portage, which is 99.9% of the time okay to do.
Anyway, much appreciated. no that I have anything against utilities like dracut, but sometimes it is nice to know what is going on.
Thanks so much again. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Sun Dec 05, 2010 12:47 am Post subject: |
|
|
Good to see you got it working. My first thought was that it would be a library linking issue, but I dismissed that because busybox is so often built statically and you were using it as your script interpreter. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
systema encephale n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 17 Apr 2006 Posts: 11
|
Posted: Tue Dec 07, 2010 8:05 am Post subject: |
|
|
Thanks to your suggestions I managed to build a correct initramfs and now I get busybox running the init script.
However, as I thought, it cannot load modules from another kernel version. At the moment I'm trying to load the 2.6.35-gentoo-r12 kernel with the mpt- modules from the 2.6.19 kernel (which are working for my hardware), but I cannot.
The actual error message is the following:
Code: | mptbase: version magic '2.6.19-gentoo-r5 SMP mod_unload 486 ' should be '2.6.35-gentoo-r12 SMP mod_unload PENTIUMIII '
insmod: can't insert '/lib/modules/mptbase.ko': invalid module format |
and the same for mptscsih and mptspi modules.
Do you have any suggestions? I wouldn't use an initramfs if I didn't have to use external modules, otherwise I would have compiled everything into the kernel.
Thanks 1M |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Wed Dec 08, 2010 4:03 am Post subject: |
|
|
It is very unlikely that you will get those modules to work with that kernel version. Even if you bypassed all the sanity checks and somehow forced the kernel to load those modules, I doubt that they would be compatible. You should rebuild those modules with a modern kernel. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
systema encephale n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 17 Apr 2006 Posts: 11
|
Posted: Wed Dec 08, 2010 9:40 am Post subject: |
|
|
You're right Hu. Indeed I wanted to try compiling those modules from kernel 2.6.20 on a machine running 2.6.35. Do you think it could work? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Thu Dec 09, 2010 12:37 am Post subject: |
|
|
You might be able to compile it, but I doubt you will get the modules to load unless they are from exactly the same kernel version. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
systema encephale n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 17 Apr 2006 Posts: 11
|
Posted: Thu Dec 09, 2010 7:49 am Post subject: |
|
|
What can I do then? Those modules from kernel 2.6.35 don't work for my hardware, if they did I wouldn't have needed an initramfs, I'd rather have compiled them into the kernel. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Fri Dec 10, 2010 2:27 am Post subject: |
|
|
Run an old kernel (not recommended) or file a bug with the maintainer of the modules so that they can be fixed to work with your hardware. Since they worked before, their failure now is a regression. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Mike81 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 05 Jan 2011 Posts: 39
|
Posted: Thu Jan 06, 2011 1:53 am Post subject: |
|
|
Hi,
I am new in Gentoo. I am also working with VMware and need the Fusion MPT drivers on boot. In Debian, I would compile that driver as module and build an initrd file. It would work.
Genkernel created a initramsfs for me, which contains the drivers (I checked that), but on boot, the controller isn't accessible. My system won't boot, I need to open a shell and run the "modprobe mptspi" command so that Gentoo is able to mount the root fs and continue booting. So is that different in Gentoo?
Do I need to create such a custom initramfs with an own script? I like the generic kernels I know from Debian and other distributions, which are working out of the box or will it work as known from Debian, when I update my Gentoo, currently I am using 2007.0 with v2.6.19... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Thu Jan 06, 2011 2:32 am Post subject: |
|
|
If you are new in Gentoo and using a 2007.0 system with a v2.6.19 kernel, I think you got off to a really bad start. That configuration is so old that it will be extremely difficult to maintain. How did you end up with such an old system if you are such a new user? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|