You are not logged in.
Pages: 1
Hi, I have been playing around with initramfs and created my own (very, very basic) to learn more about how it works. I am using GRUB 2 and the MSI Wind U100 laptop.
I have a few questions I haven't been able to found the answer to yet, maybe you could help?
1. When I pass a wrong pathname to the GRUB 2 initrd line, I get a kernel panic as the file cannot be loaded, which is Ok. But, I can't reboot the computer with the CTRL+ALT+DEL key combination. Is this because the keyboard driver hasn't been loaded by anybody yet? The only thing that works is to power off the computer the hard way with the power button. I guess it works because it is a hardware switch and no driver is necessary?
2. It seems I must use the 'initrd /boot/initramfs.cpio.gz' GRUB 2 line. But, the https://www.kernel.org/doc/Documentatio … meters.txt site mentions the kernel 'initrd' parameter. When I remove theGRUB line and use the kernel param to point to my ramfs, though, I get a kernel panic. It seems the only way to make it work is to use GRUB 2 to instruct the kernel where the ramfs is. How does this really work?
3. When my ramfs looks like this:
bin/busybox
lib/ld-linux.so.2
usr/lib/libc.so.6
initand the init code is:
#!/bin/busybox sh
exec /bin/busybox shit can actually boot and here is what I get:
can't access tty; job control turned offWhat does need to be done to have job control? I think the same message is displayed in Arch's rescue shell, I think I've seen it.
4. I can now see the shell and the command prompt, but I cannot type anything. Is the reason the same as in #1, i.e. no drivers loaded yet?
Regards.
Last edited by wujek.srujek (2014-10-01 09:28:54)
Offline
Hi again. About the keyboard not working - it also doesn't work when i use the break=premount or break=postmount kernel params. This is strange as it works fine in grub.
Can anybody help with this?
Offline
I found the answer to question #3 here: http://www.busybox.net/FAQ.html#job_control.
Offline
Some very basic things missing... and if you're using the Arch kernel, most things (including keyboards) are built as modules, so it won't work without including those (and something to load the module)
My: [ GitHub | AUR Packages ]
Offline
Hi. Thanks for your comment. I read the page you linked and a few others, and I'm getting closer, I think.
I was able to add the keyboard to early userspace by either adding the 'atkbd' module and its deps, or the 'keyboard' hook. However, I can't make it work in my custom initramfs.
Here is the contents:
$ find -type f | sort
./bin/busybox
./bin/find
./bin/kmod
./bin/mount
./init
./lib/ld-linux.so.2
./lib/modules/3.16.3-1-ARCH/kernel/atkbd.ko
./lib/modules/3.16.3-1-ARCH/kernel/i8042.ko
./lib/modules/3.16.3-1-ARCH/kernel/libps2.ko
./lib/modules/3.16.3-1-ARCH/kernel/serio.ko
./usr/lib/libblkid.so.1
./usr/lib/libc.so.6
./usr/lib/libm.so.6
./usr/lib/libmount.so.1
./usr/lib/libuuid.so.1
./usr/lib/libz.so.1and here is my /init:
#!/bin/busybox sh
echo Creating links
/bin/busybox --install -s /bin
ln -s /bin/kmod /bin/modprobe
ln -s /bin/kmod /bin/lsmod
echo Mounting /proc
mkdir /proc
mount -t proc dummy_proc /proc
echo Mounting /sys
mkdir /sys
mount -t sysfs dummy_sys /sys
echo Mounting /dev
mkdir /dev
mount -t devtmpfs dummy_dev /dev
echo Loading modules
modprobe serio
modprobe libps2
modprobe atkbd
modprobe i8042
lsmod
exec shAs you can see, I'm packaging very little and creating all the links to busybox and directories at runtime, in the scrip (is this Ok?).
The /proc, /dev/ and /sys mounts are populated.
The script actually executes without error, but the lsmod command near the end results only in the lsmod column headers (i.e. not module has been loaded). But I don't get any error etc.
Could you give me a pointer what is missing?
Offline
That looks more like it
Yes, it's fine to populate the busybox links at runtime (apart from init, but I see you found that out). I noticed you are using kmod to load the modules - is there any reason not to use busybox modprobe?
First thing to try would be "modprobe -v " to show a verbose output, it might tell you something simple to fix.
Otherwise, (just a guess) it might be to do with the fact arch linux uses /usr/lib/modules, and your initramfs is /lib/modules
Did you try making a few symlinks?
ln -sv /usr/bin bin
ln -sv /usr/bin sbin
ln -sv /usr/bin usr/sbin
ln -sv /usr/lib lib
ln -sv /usr/lib lib64
ln -sv /usr/lib usr/lib64that's a copy-paste from my scripts as an example - you'll need to swap them around to fit your layout e.g. ln -sv /bin usr/bin
EDIT: actually, I've just noticed your kmod symlinks are after busybox, and not "forced"... so you might be using busybox modprobe without knowing it ![]()
in addition to the stuff above, I'd add a "ls -l /bin/modprobe" which will show you where the symlink is pointing to (kmod or busybox)
Last edited by stevenhoneyman (2014-10-05 20:37:18)
My: [ GitHub | AUR Packages ]
Offline
I'm using kmod because the busybox coming by default with Arch in /usr/lib/initcpio doesn't have it. It is actually a bit restricted, i.e. a few commands are missing which can be there: find, modprobe, mount... I guess it was compiled with the restricted set of commands.
The standard Arch initramfs also uses standalone kmod and mount, and a few others so I also decided to go for it.
I created the links as you suggested, but it didn't help; I tried moving the files around etc. and nothing helped.
modprobe -v is also very silent. It's very disconcerting because apparently it doesn't add the modules, but it doesn't report any problems. It turns out it might not be doing anything at all, because when I 'modprobe blahblah' it also doesn't complain that it can't find the module, while it definitely should. I checked and the kmod binary in mine and Arch's initramfs is exactly the same one. There must be something missing preventing modprobe from working.
I guess I will start over, with a different approach - with the working Arch initramfs, and by removing bits step by step I will sooner or later (or give up altogether) know how it really works.
Offline
Ok, so I had this strange idea that modprobe doesn't work but maybe insmod does and guess what... it does work! The ordering of the modules must be different: serio, i8042, libps2, atkbd, and insmod works with full module paths. But now I have the keyboard in my custom initramfs.
Why on earth modprobe doesn't work is a mystery to me, I guess it has something to do with the fact that nowhere do I have any dependency file. But why doesn't it report errors?
Offline
Well if insmod works and modprobe doesn't, then at least kmod seems to work (as they're the same file). Maybe you need to get depmod to create the modules.* files?
something like:
cp /usr/lib/modules/3.16.3-1-ARCH/modules.{builtin,order} ~/initramfs/lib/modules/3.16.3-1-ARCH/
depmod --basedir=~/initramfs 3.16.3-1-ARCHMy: [ GitHub | AUR Packages ]
Offline
Well if insmod works and modprobe doesn't, then at least kmod seems to work (as they're the same file). Maybe you need to get depmod to create the modules.* files?
At least mkinitcpio does call depmod (in install_modules), so I believe it is necessary.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline
Yes! It works. Here is what is needed:
go to the root of the custom initramfs
invoke:
depmod -b $(pwd) $(pwd)/lib/modules/$(uname -r)/kernel/*.koThis creates the depmod files in ./lib/modules/3.16.3-1-ARCH with relatives paths to the modules in kernel/.
Replace the insmods in the previously shown init with a simple 'modprobe atkbd'.
Thank you for your tips and help with this.
This leaves only one of my previous questions open: why do I need to use GRUB's initrd directive to pass the image, and initrd= on the command line doesn't work.
Offline
Pages: 1