[lfs-dev] bootscripts-20111017 statusproc() broken?
lfs/lib/services/init-functions defines statusproc() with this snippit to process arguments: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; esac done Isn't this broken? I notice that the statusproc() defined in the (deprecated) lfs/init.d/functions includes both an unknown option error message and a break out of the loop: while true; do case ${1} in -p) pidfile=${2} shift2 ;; -*) log_failure_msg Unknown Option: ${1} return 2 ;; *) break ;; esac done -dean takemori -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
[lfs-dev] kmod.xml not committed to repo
Hi, As the subject heading says, it looks like kmod.xml is missing in rev 9712, while chapter06/chapter06.xml has been modified to xinclude it. Regards, Pierre -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] kmod.xml not committed to repo
On Sun, 2012-01-22 at 16:14 +0100, Pierre Labastie wrote: Hi, As the subject heading says, it looks like kmod.xml is missing in rev 9712, while chapter06/chapter06.xml has been modified to xinclude it. Thanks! Should be fixed up in r9713. Regards, Matt. -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
Dean Takemori wrote: lfs/lib/services/init-functions defines statusproc() with this snippit to process arguments: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; esac done Isn't this broken? What's broken? Can you give an example of how it breaks? -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
On 01/22/2012 10:43 AM, Bruce Dubbs wrote: Dean Takemori wrote: lfs/lib/services/init-functions defines statusproc() with this snippit to process arguments: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; esac done Isn't this broken? What's broken? Can you give an example of how it breaks? -- Bruce I think this might carry over from the original so the problem dates back to me or possibly even Nathan and Alex. I didn't look. At any rate, the problem is that there is no error checking. I don't believe that statusproc() is intended to check multiple processes from multiple executables (multiple processes from one executable yes). For the -p case, you should verify that $2 is a valid file, and that $3 is executable or undefined, and add a * case, that $1 is executable and $2 = -p shift 1;. If any of the above are false, a return value of 2 should fit the LSB spec with optional error message Error: invalid or excessive argument(s). A case could be made that $3 in the -p case or $1 in the * case not being executable should return a value of 5, but I'm not sure that value should apply here. I didn't look to see if the executable is evaluated later in the function, but the function should most definitely have argument handling for excessive arguments in the while loop. http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html -- DJ Lucas -- This message has been scanned for viruses and dangerous content, and is believed to be clean. -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
Bruce Dubbs wrote: Dean Takemori wrote: lfs/lib/services/init-functions defines statusproc() with this snippit to process arguments: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; esac done Isn't this broken? What's broken? Can you give an example of how it breaks? Unless I'm misreading and mis-testing it, there's no break out of the loop; For example, given this: root:/tmp/lfs-bootscripts-20111017# bash --version | head -1 GNU bash, version 4.2.10(2)-release (i686-pc-linux-gnu) root:/tmp/lfs-bootscripts-20111017# cat /run/fcron.pid 2066 root:/tmp/lfs-bootscripts-20111017# ps xa | grep 2066 2066 ?Ss 0:00 /usr/sbin/fcron 2333 tty1 S+ 0:00 grep 2066 And then doing this: root:/tmp/lfs-bootscripts-20111017# source lfs/lib/services/init-functions Both of these never return; root:/tmp/lfs-bootscripts-20111017# statusproc -p /run/fcron.pid /usr/sbin/fcron root:/tmp/lfs-bootscripts-20111017# statusproc /usr/sbin/fcron But if one does instead (after commenting out the init_params line as per the 7.0 errata) root:/tmp/lfs-bootscripts-20111017# source lfs/init.d/functions root:/tmp/lfs-bootscripts-20111017# statusproc -p /run/fcron.pid /usr/sbin/fcron fcron is running with Process ID(s) 2066. root:/tmp/lfs-bootscripts-20111017# statusproc /usr/sbin/fcron fcron is running with Process ID(s) 2066. -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
de...@hawaii.rr.com wrote: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; esac done Unless I'm misreading and mis-testing it, there's no break out of the loop; You are not giving the whole loop: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; *) if [ -n ${2} ]; then echo Too many arguments return 1 else break fi ;; esac done The 'break' command breaks out of the while loop. It's not the same as C/C++. The 'functions' file is only present for a few (currently 19 are left) bootscripts in BLFS that have not yet been updated to LFS 7.0 syntax. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
deant at hawaii.rr.com wrote: You are not giving the whole loop: while true; do case ${1} in -p) pidfile=${2} shift 2 ;; *) if [ -n ${2} ]; then echo Too many arguments return 1 else break fi ;; esac done The 'break' command breaks out of the while loop. It's not the same as C/C++. The 'functions' file is only present for a few (currently 19 are left) bootscripts in BLFS that have not yet been updated to LFS 7.0 syntax. -- Bruce Well, then something else is amiss. the statusproc() function defined here: http://www.linuxfromscratch.org/lfs/view/stable/scripts/apds02.html does not have the *) case. And neither does the one defined in lfs-bootscripts-20111017/lfs/lib/services/init-functions as downloaded just now from http://www.linuxfromscratch.org/lfs/downloads/7.0/lfs-bootscripts-20111017.tar.bz2 -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
de...@hawaii.rr.com wrote: Well, then something else is amiss. the statusproc() function defined here: http://www.linuxfromscratch.org/lfs/view/stable/scripts/apds02.html does not have the *) case. And neither does the one defined in lfs-bootscripts-20111017/lfs/lib/services/init-functions as downloaded just now from http://www.linuxfromscratch.org/lfs/downloads/7.0/lfs-bootscripts-20111017.tar.bz2 I now remember that I fixed that on Nov 14 in svn. I guess it didn't get into the errata. Try using the current -dev version: http://www.linuxfromscratch.org/lfs/downloads/development/lfs-bootscripts-20120116.tar.bz2 -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Thu, Jan 19, 2012 at 10:29 AM, Bruce Dubbs bruce.du...@gmail.com wrote: I've been thinking about the discussion we had earlier and think a couple of pages added to BLFS would be a good start (yes, I know this is lfs-dev). The outline of the pages is below and I'm looking for feedback. snip Using dracut to create an initramfs (add dracut to the book) I've been experimenting with initramfs recently (I used to use initrd for my cdrom bootable lfs firewall). It's relatively straightforward. I understand dracut may automate some of the LVM\MD\RAID stuff (not looked at it yet), but for purely educational purposes, isn't a hand-crafted version better? Anyway, here are my notes for building initramfs during the last stages of LFS. involves one additional package (busybox), a requirement for a kernel parameter to be set (initramfs support) and an additional line in grub.cfg What we get as an end result is a simple, expandable initramfs environment, that will drop to a rescue shell if the real root device can't be loaded. This allows some diagnostics to be done regarding device nodes, modules, use of lspci\lsusb, etc, which might be useful given the number of issues recently with people configuring grub correctly for the root= parameter. Feel free to comment - if it's preferred, I can implement as a hint instead. Note that module support is not yet tested and needs further work, but was lifted verbatim from the existing gentoo initramfs wiki page, so should be functional. === Using an INITRAMFS with LFS === @ FIXME: wordy and awkward @ Modern Linux systems feature the ability to start what is known as early userspace. This is used in most cases to perform extra actions that require features that are either not generic enough to be in the Linux kernel, or are complex enough to require user interaction. This early userspace consists of a temporary root filesystem, with just enough scripts and programs to perform the early actions needed. This temporary root filesystem, called an INITRAMFS, is loaded from a compressed cpio archive into memory, is discarded when complete, and replaced by the real root filesystem. The INITRAMFS can be used to load binary firmware images to a RAID controller, mounting of LVM or MD devices, decrypting an encrypted root filesystem, or simply providing a diagnostic (or rescue) shell environment if the real root filesystem cannot be mounted. LFS provides an INITRAMFS system that includes a rescue shell, and which can be extended to provide other service such as LVM\MD or encryption services as required. = Creating the INITRAMFS directory tree = We first need to create a place that the initramfs image can be built from, and then populate the area with the necessary minimal scripts and binaries. mkdir -pv /usr/src/initramfs We don't need all the FHS required directories for an INITRAMFS, so we just create the minimum required set mkdir -pv /usr/src/initramfs/{bin,dev,etc,lib,mnt/root,proc,root,sbin,sys} We create a few minimal device nodes in case the device detection has problems. cp -av /dev/{console,null,tty} /usr/src/initramfs/dev Building BusyBox Next we use BusyBox, a single binary that can be referenced by many different names to perform most of the functions needed by an INITRAMFS (FIXME: ). @ FIXME: Need a better description than this FIXME: Mention the other option? Copy static\dynamic binaries from LFS system and necessary dynamic libs? Helps teach use of LDD, etc? Much larger INITRAMFS image, although we are talking 10's of megabytes here... @ tar xvf busybox cd busybox make menuconfig Select at least the following BusyBox Settings --- General Configuration --- [*] Support --install [-s] to install applet links at runtime [*] Don't use /usr Build Options --- [*] Build BusyBox as a static binary (no shared libs) Archival Utilities --- [*] cpio [*] Support for archive creation Coreutils --- [*] cat [*] cp [*] env [*] ls [*[ mkdir [*] mv Editors --- [*] vi Init Utilities --- [*] poweroff, halt and reboot Linux Module Utilities --- [*] insmod [*] lsmod [*] modprobe Linux System Utilities --- [*] dmesg] [*] lspci [*] lsusb [*] mdev [*] more [*] mount [*] switch_root [*] umount Miscellaneous Utilities --- [*] less [*] setsid Networking Utilities --- [*] ifconfig [*] route [*] telnetd [*] udhcpc client (udhcpc) Shells --- [*] ash [*] cttyhack [*] POSIX math support make cp busybox /usr/src/initramfs/bin cp examples/udhcp/simple.script /usr/src/initramfs/bin ==
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Mon, Jan 23, 2012 at 4:33 PM, Steve Crosby steve.cro...@gmail.com wrote: cutpasto ${INITPRG:=/sbin/init} should be : ${INITPRG:=/sbin/init} -- -- - Steve Crosby -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
Steve Crosby wrote: I've been experimenting with initramfs recently (I used to use initrd for my cdrom bootable lfs firewall). It's relatively straightforward. I understand dracut may automate some of the LVM\MD\RAID stuff (not looked at it yet), but for purely educational purposes, isn't a hand-crafted version better? What you have is interesting, but if you are not using LVM/MD/RAID, what is the purpose of your initramfs? AFAIK, the only real reason to use an initramfs is to mount the root fs and the kernel is quite capable of doing that for plain file systems. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Mon, Jan 23, 2012 at 4:57 PM, Bruce Dubbs bruce.du...@gmail.com wrote: Steve Crosby wrote: I've been experimenting with initramfs recently (I used to use initrd for my cdrom bootable lfs firewall). It's relatively straightforward. I understand dracut may automate some of the LVM\MD\RAID stuff (not looked at it yet), but for purely educational purposes, isn't a hand-crafted version better? What you have is interesting, but if you are not using LVM/MD/RAID, what is the purpose of your initramfs? AFAIK, the only real reason to use an initramfs is to mount the root fs and the kernel is quite capable of doing that for plain file systems. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page 1. Education ;) 2. Providing an emergency shell in the event of failure to mount root filesystem -- -- - Steve Crosby -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Mon, Jan 23, 2012 at 5:36 PM, Steve Crosby steve.cro...@gmail.com wrote: 1. Education ;) 2. Providing an emergency shell in the event of failure to mount root filesystem 3. (not relevant to LFS) Auto-detecting which device the root is on, when the boot device is portable\non-persistent (usb\cdrom\etc) e.g. my LFS can end up as an iso, and run in a VM, or applied to usb stick, therefore the real root device is variable. -- -- - Steve Crosby -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
Steve Crosby wrote: On Mon, Jan 23, 2012 at 5:36 PM, Steve Crosby steve.cro...@gmail.com wrote: 1. Education ;) Always a good reason. 2. Providing an emergency shell in the event of failure to mount root filesystem That's reasonable too, however I never recall needing that capability. The times I have had problems have been when grub can't load the kernel and if I can load the kernel I can always edit the command line in grub to use init=/bin/bash. 3. (not relevant to LFS) Auto-detecting which device the root is on, when the boot device is portable\non-persistent (usb\cdrom\etc) e.g. my LFS can end up as an iso, and run in a VM, or applied to usb stick, therefore the real root device is variable. Can't you use 'mount'? I get something like: /dev/sda8 on / type ext3 (rw) Wouldn't that be easier? To me, the biggest reason to use initiramfs is if you want to have the root fs on a sw raid device, e.g. md0. All the other reasons are fairly exotic. root on lvm? why? On nfs? Maybe, but still exotic. Encrypted? Data, yes, but why the root fs? There seems to be a trend in Linux to embrace the complex when simple solutions will suffice for most people. The first exhibit is systemd. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Jan 22, 2012, at 7:33 PM, Steve Crosby wrote: 3. Populate /dev using busybox cutdown version of udev (mdev) Is there a benefit to mdev over just using tmpdevfs? I say that as a current user of mdev; I haven't yet tried a tmpdevfs initramfs device system. But if I'm understanding it correctly tmpdevfs should be sufficient for any use were an default-config mdev run would work, and requires less configuration/tools, less boot scripting, and the need to wait for a coldplug scan in the initramfs. Zach smime.p7s Description: S/MIME cryptographic signature -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Jan 22, 2012, at 9:05 PM, Bruce Dubbs wrote: The times I have had problems have been when grub can't load the kernel and if I can load the kernel I can always edit the command line in grub to use init=/bin/bash. Only if the kernel can mount the root file system as-is. Given an initramfs there's an opportunity to run repairs or switch to a backup disk from a userspace environment that's as rich as you'd like it to be and guaranteed to be available so long as the boot loader can find the kernel/initramfs files. You may or may not care; if you're sitting at the machine in question it's probably just as easy to slap in a boot CD and fix it that way, versus maintaining a full-featured initramfs. But if you're building a machine that lives in a data center 2000 miles away it's nice to be able to run fsck without needing to boot from alternate media. 3. Auto-detecting which device the root is on, Can't you use 'mount'? I get something like: /dev/sda8 on / type ext3 (rw) On my system I don't always get the same device at /dev/sda. Rebooting can change my /dev/sda to /dev/sdg, or any other device letter, without any physical change in the underlying disks or cabling. This is not a problem in the eyes of the kernel devs, and will never be fixed, because there's no general way to guarantee consistent naming short of a configurable system like udev (which obviously isn't available at the time root is mounted by the kernel). Depending on your hardware that may or may not be an issue for you, but it's a possible problem on any system with more than one SCSI disks (including SAS and SATA disks, and most USB disks). Something as simple as inserting a thumb drive could change device names and break a static kernel boot config. Or let's say you've burned a CD with LFS on it. The BIOS can find the boot loader, but how do you determine if the root is at /dev/hda or /dev/sdb and pass that string to the kernel? Even on writable media the same situation occurs any time you can't predict the device name -- if you are booting from a USB block device, even on a single machine, it can be difficult to reliably predict the root device name, and all but impossible if you share the same disk among non-identical machines. Zach smime.p7s Description: S/MIME cryptographic signature -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] bootscripts-20111017 statusproc() broken?
Bruce Dubbs wrote: de...@hawaii.rr.com wrote: Well, then something else is amiss. the statusproc() function defined here: http://www.linuxfromscratch.org/lfs/view/stable/scripts/apds02.html does not have the *) case. And neither does the one defined in lfs-bootscripts-20111017/lfs/lib/services/init-functions as downloaded just now from http://www.linuxfromscratch.org/lfs/downloads/7.0/lfs-bootscripts-20111017.tar.bz2 I now remember that I fixed that on Nov 14 in svn. I guess it didn't get into the errata. Try using the current -dev version: http://www.linuxfromscratch.org/lfs/downloads/development/lfs-bootscripts-20120116.tar.bz2 Aha. That did it. Many thanks. For the mailing list archives; Upgrading bootscripts from the 20111017 version to 20120116 requires devtmpfs support in the kernel. -dean takemori -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Mon, Jan 23, 2012 at 7:58 PM, Zachary Kotlarek z...@kotlarek.com wrote: On Jan 22, 2012, at 7:33 PM, Steve Crosby wrote: 3. Populate /dev using busybox cutdown version of udev (mdev) Is there a benefit to mdev over just using tmpdevfs? I say that as a current user of mdev; I haven't yet tried a tmpdevfs initramfs device system. But if I'm understanding it correctly tmpdevfs should be sufficient for any use were an default-config mdev run would work, and requires less configuration/tools, less boot scripting, and the need to wait for a coldplug scan in the initramfs. I haven't yet reviewed devtmpfs, so didn't implement it in my initial cut of scripts. From reading, it has several significant advantages, including the ability to move the /dev mount to the new root and thus not miss any events and thus not require udev to replay them in the real bootscripts. It is not however automatically mounted in an initramfs (deliberately), so still needs the mount line, but the kernel hotplug helper and scan can be eliminated. Will add to todo list ;) -- -- - Steve Crosby -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
Re: [lfs-dev] Adding LVM/RAID/initfamfs
On Mon, Jan 23, 2012 at 6:05 PM, Bruce Dubbs bruce.du...@gmail.com wrote: Steve Crosby wrote: 2. Providing an emergency shell in the event of failure to mount root filesystem That's reasonable too, however I never recall needing that capability. The times I have had problems have been when grub can't load the kernel and if I can load the kernel I can always edit the command line in grub to use init=/bin/bash. Agreed. Perhaps we should mention that in the grub section of the book as a diagnostic\troubleshooting step. Note however that if your rootfs fails to mount as a result of a fs error, that won't help you ;) Also, the switch in grub config between hd0,1 and /dev/sda1 for a root fs quite often catches people out. Being able to have a diagnostic userspace where they can actually ls /dev and see what their kernel thinks is the disk device, or using lspci et al is helpful. 3. (not relevant to LFS) Auto-detecting which device the root is on, when the boot device is portable\non-persistent (usb\cdrom\etc) e.g. my LFS can end up as an iso, and run in a VM, or applied to usb stick, therefore the real root device is variable. Can't you use 'mount'? I get something like: /dev/sda8 on / type ext3 (rw) Wouldn't that be easier? Nope. If your root device is a USB stick, the /dev mapping changes depending on which USB hub\port you plug into - at kernel root mount time, there is no facility to use any of the udev device\name mapping, so early userspace is a requirement. All live-cd based systems use this approach as well, since they don't know how many cd-rom's you have, the type, or where they are in the device chain. As above, not relevant for LFS though ;) There seems to be a trend in Linux to embrace the complex when simple solutions will suffice for most people. The first exhibit is systemd. systemd is a solution looking for a problem ;) Primarily aimed at people who want fast boot times, the parallelisation is very good, but the dependencies really bite. So far, systemd requires (both directly and indirectly) dbus, gperf, attr, intltool, libcap - and aside from parallel scripts, and some esoteric use cases, provides no advantage I have yet to discover to the masses over sysvinit. -- -- - Steve Crosby -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page