View previous topic :: View next topic |
Author |
Message |
GTXcube n00b
Joined: 05 Apr 2012 Posts: 31
|
Posted: Fri Jan 04, 2013 8:18 am Post subject: [Solved] Initramfs doesn't work |
|
|
Hello everybody. Today the first time I tried initramfs but unsuccessfully because of kernel panic. It's not problem of kernel because if I disable initramfs in grub.conf, kernel works normally. It says something like:
Code: | swich_root: can't execute '/sbin/init': No such file or directory
...
Kernel panic - not syncing: Attemped to kill init!
Pid: 1, comm: busybox Not tainted 3.7.1-gentoo #1
Call Trace:
panic+0xb6/0x1bc
do_exit+0x7f0/0x9a0
do_group_exit+0x3f/0xa0
sys_exit_group+0x12/0x20
system_call_fastpatch+0x16/0x1b
panic occurec, switching back to text console |
After I boot my system, /sbin/init is normally there so idk where can be a problem. Any ideas ? Thanks
Last edited by GTXcube on Sun Jan 13, 2013 3:55 pm; edited 1 time in total |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2181
|
Posted: Fri Jan 04, 2013 9:38 am Post subject: |
|
|
Almost certainly the script your initramfs runs is exiting. It's trying to return to the process that called it, but of course there isn't one.. You're not allowed to do that in initramfs; instead the script should end by executing some flavour of switch_root (assuming your initramfs is running its script in busybox).
Of course, the hard part is finding what's causing the exit. It's probably an error in the script.
When I had this problem just before Christmas, it turned out to be because busybox requires somewhere to mount /dev/console BEFORE it starts, and my initramfs had too few nodes in its /dev tree. _________________ Greybeard |
|
Back to top |
|
|
javeree Guru
Joined: 29 Jan 2006 Posts: 453
|
Posted: Fri Jan 04, 2013 9:39 am Post subject: |
|
|
When you create your initramfs. does you initramfs itself contain /sbin/init (I guess this will be the case, as there would otherwise be no mention of switch_root AFAIK ?
If so, can you adapt the init file in your initramfs to echo what it thinks the root drive is ? Check if that corresponds to what you expect. |
|
Back to top |
|
|
GTXcube n00b
Joined: 05 Apr 2012 Posts: 31
|
Posted: Fri Jan 04, 2013 1:16 pm Post subject: |
|
|
This is my /usr/src/initramfs/init script
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/sda1 /mnt/root
# Clean up.
umount /proc
umount /sys
# Boot the real thing.
exec switch_root /mnt/root /sbin/init |
It's default script from guide on wiki. Is there something wrong ? |
|
Back to top |
|
|
gabrielg Tux's lil' helper
Joined: 16 Nov 2012 Posts: 137
|
Posted: Fri Jan 04, 2013 1:26 pm Post subject: |
|
|
GTXcube: have you got any errors before the switch_root one? I'm curious as to whether /dev/sda1 is mounted properly or not. I suggest that you insert something like this, assuming that /bin/sh is linked to busybox in your initramfs:
right before the switch_root and you verify that /mnt/root/sbin/init exists.
If you find anything wrong, you can fix it and then exit, init should continue normally and you'll know what you're missing. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54584 Location: 56N 3W
|
Posted: Fri Jan 04, 2013 4:35 pm Post subject: |
|
|
GTXcube,
Code: | mount -o ro /dev/sda1 /mnt/root |
/dev/sda1 is a funny place for the root filesystem to be. Its often /boot.
I that case the mount would work but there would be no /sbin/init to run. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
GTXcube n00b
Joined: 05 Apr 2012 Posts: 31
|
Posted: Fri Jan 04, 2013 6:05 pm Post subject: |
|
|
oh you are right my root is /dev/sda3 but I always can't find a correct mount point. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54584 Location: 56N 3W
|
Posted: Fri Jan 04, 2013 6:46 pm Post subject: |
|
|
GTXcube,
Does /mnt/root exist in your intramfs ? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
GTXcube n00b
Joined: 05 Apr 2012 Posts: 31
|
Posted: Fri Jan 04, 2013 7:30 pm Post subject: |
|
|
yes sure :/ |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54584 Location: 56N 3W
|
Posted: Fri Jan 04, 2013 7:57 pm Post subject: |
|
|
GTXcube
Change your initrd init script as follows.
Code: | # Mount the root filesystem.
mount -o ro /dev/sda1 /mnt/root
# new lines to see whats happening
busybox -s
busybox sh
# Clean up.
umount /proc
umount /sys |
busybox -s makes all the symlinks for busybox
and busybox sh spawns a shell
Have a look round.
If everything look OK you can execute
Code: | umount /proc
umount /sys
exec switch_root /mnt/root /sbin/init |
in the busybox shell to continue.
You should see your root filesystem mounted at /mnt/root and you should see that /mnt/root/sbin/init exists.
What do you have in /dev ?
Thats the initrd /dev, your own roots /dev may be populated (/mnt/root/dev) but whatever is there will be hidden during the boot process _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
gabrielg Tux's lil' helper
Joined: 16 Nov 2012 Posts: 137
|
Posted: Sat Jan 05, 2013 2:03 pm Post subject: |
|
|
NeddySeagoon: I don't believe the latest stable version of busybox allows you to execute switch_root unless your PID is 1, so if you want to do it from a spawned shell it will ungracefully print its help |
|
Back to top |
|
|
GTXcube n00b
Joined: 05 Apr 2012 Posts: 31
|
Posted: Sat Jan 05, 2013 4:29 pm Post subject: |
|
|
Ok finally I found a solution. I just had to run
Code: | cp -a /dev/{null,sda3} /usr/src/initramfs/dev/ |
Reason why I wanted to use initramfs is gone because in the lattest kernel 3.7.1 isn't support of Fbsplash but nevermind.
Thank you so much as always |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22705
|
Posted: Sat Jan 05, 2013 6:09 pm Post subject: |
|
|
GTXcube wrote: | Ok finally I found a solution. I just had to run
Code: | cp -a /dev/{null,sda3} /usr/src/initramfs/dev/ |
| You could instead modify your init script to mount devtmpfs, which would provide those devices. |
|
Back to top |
|
|
|