Click to See Complete Forum and Search --> : [SOLVED] kernel .config for LFS live cd
Exodus2001
08-07-2005, 08:59 PM
I'm trying to make a live cd of my LFS 6.0 installation. I keep getting kernel panics. It has to be something I'm over-looking when I'm building the kernel for the cd. I beleive I have everything I need like Ram disk support, initrd support, loopback, rom file system, and sysctl is off. I'm not using any modules and the kernel will boot the system when booting from the hard disk.
Does anybody have any I idea what might be going wrong? If some could give me a kernel config from a LFS live cd that would help alot.
I'm getting:
cannot create directory '/dev/pts' : read-only file system
cannot create directory '/dev/shm' : read-only file system
No LFS cd found
Kernel panic - not syncing: Attempt to kill init
and a bunch of other stuff about not being able to load shared libraries above that. Ya' know it being a read only fs and all, it doesn't give me a very good log file. :p
udev? bad ram device nodes? bad kernel config? I'm stupid?
7 cds down the drain already :mad:
I'm not sure but I think that it has to do something with udev.
bwkaz
08-08-2005, 07:42 PM
cannot create directory '/dev/pts' : read-only file system
cannot create directory '/dev/shm' : read-only file system Well, /dev should probably be either a tmpfs or a ramfs. This will make it not be read-only anymore. Your initrd script will have to mount the tmpfs or ramfs on /dev first, then try to make these directories.
No LFS cd found This is odd... do you know what part of the initrd (or init scripts) are producing this message?
Kernel panic - not syncing: Attempt to kill init
and a bunch of other stuff about not being able to load shared libraries above that. OK, I doubt that it's the kernel. It's probably the initrd image instead.
This message (attempt to kill init) gets logged when the init process dies. So what are you passing to the kernel for the value of init from your CD's bootloader? I don't know a lot about initrds, but I think the kernel loads some script in there as init first, then the script does a pivot_root "back" to your main (CD?) FS.
What shared libraries is it complaining about? Do you know what program it's running when it complains? Maybe you could modify the initrd to print some informative messages near each command that it runs, so you can see how far it gets?
Exodus2001
08-09-2005, 11:22 PM
To create the first ram device I put:
dev_ram=/dev/ram1
/sbin/mke2fs -m 0 -i 1024 -q $dev_ram > /dev/null 2>&1
When it boots it says it can't find:
libblkid.so.1
It does exsist and is located in /lib.
So it must be a problem with E2fsprogs. I believe the ram disk is'nt working at all and that's why nothing is being mounted.
I'm going to look into posible proplems with E2fsprogs. I cross compiled the entire OS for i486 and I might have dorked something up.
More fun...
bwkaz
08-10-2005, 09:29 PM
To create the first ram device I put:
dev_ram=/dev/ram1
/sbin/mke2fs -m 0 -i 1024 -q $dev_ram > /dev/null 2>&1 OK, that looks (probably) all right. (Unless you got errors. You wouldn't have seen them, because this command dumps them to /dev/null, but they probably would have been important...)
What did you subsequently put onto that ramdisk?
Exodus2001
08-11-2005, 10:55 PM
Ext2 and Udev are not the problem. It took me a day, but they have been ruled out.
First I mounted the loop:
export LIVECD=/mnt/lfs
mount -o loop $LIVECD/boot/initrd $LIVECD/mnt
cd $LIVECD/mnt
This is what I put into the initrd image:
mkdir bin sbin lib dev proc mnt sys etc
cp -a $LIVECD/bin/{bash,mount,grep,umount,echo,ln,mkdir} bin/
cp -a $LIVECD/sbin/udev* sbin/
cp -a $(find $LIVECD -name "test" -type f) bin/
cp -a $(find $LIVECD -name "chroot" -type f) bin/
cp -a $(find $LIVECD -name "pivot_root" -type f) bin/
cp -H $LIVECD/lib/{libncurses.so.5,libdl.so.2,libc.so.6,ld-linux.so.2} lib/
cp -H $LIVECD/lib/{libreadline.so.5.0,libhistory.so.5.0} lib/
cp -a $LIVECD/dev/{console,null,ram{0,1,2}} dev/
cp -a $LIVECD/etc/{udev,dev.d,hotplug.d} etc/
ln -s bash bin/sh
ln -s test bin/[
And a script called linuxrc:
#!/bin/sh
ID="livecd"
TMP_MOUNT="/mnt"
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
CHECK_TYPE="try_mount"
if [ ! -d "/proc/" ]; then
mkdir /proc
fi
mount -n proc /proc -t proc
if grep -q '[[:space:]]sysfs' /proc/filesystems; then
if [ ! -d /sys/block ]; then
mount -n sysfs /sys -t sysfs
fi
fi
make_extra_nodes() {
ln -s /proc/self/fd /dev/fd
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
ln -s /proc/self/fd/2 /dev/stderr
ln -s /proc/kcore /dev/core
mkdir /dev/pts
mkdir /dev/shm
}
if [ ! -x /sbin/hotplug ]; then
echo /sbin/udev > /proc/sys/kernel/hotplug
fi
mount -n ramfs /dev -t ramfs
/sbin/udevstart
make_extra_nodes
CDROM_LIST=""
for ide_channel in /proc/ide/ide[0-9]
do
if [ ! -d "$ide_channel" ]; then
break
fi
for ide_device in hda hdb hdc hdd hde hdf hdg hdh hdi hdj hdk hdl hdm hdn
do
device_media_file="$ide_channel/$ide_device/media"
if [ -e "$device_media_file" ]; then
grep -i "cdrom" $device_media_file > /dev/null 2>&1
if [ $? -eq 0 ]; then
CDROM_LIST="$CDROM_LIST /dev/$ide_device"
fi
fi
done
done
for scsi_cdrom in /dev/scd[0-99]
do
if [ -e "$scsi_cdrom" ]; then
CDROM_LIST="$CDROM_LIST $scsi_cdrom"
fi
done
LFS_CDROM_DEVICE=""
for cdrom_device in $CDROM_LIST
do
if [ "$CHECK_TYPE" = "try_mount" ]; then
mount -n -t iso9660 ${cdrom_device} $TMP_MOUNT
# > /dev/null 2>&1
media_found=$?
fi
if [ $media_found -eq 0 ]; then
echo -n "media found"
if [ "$CHECK_TYPE" = "try_mount" ]; then
[ -e "$TMP_MOUNT/$ID" ]
media_lfs=$?
fi
if [ "$CHECK_TYPE" = "isoinfo" ]; then
isoinfo -d -i $cdrom_device | grep -i "Volume id:" | grep "$ID" \
> /dev/null 2>&1
media_lfs=$?
if [ $media_lfs -ne 0 ]; then
isoinfo -V $cdrom_device | grep "$ID" > /dev/null 2>&1
media_lfs=$?
fi
fi
if [ "$CHECK_TYPE" = "try_mount" ]; then
umount -n $cdrom_device > /dev/null 2>&1
fi
if [ $media_lfs -eq 0 ]; then
echo ", LFS boot CD found. Ready!"
LFS_CDROM_DEVICE="$cdrom_device"
break;
else
echo ", not LFS boot CD."
fi
else
echo "no media "
fi
done
if [ "$LFS_CDROM_DEVICE" = "" ]; then
echo "No LFS boot CD found!!!"
exit 1
else
echo "Booting from $LFS_CDROM_DEVICE..."
mount -n -o ro -t iso9660 $LFS_CDROM_DEVICE $TMP_MOUNT
cd $TMP_MOUNT
pivot_root . mnt
umount -n /mnt/proc >/dev/null 2>&1
exec chroot . sh -c 'umount -n /mnt >/dev/null 2>&1; exec -a init.new /sbin/init 3' <dev/console >dev/console 2>&1
fi
And then I ran chmod on linuxrc, unmounted /mnt/lfs/mnt and gziped the initrd:
chmod 0755 $LIVECD/mnt/linuxrc
cd $LIVECD/
umount $LIVECD/mnt
gzip $LIVECD/boot/initrd
bwkaz
08-12-2005, 06:58 PM
I'm getting:
cannot create directory '/dev/pts' : read-only file system
cannot create directory '/dev/shm' : read-only file system
No LFS cd found Are you getting anything before this? If you're using the linuxrc that you posted, you should be. It should be printing something like:
no media
media found, not LFS boot CD
media found, LFS boot CD found. Ready!
(Or maybe just one of those.)
Which of those are you seeing, and in what order?
Also, maybe you didn't notice, but this script checks for a "livecd" file in the root of the CD filesystem before it declares the CD to be the LFS boot CD. Make sure that file exists.
Exodus2001
08-12-2005, 08:52 PM
I took some time and wrote down the output with a pen and paper. The high tech way. :cool:
This is all I can see:
intel I8x0: clocking to 48000
ALSA device list:
#0: Intel 82801DB-ICH4 at 0xe210100, irq 11
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem) read-only.
Freeing unused kernel memory: 128k freed
mount: error while loading shared libraries: liblkid.so.1: cannot open shared object file: No such file or directory
grep: /proc/filesystems: No such file or directory
/linuxrc: line 49: /proc/sys/kernel/hotplug: No such file or directory
mount: error while loading shared libraries: liblkid.so.1: cannot open shared object file: No such file or directory
ln: creating symbolic link '/dev/fd' to '/proc/self/fd': Read-only file system
ln: creating symbolic link '/dev/stdin' to '/proc/self/fd/0': Read-only file system
ln: creating symbolic link '/dev/stdout' to '/proc/self/fd/1': Read-only file system
ln: creating symbolic link '/dev/stderr' to '/proc/self/fd/2': Read-only file system
ln: creating symbolic link '/dev/core' to '/proc/kcore': Read-only file system
cannot create directory '/dev/pts' : read-only file system
cannot create directory '/dev/shm' : read-only file system
No LFS cd found
Kernel panic - not syncing: Attempt to kill init
...Freeing unused kernel memory: 128k freed...
The kernel is working
mount: error while loading shared libraries: liblkid.so.1...
tries to mount /dev/ram1?
grep: /proc/filesystems...
Some how this weasled it way into the output?
mount: error while loading shared libraries: liblkid.so.1...
tries to mount /dev/ram2?
ln: creating symbolic link '/dev/fd'...
is /dev mounted ram0? It created the symlinks without error
cannot create directory '/dev/pts' : read-only file system...
no clue. Did ram0 run out of space?
No LFS cd found...
Udev never started because /dev/sys was never mounted?
libblkid.so.1 not being found has got to be the reason the other 2 ram disks are not getting mounted. The block device is not being "IDed"?:D I don't think it's even getting to the point where it is supposed to mount /proc in the first place.
E2fsprogs and Udev recompiled without errors. Is it possible something is wrong with Binutils or Glibc?
By the way, this is the first time I've ever had my butt kicked by one of these shinny electric interweb boxxes. :)
bwkaz
08-13-2005, 09:24 AM
mount: error while loading shared libraries: liblkid.so.1: cannot open shared object file: No such file or directory
grep: /proc/filesystems: No such file or directory
mount: error while loading shared libraries: liblkid.so.1...
tries to mount /dev/ram1? No, it's trying to mount /proc.
You don't have all the libraries in the initrd that are required for the "mount" binary that the initrd is using. Copy libblkid.so into the initrd, and try again.
Actually, run ldd /path/to/mount (on wherever the initrd's mount binary is sitting), to make sure it doesn't require any other libraries that you don't have on the initrd.
You can't just copy the binaries -- you have to copy all the libraries that those binaries need, too.
grep: /proc/filesystems...
Some how this weasled it way into the output? It's in the script. But since /proc isn't mounted (because mount would not start, because it was missing one of its dependent libs), there is no /proc/filesystems file.
mount: error while loading shared libraries: liblkid.so.1...
tries to mount /dev/ram2? Likely the /dev directory, actually. But it's the same problem as above -- you need to copy libblkid.so.1.whatever into the initrd (along with any other libraries that mount, or any of the other binaries in the initrd, require).
Exodus2001
08-13-2005, 05:33 PM
Well I tried adding those libs before and I got the same error. What I did do was pretty stupid. I miss copied the libs into the initrd image.
Check this out for example:
export LIVECD=/mnt/lfs
cp -H $LIVECD/lib/libdl.so.2 lib/
libdl.so.2 is the symlink, not the lib itself
so instead I:
export LIVECD=/mnt/lfs
cp -H $LIVECD/lib/libdl.so.2 lib/
cp -H $LIVECD/lib/libdl-2.3.4.so lib/
It accually made it past the libblk.so.1 error and then said it was missing libuuid.so.1. So I added that too.
It now works!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !
Thanks alot bwkaz, I wonder how many more times I would have missed this mistake if you didn't suggest adding the other libs. Suggesting ldd comand was the savior.
Thanks, Thanks, Thanks, Thanks, Thanks...
This are my notes for creating the cd from begining to end:
#set up variables
export LIVECD=/mnt/lfs
export CDDEV=/dev/hdb7
export ISODIR=/sources/exodus
#make ram disk directories
mkdir -p $LIVECD/fake/{needwrite,ramdisk}
cd $LIVECD/
mv dev/ etc/ home/ root/ tmp/ var/ fake/needwrite/
#replace moved directories with symlinks
cd $LIVECD/
ln -s fake/needwrite/dev dev
ln -s fake/needwrite/var var
ln -s fake/needwrite/tmp tmp
ln -s fake/needwrite/root root
ln -s fake/needwrite/home home
ln -s fake/needwrite/etc etc
#init script to create the ramdisks
cat > $LIVECD/etc/rc.d/init.d/create_ramdisk << "EOF"
#!/bin/sh
dev_ram=/dev/ram1
dev_ram2=/dev/ram2
dir_ramdisk=/fake/ramdisk
dir_needwrite=/fake/needwrite
source /etc/rc.d/init.d/functions
case "$1" in
start)
echo "Creating ext2fs on $dev_ram..."
/sbin/mke2fs -m 0 -i 1024 -q $dev_ram > /dev/null 2>&1
evaluate_retval
sleep 1
echo "Mounting ramdisk on $dir_ramdisk..."
mount -n $dev_ram $dir_ramdisk -t ext2
evaluate_retval
sleep 1
echo "Copying files to ramdisk..."
cp -a $dir_needwrite/* $dir_ramdisk > /dev/null 2>&1
evaluate_retval
sleep 1
echo "Creating second ramdisk"
/sbin/mke2fs -m 0 -i 1024 -q $dev_ram2 > /dev/null 2>&1
evaluate_retval
sleep 1
echo "Mounting second ram disk"
mount -n $dev_ram2 $dir_needwrite -t ext2
evaluate_retval
sleep 1
echo "Copying files to the second ram disk"
cp -a $dir_ramdisk/* $dir_needwrite
evaluate_retval
sleep 1
echo "Unmounting and clearing first ram disk"
umount -n $dir_ramdisk > /dev/null 2>&1
blockdev --flushbufs /dev/ram1
evaluate_retval
sleep 1
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac
EOF
#make it executable
chmod 0755 $LIVECD/etc/rc.d/init.d/create_ramdisk
#create symlink for sysinit
cd $LIVECD/etc/rc.d/rcsysinit.d
ln -s ../init.d/create_ramdisk S00create_ramdisk
#syslinux installation
mkdir $LIVECD/isolinux
cp syslinux-3.09/isolinux.bin $LIVECD/isolinux
mv $LIVECD/boot/* $LIVECD/isolinux
cd $LIVECD/
rmdir boot
ln -s isolinux boot
#isolinux config
cat > $LIVECD/isolinux/isolinux.cfg << "EOF"
default livecd
label livecd
kernel exoduskernel
append initrd=initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=16384
EOF
#remove sysinits I don't need
rm $LIVECD/etc/rc.d/rc3.d/S20network
rm $LIVECD/etc/rc.d/rc0.d/K80network
rm $LIVECD/etc/rc.d/rc6.d/K80network
rm $LIVECD/etc/rc.d/rcsysinit.d/S40mountfs
rm $LIVECD/etc/rc.d/rcsysinit.d/S30checkfs
#make initrd
dd if=/dev/zero of=$LIVECD/boot/initrd bs=1024 count=7144
mke2fs -m 0 -i 1024 -F $LIVECD/boot/initrd
#mount the loop device to create the initrd image
mount -o loop $LIVECD/boot/initrd $LIVECD/mnt
#move the files to temp mnt
cd $LIVECD/mnt
mkdir bin
mkdir sbin
mkdir lib
mkdir dev
mkdir proc
mkdir mnt
mkdir sys
mkdir etc
cp -a $LIVECD/bin/bash bin/
cp -a $LIVECD/bin/mount bin/
cp -a $LIVECD/bin/grep bin/
cp -a $LIVECD/bin/umount bin/
cp -a $LIVECD/bin/echo bin/
cp -a $LIVECD/bin/ln bin/
cp -a $LIVECD/bin/mkdir bin/
cp -a $LIVECD/sbin/udev* sbin/
cp -a $(find $LIVECD -name "test" -type f) bin/
cp -a $(find $LIVECD -name "chroot" -type f) bin/
cp -a $(find $LIVECD -name "pivot_root" -type f) bin/
cp -H $LIVECD/lib/ld-2.3.4.so lib/
cp -H $LIVECD/lib/ld-linux.so.2 lib/
cp -H $LIVECD/lib/libblkid.so.1 lib/
cp -H $LIVECD/lib/libblkid.so.1.0 lib/
cp -H $LIVECD/lib/libc-2.3.4.so lib/
cp -H $LIVECD/lib/libc.so.6 lib/
cp -H $LIVECD/lib/libdl-2.3.4.so lib/
cp -H $LIVECD/lib/libdl.so.2 lib/
cp -H $LIVECD/lib/libhistory.a lib/
cp -H $LIVECD/lib/libhistory.so lib/
cp -H $LIVECD/lib/libhistory.so.5 lib/
cp -H $LIVECD/lib/libhistory.so.5.0 lib/
cp -H $LIVECD/lib/libncurses.so.5 lib/
cp -H $LIVECD/lib/libncurses.so.5.4 lib/
cp -H $LIVECD/lib/libreadline.a lib/
cp -H $LIVECD/lib/libreadline.so lib/
cp -H $LIVECD/lib/libreadline.so.5 lib/
cp -H $LIVECD/lib/libreadline.so.5.0 lib/
cp -H $LIVECD/lib/libuuid.so.1 lib/
cp -H $LIVECD/lib/libuuid.so.1.2 lib/
cp -a $LIVECD/dev/console dev/
cp -a $LIVECD/dev/null dev/
cp -a $LIVECD/dev/ram0 dev/
cp -a $LIVECD/dev/ram1 dev/
cp -a $LIVECD/dev/ram2 dev/
cp -a $LIVECD/etc/udev etc/
cp -a $LIVECD/etc/dev.d etc/
cp -a $LIVECD/etc/hotplug.d etc/
ln -s bash bin/sh
ln -s test bin/[
#create the linuxrc file
cat > $LIVECD/mnt/linuxrc << "EOF"
#!/bin/sh
ID="livecd"
TMP_MOUNT="/mnt"
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
CHECK_TYPE="try_mount"
if [ ! -d "/proc/" ]; then
mkdir /proc
fi
mount -n proc /proc -t proc
if grep -q '[[:space:]]sysfs' /proc/filesystems; then
if [ ! -d /sys/block ]; then
mount -n sysfs /sys -t sysfs
fi
fi
make_extra_nodes() {
ln -s /proc/self/fd /dev/fd
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
ln -s /proc/self/fd/2 /dev/stderr
ln -s /proc/kcore /dev/core
mkdir /dev/pts
mkdir /dev/shm
}
if [ ! -x /sbin/hotplug ]; then
echo /sbin/udev > /proc/sys/kernel/hotplug
fi
mount -n ramfs /dev -t ramfs
/sbin/udevstart
make_extra_nodes
CDROM_LIST=""
for ide_channel in /proc/ide/ide[0-9]
do
if [ ! -d "$ide_channel" ]; then
break
fi
for ide_device in hda hdb hdc hdd hde hdf hdg hdh hdi hdj hdk hdl hdm hdn
do
device_media_file="$ide_channel/$ide_device/media"
if [ -e "$device_media_file" ]; then
grep -i "cdrom" $device_media_file > /dev/null 2>&1
if [ $? -eq 0 ]; then
CDROM_LIST="$CDROM_LIST /dev/$ide_device"
fi
fi
done
done
for scsi_cdrom in /dev/scd[0-99]
do
if [ -e "$scsi_cdrom" ]; then
CDROM_LIST="$CDROM_LIST $scsi_cdrom"
fi
done
LFS_CDROM_DEVICE=""
for cdrom_device in $CDROM_LIST
do
if [ "$CHECK_TYPE" = "try_mount" ]; then
mount -n -t iso9660 ${cdrom_device} $TMP_MOUNT
# > /dev/null 2>&1
media_found=$?
fi
if [ $media_found -eq 0 ]; then
echo -n "media found"
if [ "$CHECK_TYPE" = "try_mount" ]; then
[ -e "$TMP_MOUNT/$ID" ]
media_lfs=$?
fi
if [ "$CHECK_TYPE" = "isoinfo" ]; then
isoinfo -d -i $cdrom_device | grep -i "Volume id:" | grep "$ID" \
> /dev/null 2>&1
media_lfs=$?
if [ $media_lfs -ne 0 ]; then
isoinfo -V $cdrom_device | grep "$ID" > /dev/null 2>&1
media_lfs=$?
fi
fi
if [ "$CHECK_TYPE" = "try_mount" ]; then
umount -n $cdrom_device > /dev/null 2>&1
fi
if [ $media_lfs -eq 0 ]; then
echo ", EXODUS boot CD found. Ready!"
LFS_CDROM_DEVICE="$cdrom_device"
break;
else
echo ", not EXODUS boot CD."
fi
else
echo "no media "
fi
done
if [ "$LFS_CDROM_DEVICE" = "" ]; then
echo "No EXODUS boot CD found!!!"
exit 1
else
echo "Booting from $LFS_CDROM_DEVICE..."
mount -n -o ro -t iso9660 $LFS_CDROM_DEVICE $TMP_MOUNT
cd $TMP_MOUNT
pivot_root . mnt
umount -n /mnt/proc >/dev/null 2>&1
exec chroot . sh -c 'umount -n /mnt >/dev/null 2>&1; exec -a init.new /sbin/init 3' <dev/console >dev/console 2>&1
fi
EOF
#make it executable
chmod 0755 $LIVECD/mnt/linuxrc
#unmount the initrd image
cd $LIVECD/
umount $LIVECD/mnt
gzip $LIVECD/boot/initrd
#create iso image
touch $LIVECD/livecd
cd $LIVECD/
mkisofs -R -l -L -D -b isolinux/isolinux.bin -o $ISODIR/EXODUS-0.1.iso -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "livecd" $LIVECD