Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Initramfs doesn't work
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
GTXcube
n00b
n00b


Joined: 05 Apr 2012
Posts: 31

PostPosted: Fri Jan 04, 2013 8:18 am    Post subject: [Solved] Initramfs doesn't work Reply with quote

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
View user's profile Send private message
Goverp
Guru
Guru


Joined: 07 Mar 2007
Posts: 331

PostPosted: Fri Jan 04, 2013 9:38 am    Post subject: Reply with quote

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
View user's profile Send private message
javeree
Apprentice
Apprentice


Joined: 29 Jan 2006
Posts: 285

PostPosted: Fri Jan 04, 2013 9:39 am    Post subject: Reply with quote

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
View user's profile Send private message
GTXcube
n00b
n00b


Joined: 05 Apr 2012
Posts: 31

PostPosted: Fri Jan 04, 2013 1:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
gabrielg
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2012
Posts: 87

PostPosted: Fri Jan 04, 2013 1:26 pm    Post subject: Reply with quote

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:
Code:

exec /bin/sh

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31711
Location: 56N 3W

PostPosted: Fri Jan 04, 2013 4:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
GTXcube
n00b
n00b


Joined: 05 Apr 2012
Posts: 31

PostPosted: Fri Jan 04, 2013 6:05 pm    Post subject: Reply with quote

oh you are right my root is /dev/sda3 but I always can't find a correct mount point.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31711
Location: 56N 3W

PostPosted: Fri Jan 04, 2013 6:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
GTXcube
n00b
n00b


Joined: 05 Apr 2012
Posts: 31

PostPosted: Fri Jan 04, 2013 7:30 pm    Post subject: Reply with quote

yes sure :/
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31711
Location: 56N 3W

PostPosted: Fri Jan 04, 2013 7:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
gabrielg
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2012
Posts: 87

PostPosted: Sat Jan 05, 2013 2:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
GTXcube
n00b
n00b


Joined: 05 Apr 2012
Posts: 31

PostPosted: Sat Jan 05, 2013 4:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8830

PostPosted: Sat Jan 05, 2013 6:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum