I recently decided to switch to a pure udev system while still using genkernel to compile my kernel, and using the bootsplash patch when booting. This raised two problem: 1. the generated kernel+initrd couple does not boot when compiled without devfs as the initrd lacks udev support 2. when generated initrd is patched to boot (by adding the missing udev support) there is problem with the bootsplash as /dev/fb/0 is missing So, I decided hacked genkernel so that the generated initrd supports udev. It is still crude as the udev support only work when booting on the user harddrive, not for livecd (but it should not be to hard to do, just some additional modification in the linuxrc script), but it "works for me." The patch is (please note that the tarball for udev is taken from the udev ebuild): ------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------ diff -Nru genkernel-3.0.2a.old/gen_compile.sh genkernel-3.0.2a/gen_compile.sh --- genkernel-3.0.2a.old/gen_compile.sh 2004-03-27 01:00:00.000000000 +0100 +++ genkernel-3.0.2a/gen_compile.sh 2004-04-28 23:11:24.762972536 +0200 @@ -433,3 +433,38 @@ rm -rf "${TEMP}/diet" > /dev/null fi } + +compile_udev() { + + local options destdir + destdir="${TEMP}/udev" + options="USE_KLIBC=true USE_LOG=false DEBUG=false udevdir=/dev" + + if [ ! -f "${UDEV_BINCACHE}" ] + then + cd "${TEMP}" + rm -rf "${UDEV_DIR}" "${destdir}" + [ ! -f "${UDEV_SRCTAR}" ] && gen_die "Could not find udev tarball: ${UDEV_SRCTAR}" + tar -jxpf "${UDEV_SRCTAR}" || gen_die "Could not extract udev tarball" + [ ! -d "${UDEV_DIR}" ] && gen_die "Udev tarball ${UDEV_SRCTAR} is invalid" + + cd "${UDEV_DIR}" + print_info 1 "udev: >> Compiling..." + ln -snf "${KERNEL_DIR}" "klibc/linux" || gen_die "Could not link to ${KERNEL_DIR}" + compile_generic "${options} all etc/udev/udev.conf" utils + + print_info 1 " >> Installing..." + install -d "${destdir}/etc/udev" "${destdir}/sbin" || gen_die "Could not create directory hierarchy" + install -m 0755 "udev" "${destdir}/sbin" || gen_die "Could not install udev binary" + install -m 0644 "etc/udev/udev.conf" "etc/udev/udev.rules" \ + "etc/udev/udev.permissions" "${destdir}/etc/udev" || gen_die "Could not install udev configuration" + + cd "${destdir}" + print_info 1 " >> Copying to bincache..." + tar -jcpf "${UDEV_BINCACHE}" "." || gen_die "Could not create binary cache" + + cd "${TEMP}" + rm -rf "${TEMP}/udev" + rm -rf "${UDEV_DIR}" + fi +} diff -Nru genkernel-3.0.2a.old/gen_determineargs.sh genkernel-3.0.2a/gen_determineargs.sh --- genkernel-3.0.2a.old/gen_determineargs.sh 2004-03-20 21:59:25.000000000 +0100 +++ genkernel-3.0.2a/gen_determineargs.sh 2004-04-26 02:36:18.000000000 +0200 @@ -91,6 +91,7 @@ DIETLIBC_BINCACHE_TEMP=`arch_replace "${DIETLIBC_BINCACHE_TEMP}"` DEVFSD_BINCACHE=`arch_replace "${DEVFSD_BINCACHE}"` DEVFSD_CONF_BINCACHE=`arch_replace "${DEVFSD_CONF_BINCACHE}"` + UDEV_BINCACHE=`arch_replace "${UDEV_BINCACHE}"` if [ "${CMD_BOOTSPLASH}" != "" ] then diff -Nru genkernel-3.0.2a.old/gen_initrd.sh genkernel-3.0.2a/gen_initrd.sh --- genkernel-3.0.2a.old/gen_initrd.sh 2004-04-02 22:27:01.000000000 +0200 +++ genkernel-3.0.2a/gen_initrd.sh 2004-04-28 23:12:40.516456256 +0200 @@ -28,6 +28,7 @@ mkdir -p ${TEMP}/initrd-temp/bin mkdir -p ${TEMP}/initrd-temp/etc mkdir -p ${TEMP}/initrd-temp/usr + mkdir -p ${TEMP}/initrd-temp/sys mkdir -p ${TEMP}/initrd-temp/proc mkdir -p ${TEMP}/initrd-temp/temp mkdir -p ${TEMP}/initrd-temp/.initrd @@ -68,6 +69,8 @@ bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd" chmod +x "${TEMP}/initrd-temp/bin/devfsd" + tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initrd-temp" || gen_die "could not extract udev binary cache" + # We make our own devfsd.conf these days, the default one doesn't work with the stripped # down devfsd we use with dietlibc # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not copy devfsd.conf from bincache" diff -Nru genkernel-3.0.2a.old/generic/linuxrc genkernel-3.0.2a/generic/linuxrc --- genkernel-3.0.2a.old/generic/linuxrc 2004-04-11 16:16:08.000000000 +0200 +++ genkernel-3.0.2a/generic/linuxrc 2004-04-28 23:19:05.367949936 +0200 @@ -6,6 +6,7 @@ . /etc/initrd.defaults . /etc/initrd.scripts +USE_UDEV_NORMAL=1 USE_DEVFS_NORMAL=1 if [ "$$" != "1" ] @@ -39,6 +40,12 @@ nodevfs) USE_DEVFS_NORMAL=0 ;; + udev) + USE_UDEV_NORMAL=1 + ;; + noudev) + USE_UDEV_NORMAL=0 + ;; loop\=*) LOOP=`parse_opt "${x}"` ;; @@ -136,8 +143,45 @@ fi fi +# Disable udev support if /dev is already mounted as devfs +[ -e /dev/.devfsd ] && USE_UDEV_NORMAL=0 + +# Try to mount sysfs, and if it fails, do not use udev +if [ "${USE_UDEV_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ] +then + mount -t sysfs sys /sys 2> /dev/null + [ ! "$?" -eq "0" ] && USE_UDEV_NORMAL=0 +fi + # Don't do else b/c we set CDROOT=0 if it fails to detect -if [ "${CDROOT}" -eq "0" -a "${USE_DEVFS_NORMAL}" -eq "1" ] +if [ "${USE_UDEV_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ] +then + export ACTION=add + export UDEV_NO_SLEEP=1 + + # Add block devices and their partitions to /dev, + # using information from /sys, and only those + # devices (since other are not needed for boot). + + cd /sys + for x in block/* + do + export DEVPATH="/${x}" + /sbin/udev block + + for y in ${x}/* + do + if [ -f "${y}/dev" ] + then + export DEVPATH="/${y}" + /sbin/udev block + fi + done + done + cd / + + unset -v ACTION DEVPATH UDEV_NO_SLEEP +elif [ "${CDROOT}" -eq "0" -a "${USE_DEVFS_NORMAL}" -eq "1" ] then [ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev devfsd /dev -np @@ -314,7 +358,11 @@ pivot_root . tmp/.initrd echo -n '.' -if [ "${USE_DEVFS_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ] +if [ "${USE_UDEV_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ] +then + umount /tmp/.initrd/proc || echo '*: Failed to unmount /tmp/.initrd/proc!' + umount /tmp/.initrd/sys || echo '*: Failed to unmount /tmp/.initrd/sys!' +elif [ "${USE_DEVFS_NORMAL}" -eq "1" -a "${CDROOT}" -eq "0" ] then umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!' diff -Nru genkernel-3.0.2a.old/genkernel genkernel-3.0.2a/genkernel --- genkernel-3.0.2a.old/genkernel 2004-04-11 16:32:02.000000000 +0200 +++ genkernel-3.0.2a/genkernel 2004-04-26 02:38:21.000000000 +0200 @@ -178,6 +178,7 @@ fi compile_devfsd +compile_udev # Create initrd create_initrd diff -Nru genkernel-3.0.2a.old/genkernel.conf genkernel-3.0.2a/genkernel.conf --- genkernel-3.0.2a.old/genkernel.conf 2004-03-21 13:02:24.000000000 +0100 +++ genkernel-3.0.2a/genkernel.conf 2004-04-28 23:05:28.046201728 +0200 @@ -79,3 +79,8 @@ DEVFSD_DIR="devfsd" DEVFSD_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-${DEVFSD_VER}-%%ARCH%%.bz2" DEVFSD_CONF_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-conf-${DIETLIBC_VER}-%%ARCH%%.bz2" + +UDEV_VER="025" +UDEV_DIR="udev-${UDEV_VER}" +UDEV_SRCTAR="${GK_SHARE}/pkg/udev-${UDEV_VER}.tar.bz2" +UDEV_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/udev-${UDEV_VER}-%%ARCH%%.tar.bz2" ------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------ The second patch is against /sbin/rc to make it create the /dev/fb/0 node when RC_DEVICE_TARBALL is set to no (since it is required for the bootsplash hack). ------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------ --- /sbin/rc 2004-04-28 23:24:06.423182584 +0200 +++ /sbin/rc~ 2004-04-28 23:23:17.242659160 +0200 @@ -200,6 +200,9 @@ then einfo " Populating /dev with device nodes..." try tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev + else + [ ! -e /dev/fb ] && mkdir /dev/fb + [ ! -e /dev/fb/0 ] && mknod /dev/fb/0 c 29 0 fi populate_udev if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] ------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------ BTW, I think that many file in genkernel tarball should have their permissions changed (from 0700 to 0755 and 0600 to 0644) since there is no meaning in preventing user to read them. I would recommend the following permissions (only the modified files are listed): -rw-r--r-- genkernel-3.0.2a/gen_arch.sh -rw-r--r-- genkernel-3.0.2a/gen_cmdline.sh -rw-r--r-- genkernel-3.0.2a/gen_funcs.sh -rw-r--r-- genkernel-3.0.2a/gen_initrd.sh -rw-r--r-- genkernel-3.0.2a/genkernel.conf -rw-r--r-- genkernel-3.0.2a/notes -rw-r--r-- genkernel-3.0.2a/generic/initrd.defaults -rw-r--r-- genkernel-3.0.2a/generic/linuxrc
We should really be using initramfs for 2.6 instead of initrd. But that is going to take a bit of work, that hopefully I can get to in a month or so, once the rest of the kernel stuff is cleaned up... Either way, we need to put udev into initramfs too, this is just a note...
Adding livecd@gentoo.org to CC since this is a "Feature" planned for 2004.2 release.
Adding plasmaroo directly to the CC on this one so hopefully he can get it into genkernel 3.0.2b for me... *hint* *hint*
Hi, the patch looks good and I'll add it in to CVS... The only issue is that we want to get this into LiveCDs and they use CDROOT=1... Could you make a patch to mount udev when CDROOT=1 please? This only needs an extention to the generic/linuxrc file. Sidenotes: [ "$?" -eq '0' ] || is better than [ ! "$?" -eq "0" ] && and there isn't a need for locals in the compile_udev() function. Good otherwise.
Tim, did this get added to genkernel 3.0.2b or...?
i don't think it got added since my last attempt to run udev + genkernel generated initrd gave the same results as before (root not found).
When is this going in? Genkernel is the only thing keeping me from going udev.
well, you can always compile your kernel by hand, of course. but having an initrd isn't a silly idea (or gentoo wouldn't use it :), and the only usable way to get one is using genkernel. you can indeed have udev perfectly working also along with genkernel (in fact, I do), but it's not -ehm- "elegant". Just don't use in your lilo.conf the "real_root" thing. It'll work. The reason to fix this is that things are made to work, and not by kluge. ;)
It won't be until after 2004.2 (end of the month) since we want to keep the same version of genkernel for all arches.
Created attachment 35267 [details, diff] udev/linuxrc patch for clean initrd unmount
OK, udev support is now in 3.0.2e and should work; just make sure you run genkernel with the --udev parameter. If there are any issues, please reopen this bug. Thanks!