LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-30-2007, 02:56 PM   #1
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Rep: Reputation: 15
Lightbulb Problem booting kernel without initial ramdisk


Hi

I've compiled custom kernel from sources: linux-2.6.22, very basic, all necessary modules are build-in. Also I've assumed it boots without initial ramdisk. I've disabled this option in .config. Then I was trying to boot the kernel with the followings GRUB commands:

Code:
root (hd1,0)
kernel (hd1,0)/boot/bzImage root=/dev/hdb1 init=/bin/sh
boot
Where hdb1 is BIOS primary slave IDE drive, so it's second physical hard disk, 10MB. I've formatted it with ext2, created some basic directories (dev,boot,etc,tmp,var...), I've put bzImage, /bin/bash and /bin/sh. So all I want is to boot the kernel and run bash. Kernel have to know that this drive is it's root filesystem (root=...) but I'm afraid it is not so obvious...

And unfortunately I get kernel panic: Could not find /bin/sh, try init=..... But there is /bin/sh for sure. I don't have any idea why it happens, GRUB can see all files in the disk: cat /bin/sh works well, but kernel cannot, why?? What am I doing wrong?

I've tested these GRUB commands with my main Debian filesystem (root hd0,2) and it worked. So I guess it's not a problem with kernel itself but with disk or boot commands.
 
Old 07-30-2007, 05:16 PM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
What is the file system? Are you sure you've got all the necessary modules built into the kernel for this fs? Are there any errors displayed before the error mentioned?
 
Old 07-30-2007, 07:09 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Does it indicate it has successfully mounted the root partition?
 
Old 07-31-2007, 03:11 AM   #4
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
All modules for ext2, ext3, vfat, ntfs, iso also p-ata drivers ale built-in to the kernel. It says: VFS: Filesystem has been mounted as ext2fs (or someting like that, no error here anyway).

I've tried it also with qemu and loop device - the same problem, can't find any file in the root fs.

Does it has something with /dev/* files?? Does the kernel creates all the files inside? or maybe it needs /dev/hd* at least? How does it access to the disk?

{ps.sorry for my english}

Last edited by m4mach; 07-31-2007 at 03:29 AM.
 
Old 07-31-2007, 04:02 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,188

Rep: Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131
Try sdb1 - yes, I know it's not SCSI or SATA, but the naming changed in 2.6.19
 
Old 07-31-2007, 06:15 AM   #6
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
Should I create /dev/sdb1 before?

I repeat my last question, I think very important:
Quote:
Does it has something with /dev/* files?? Does the kernel create all the files inside? or maybe it needs /dev/hd* at least? How does it access to the disk for the first time?
When I pass root=/dev/hdb1 to the kernel, is it looking for a second hard disk in the BIOS, and creates /dev/hdb1 when it found it?

Because the situation changes a lot in 2 cases:

1. Booting The kernel with root=/dev/hda3 - WORKS
2. Booting The kernel with root=/dev/hdb1 - FAILS

Where:
hda3 Main roof fs from Debian dist. First HDD (primary master) 3rd partition, ext3.
hdb1 Second HDD (primary slave) only one partition. Some basic dirs created by me, ext2.

Last edited by m4mach; 07-31-2007 at 06:18 AM.
 
Old 07-31-2007, 06:29 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,188

Rep: Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131Reputation: 4131
Well you are telling it to look at /dev/hdb1 (which appears to exist o.k.) for the root filesystem (rather than /dev/hda3).
Why ???.

My previous suggestion was based on not having the information you just supplied.
 
Old 07-31-2007, 07:05 AM   #8
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
I've copied /dev/hdb, /dev/hdb1 from Debian rootfs to the new rootfs. Later I copied all /dev/* files - no change in both situations, kernel panics.

The only differents are files on rootfs (and drives of course), so does the kernel need some more "special" files on foorfs?

You asked why I dont use Debian rootfs? Well I want to create my own (small, basic) distribution, and learn more about Linux

Last edited by m4mach; 07-31-2007 at 07:53 AM.
 
Old 07-31-2007, 07:38 AM   #9
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Anyway did you try sdb1 instead of hdb1 as suggested?
You should read LFS by the way.
 
Old 07-31-2007, 08:09 AM   #10
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
Yes I've tried. no change

LSF? I'd want to write my own simple scripts rather than read or just execute tons of code written by someone else. I've read the LFS-BOOK but there is not too much on how kernel boot works, some basics but a lot about apps that I don't need at this level.

I think I will start read the kernel Documentations. btw. I'll be grateful if someone helps me a little more...
 
Old 07-31-2007, 08:22 AM   #11
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Does it work with init instead of sh?
(Maybe you lack some dependencies for sh?)

BTW it has nothing to do with /dev/*
Actually, mounting / can't depend on /dev/* which is located inside /

Last edited by Agrouf; 07-31-2007 at 08:23 AM.
 
Old 07-31-2007, 08:32 AM   #12
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
No, it doesn't work with init also. Kernel cannot access to any script/file in this disk.The disk is OK, simple Grub command: cat <file> works fine...

So, theoretically there is no need for ANY files/dirs on root fs apart from any initial app like bash?, but bush can depends on some files, an this files can depend on..etc, btw. what does BASH need to run? maybe here is the problem

Last edited by m4mach; 07-31-2007 at 09:05 AM.
 
Old 07-31-2007, 12:12 PM   #13
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
grub has its own file system reader, which is different from linux one.
If grub can read the fs, it doesn't mean linux can if it doesn't have the modules to mount it.
init has very few dependencies : you need libc and ld.
you can find dependencies of an executable with ldd
ldd /bin/sh
it is not recursive though.
mkinitrd has a function to recurse through dependencies.
What about trying with an initrd image?

Last edited by Agrouf; 07-31-2007 at 12:13 PM.
 
Old 07-31-2007, 04:41 PM   #14
m4mach
Member
 
Registered: Jul 2007
Location: Poland
Distribution: Debian
Posts: 45

Original Poster
Rep: Reputation: 15
How can I install bash (or busybox) into this new rootfs with all dependencies and libs? Becouse if think the problem is that I can't run bash with only /bin/bash executable. I've tried to copy some libs to /lib but no luck, so maybe installation with basic libs will help. Unfortunately compilling bash with: ./configure --prefix=.. didn't work. Any ideas?

Quote:
What about trying with an initrd image?
This is not the solution I'm lookin for. Or did you mean something like create initrd and then copy all files from this image to my rootfs? Hmm.. interesting, I will think

Last edited by m4mach; 07-31-2007 at 04:47 PM.
 
Old 07-31-2007, 05:17 PM   #15
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
I'm not 100% sure this would solve the problem.
To me it looks like it doesn't mount the fs correctly or mounts the wrong fs, because it says :
kernel panic: Could not find /bin/sh
If it was lacking any library, it would complain later I think (not 100% sure)?
And you said init was not working. init doesn't require much.
But you say it's standard IDE and ext2. linux should not have any problem with those.
Anyway you can try your bash in a chrooted environment. If it runs, it should run at boot and whether this is the current problem or not, this will be a problem at one time anyway ; you can write a script to recurse through all the dependencies with ldd.
Try this and please report if that worked or not.
Thanks

Last edited by Agrouf; 07-31-2007 at 05:26 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel panic, Warning: unable to open an initial console while booting 2.6.16.40 prado Linux - Kernel 3 07-01-2009 04:00 PM
booting read only - how do I load /dev files in ramdisk? drkstr Slackware 4 07-19-2006 01:56 AM
kernel build create initial ramdisk htamayo Linux - Software 1 01-07-2005 01:57 PM
Slow booting ramdisk (isolinux) Dark Carnival Linux - General 1 11-09-2004 04:07 PM
bootsplash initial ramdisk error Likosin Linux - Software 2 08-16-2003 02:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration