[Th] geninitrd borked?

Łukasz Jernaś deejay1 at srem.org
Tue Dec 19 23:12:11 CET 2006


Dnia wtorek, 19 grudnia 2006 22:18, Cezary Krzyzanowski napisał:
> 1. Is the generated image initrd, or initramfs (should be the later).

With latest geninitrd from th-test:
[root at betty ~]# geninitrd -v --without-bootsplash -f initrd.gz 2.6.16.36-1
Finding IDE modules using ide_hostadapter
Finding IDE modules using PCI ID database
Using modules:  kernel/drivers/ide/ide-core.ko.gz 
kernel/drivers/ide/pci/piix.ko.gz kernel/drivers/ide/ide-disk.ko.gz 
kernel/fs/reiserfs/reiserfs.ko.gz
/bin/initrd-busybox -> /tmp/initrd.IodYzw/bin/initrd-busybox
Loading module [ide-core] without options.
Loading module [piix] without options.
Loading module [ide-disk] without options.
Loading module [reiserfs] without options.
Adding rootfs finding based on root= option support.
1276 bloków

init:
#! /bin/sh

set -x
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/ide-core.ko 
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/pci/piix.ko 
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/ide-disk.ko 
insmod /lib/modules/2.6.16.36-1/kernel/fs/reiserfs/reiserfs.ko 
set +x
mount -t proc none /proc
root="$(busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); 
gsub(/ .*/,NIL,$0); print $0; } ' /proc/cmdline)"
if [ -n "$root" ]; then
	rootnr="$(busybox awk -v root="$root" ' { if ($4 == root) { print 
256*$1+$2; } } ' /proc/partitions)"
	if [ -n "$rootnr" ]; then
		echo "$rootnr" > /proc/sys/kernel/real-root-dev
	fi
fi
umount /proc
set -x
set +x
mount -t proc none /proc
root="$(busybox awk -v prefix="root=" ' \
function separate_root ( txt ) \
{ \
    gsub(/.*root=/,NIL,txt); \
    gsub(/ .*/,NIL,txt); \
    return txt \
} \
BEGIN { \
    num_pattern = "[0-9][0-9][0-9][0-9]"; \
    dev_pattern = "[hms][a-z][a-z]([0-9])+"; \
    partition = "Metallica rocks!"; \
    min = -1; maj = -1; \
} \
$0 ~ prefix "0x" num_pattern { sub(/root=0x/,"root="); } \
$0 ~ prefix num_pattern { \
    gsub(/.*root=/,NIL,partition); \
    gsub(/ .*/,NIL,partition); \
    partition = separate_root( $0 ); \
    maj = sprintf("%d",substr(partition,1,2)); \
    min = sprintf("%d",substr(partition,3)); \
} \
$0 ~ prefix "\/dev\/" dev_pattern { sub(/root=\/dev\//,"root="); } \
$0 ~ prefix dev_pattern { \
    partition = separate_root( $0 ); \
} \
$4 ~ partition { maj = $1; min = $2; } \
$1 ~ maj && $2 ~ min { partition = $4; } \
END { print sprintf("/dev/%s %d %d", partition, maj, min); }
' /proc/cmdline /proc/partitions)"
device=${root% * *}
maj=${root#* }
maj=${maj% *}
min=${root#* * }
set -x
if [ ! -b $device ]; then
	mknod $device b $maj $min
fi
mount -t reiserfs $device /newroot 
init="$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); 
print $0; }  ' /proc/cmdline )"
if [ -z "$init" -o ! -x "/newroot$init" ]; then
	init=/sbin/init
fi
umount /proc
exec switch_root /newroot $init


linuxrc:
#! /bin/sh

set -x
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/ide-core.ko 
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/pci/piix.ko 
insmod /lib/modules/2.6.16.36-1/kernel/drivers/ide/ide-disk.ko 
insmod /lib/modules/2.6.16.36-1/kernel/fs/reiserfs/reiserfs.ko 
set +x
mount -t proc none /proc
root="$(busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); 
gsub(/ .*/,NIL,$0); print $0; } ' /proc/cmdline)"
if [ -n "$root" ]; then
	rootnr="$(busybox awk -v root="$root" ' { if ($4 == root) { print 
256*$1+$2; } } ' /proc/partitions)"
	if [ -n "$rootnr" ]; then
		echo "$rootnr" > /proc/sys/kernel/real-root-dev
	fi
fi
umount /proc
set -x
set +x
mount -t proc none /proc
root="$(busybox awk -v prefix="root=" ' \
function separate_root ( txt ) \
{ \
    gsub(/.*root=/,NIL,txt); \
    gsub(/ .*/,NIL,txt); \
    return txt \
} \
BEGIN { \
    num_pattern = "[0-9][0-9][0-9][0-9]"; \
    dev_pattern = "[hms][a-z][a-z]([0-9])+"; \
    partition = "Metallica rocks!"; \
    min = -1; maj = -1; \
} \
$0 ~ prefix "0x" num_pattern { sub(/root=0x/,"root="); } \
$0 ~ prefix num_pattern { \
    gsub(/.*root=/,NIL,partition); \
    gsub(/ .*/,NIL,partition); \
    partition = separate_root( $0 ); \
    maj = sprintf("%d",substr(partition,1,2)); \
    min = sprintf("%d",substr(partition,3)); \
} \
$0 ~ prefix "\/dev\/" dev_pattern { sub(/root=\/dev\//,"root="); } \
$0 ~ prefix dev_pattern { \
    partition = separate_root( $0 ); \
} \
$4 ~ partition { maj = $1; min = $2; } \
$1 ~ maj && $2 ~ min { partition = $4; } \
END { print sprintf("/dev/%s %d %d", partition, maj, min); }
' /proc/cmdline /proc/partitions)"
device=${root% * *}
maj=${root#* }
maj=${maj% *}
min=${root#* * }
set -x
if [ ! -b $device ]; then
	mknod $device b $maj $min
fi
mount -t reiserfs $device /newroot 
init="$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); 
print $0; }  ' /proc/cmdline )"
if [ -z "$init" -o ! -x "/newroot$init" ]; then
	init=/sbin/init
fi
umount /proc
exec switch_root /newroot $init


-- 
Łukasz [DeeJay1] Jernaś

P.S. Sorry for copy&pasting but kmail from Th seems to crash when trying to 
add an attachment...


More information about the pld-devel-en mailing list