tech-embed archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: init problem [was: Re: Tests of mdsetimage -s]



On Sat, 2 Apr 2005 16:02:13 +0200 (CEST)
Hubert Feyrer <hubert%feyrer.de@localhost> wrote:

> On Sat, 2 Apr 2005, Marcin Jessa wrote:
> > I copied over /sbin/init to my image's /sbin/oinit and it still does not 
> > execute ...
> ...
> > warning: no /dev/console
> > exec /sbin/init: error 8
> > init: trying /sbin/oinit
> >
> > Then it just hangs ...
> 
> There are two problems here:
> #1: no /dev/console
> #2: /sbin/init giving error 8
> 
> For #1: Either you populate /dev on your disk properly, or you don't. In 
> the latter case, init(8) (which gets ran by the kernel, at least normally 
> :) does some mfs magic and runs some MAKEDEV script on it's own. If you 
> make your own helloworld-style init program, chances are good that all 
> that just won't happen, and thus things fail mysteriously.

This is what happens when I boot the ramdisk created for netbsd boot floppy 
inserted into my custom kernel:

root file system type: ffs                       
warning: no /dev/console  
init: Creating mfs /dev (374 blocks, 896 inodes)

Then it proceedes so it does not seem to be a problem...
You are correct. The init file creates all the /dev entries after the 
/dev/console warning.
My own init was created just to see if my ramdisk gets loaded and if the kernel 
even tries to execute init.


> 
> For #2: This is the problem that your init(8) doesn't get loaded in the 
> first place. Error 8 means (according to /usr/include/sys/errno.h):
> 
>       #define ENOEXEC         8               /* Exec format error */
> 
> i.e. the kernel cannot load either your /sbin/init, or (my wild guess) 
> there's some trouble with shared libraries. Is /libexec/ld.elf_so there? 
> Execute permissions ok? Are all the libraries there? Permissions ok? ...

Yes, I ran ldd on all the bins I included in the build and libexex/ld.elf_so 
along with all the other libs are in place:
# pwd
/home/yazzy/wifibsd/image/libexec
# ls -l 
total 55
-r-xr-xr-x  1 root  wheel  55812 Apr  1 21:03 ld.elf_so


>Just for kicks, is your /bin/sh ok? (Not that that code path should be 
> entered here in the first place...).

I also tried the crunched bins of the NetBSD floppy disk instead of dynamically 
linked ones:
# file sbin/init 
sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 
2.0, statically linked, stripped
# file bin/sh 
bin/sh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 
2.0, statically linked, stripped


> Other questions that come to mind (and which may help you debugging:
> What does "file init" say?
> What does "ldd init" say?
> (Running both on the build system should be OK)

# file init 
init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 2.0, 
dynamically linked (uses shared libs), not stripped

# ldd init 
init:
         -lc.12 => /usr/lib/libc.so.12

# file libexec/ld.elf_so 
libexec/ld.elf_so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), 
not stripped

# file usr/lib/libc.so.12 
usr/lib/libc.so.12: symbolic link to `/lib/libc.so.12.114.1'

# file lib/libc.so.12.114.1 
lib/libc.so.12.114.1: ELF 32-bit LSB shared object, Intel 80386, version 1 
(SYSV), not stripped


The last idea I something I picked up from the Notes section of Brian Rose's 
howto: 
http://brianrose.net/family/fetch.php?dir=/Brian/NetBSD/Embedded&filename=boot_floppy.html
"From what I have read, disklabel should not be run on virtual devices. So, to 
keep the system from complaining about the lack of a disklabel, you can create 
an empty disk image. Then instead of the dd input file being /dev/zero, you can 
use your empty floppy image (with a disklabel) instead."

But then how do I build an image for CF instead of a floppy?
What I do is:

# dd if=/dev/zero of=wifibsd.bin bs=1k count=15000
# vnconfig -v -c vnd0 wifibsd.bin
# disklabel -R -r vnd0 disklabel.proto
# newfs -m 0 vnd0a ; newfs -m 0 vnd0d
# /usr/sbin/installboot -v -m i386 -o timeout=3,console=com0 -t ffs /dev/rvnd0a 
/usr/mdec/bootxx_ffsv1
# mount /dev/vnd0a /mnt
# cp /usr/mdec/boot /mnt/ ; cp netbsd /mnt/
# umount /mnt
# vnconfig -u vnd0

My disklabel.proto :

# /dev/rvnd0d:
type: vnd
disk: vnd
label: wifibsd   
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 14
total sectors: 30000
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:     30000         0     4.2BSD      0     0     0  # (Cyl.      0 -     14*)
 d:     30000         0     4.2BSD      0     0        # (Cyl.      0 -     14*)





Home | Main Index | Thread Index | Old Index