Page 1 of 1

initrd -> real-root-dev

PostPosted: Tue Oct 21, 2003 8:14 pm
by Stryker
I was wondering if anyone could help me with, yet another, problem i've run into. I have a basic linux filesystem on a CD. I put the isolinux boot loader on it, it boots fine and goes through the kernel stuff, then goes to initrd. My linuxrc file is (basically):

Code: Select all
#!/bin/nash
mount /proc /proc -t proc
mount --ro -t iso9660 /dev/hdb /sysroot
mount --ro -t iso9660 /dev/hdc /sysroot
mount --ro -t iso9660 /dev/hdd /sysroot
mount --ro -t iso9660 /dev/hda /sysroot
echo 0x0100 > /proc/sys/kernel/real-root-dev
umount /proc


in /sysroot before the mounting of the cd, i have the bin/sbin/lib type folders in /sysroot and have a symlink for each of them in /. When the CD mounts it should override the folders in /sysroot and magically /bin points to the /sysroot/bin on the iso9660 filesystem. I tested this by putting a statically linked 'ls' program on the root of initrd and executing it to show the files. But when the linuxrc script finishes I get an error about not finding init, and it suggests passing init= option to the kernel. Surely /sbin/init is there, i've checked (I've wasted several CDs on this project). Does anyone know why it would fail to execute, and how to fix it? I'd appreciate any help.

thanks

PostPosted: Tue Oct 21, 2003 8:23 pm
by Void Main
You don't have any CDRWs? I know they can be a pain in the rear but it might save some CDs. You wouldn't happen to have an ISO available for download would you (or simple instructions for creating an ISO exactly like you have)? You might also check out VMware. You can create your ISO image and boot directly from the image with VMware rather than having to write it to disc.

PostPosted: Tue Oct 21, 2003 8:38 pm
by Stryker
I did get vmware, but I got it 20 CDs too late. 30 day trial so I got 30 days to get this to work...

The files on the cd are just basic linux stuff, everything that's at the end of LFS installation. the initrd.img file can be made with mkinitrd and just modifying the /linuxrc file on it. I would put up an ISO but I'm on dialup, once the CD is finished I plan to have it available for download (my friend will upload it, but i dont want to ask him to do it twice). I used isolinux, a part of syslinux. after making the iso it comes out to be about 386MB, so if its around there its probably right.

oh, and i had to modify the lfs system a little. like removing mtab and symlinking mtab to /proc/mounts and removing most things from /etc/fstab.

PostPosted: Tue Oct 21, 2003 9:56 pm
by Void Main
I don't see where you actually mount your root file system. Here is a linuxrc from one of my initrd files:

Code: Select all
#!/bin/nash
 
echo "Loading jbd.o module"
insmod /lib/jbd.o
echo "Loading ext3.o module"
insmod /lib/ext3.o
echo Mounting /proc filesystem
mount -t proc /proc /proc
echo Creating block devices
mkdevices /dev
echo Creating root device
mkrootdev /dev/root
echo 0x0100 > /proc/sys/kernel/real-root-dev
echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot
pivot_root /sysroot /sysroot/initrd
umount /initrd/proc


As you can see in mine it mounts the root file system and at the end it uses the "pivot_root" command to change the root to the real root file system.

If you are sure your root file system is mounted, but possibly in the wrong path you can pass the kernel the path to init at boot. e.g. "linux init=/sysroot/sbin/init". I have a feeling your root file system is not being remounted properly though...

PostPosted: Tue Oct 21, 2003 11:06 pm
by Stryker
i mounted the cd in /sysroot, and every important directory in / symlinks to /sysroot/<directory>, so after it mounts the initrd files are unavailable as the mount overrode the initrd's files (they were also in /sysroot). I tried using the pivot_root method and got the same response as I do now.

PostPosted: Wed Oct 22, 2003 1:12 am
by Stryker
hmm, whenver I get stumped like this... I never -ever- find the solution unless I post it up on a forum. It was a simple mistake, I forgot to use the -f parameter with the mkisofs command and some sym-links in /lib weren't put in the iso. but now i've run into a new problem. well, i saw it before but didnt think it'd stop me. "Warning: unable to open an initial console." After getting this I tried using MAKEDEV again to make it, no hope with that. I would try mknod but it's a read-only filesystem and I dont think I can. Any suggestions?

PostPosted: Wed Oct 22, 2003 7:00 am
by Void Main
How does Knoppix do it?

PostPosted: Wed Oct 22, 2003 4:55 pm
by Stryker
I asked a friend to get my knoppix so I could have a look at it, see how it works. I fixed the console thing, I'm not sure how... but everything's great now. Thanks