Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 28 Apr 2015, 16:01
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
initrd.gz for full installs
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
Karl Godt

Joined: 20 Jun 2010
Posts: 4026
Location: Kiel,Germany

PostPosted: Wed 07 Aug 2013, 13:08    Post_subject:  initrd.gz for full installs
Sub_title: on external USB HD

Kernel is a ST**ID thing .. ! :GRR:

It loads the internally HDD and FS drivers and forks the loading of internally USB drivers .

While these USB drivers are not fully loaded, the kernel tries already to mount the root=/dev/sdcX partition, which does not succeed, since the inbuilt USB drivers are not fully loaded .
Had to boot with the debug kernel parameter to see this .

So it needs a initrd that checks for kernel parameters and full kernel load to continue .

My questions are :
1) Has someone already made such an attempt ?
2) Are there Puppies out that use some kind of pfix=wait2usb:N kernel parameter to sleep N seconds before continuing ?

«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send_private_message 

Joined: 18 May 2008
Posts: 4494

PostPosted: Wed 07 Aug 2013, 16:41    Post_subject:  

Iirc there is a builtin kernel parameter for this. At least a time based one, but there may even be one that waits for usb to settle.
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 

Joined: 11 Oct 2008
Posts: 7904
Location: qld

PostPosted: Wed 07 Aug 2013, 21:31    Post_subject:  

Hello Karl Godt

In this post I have a working initrd.gz skeleton for an f2fs FULL install. You might get some ideas from it, maybe even improve it.


Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 

Joined: 26 Feb 2007
Posts: 2427
Location: The Blue Marble

PostPosted: Thu 08 Aug 2013, 00:58    Post_subject:  

The parameters you're looking for are called "rootwait" and "rootdelay".

"rootdelay=n" (where n is in seconds) tell the kernel to wait for "n" seconds before attempting to mount the root filesystem.

"rootwait" tells the kernel to wait as long as need for the root filesystem to appear before trying to mount it.

Both will only work when you don't use initrd (although of course you can emulate them using the initrd script - which is what most distros do). I've successfully used "rootwait" to boot full-install slacko on f2fs on USB stick - without initrd, here: http://01micko.com/blog/blog/2013/07/12/f2fs-booting-linux-on-an-f2fs-flash-drive/#comment-626.

That being said, using initrd is so much better - so check out 01micko's post.

Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send_private_message 
Karl Godt

Joined: 20 Jun 2010
Posts: 4026
Location: Kiel,Germany

PostPosted: Thu 08 Aug 2013, 05:15    Post_subject:  

Hi Brad, Michael and James !

Yes, kernelparameters.txt has some options as James mentions .
Especially the
I was using longer time ago , when I had only the P4 machine -- of course had forgotten about this .

rootwait seems to be a little unsafe as it is , since a typo like root=/dev/sda99 instead of sda9 might wait forever .

In current initrd.gz there I remembered /sbin/wait4usb script , which seems to use basically code from /etc/rc.d/rc.sysinit or pup_event_frontend_d (wait4usb_classic) .

James, I remembered
The syntax is: waitdev=n, where n is the number of seconds to wait. http://distro.ibiblio.org/fatdog/web/faqs/boot-options.html
that I had read once .

Michael : Looks nice the init !
Would be even nicer if the kernel would allow the initrd could pass back to the kernel without the need to switch_root .
# variables set from install script
is that a new parameter introduced by yours ?

2cents: For all that cryptic things people should put SAP prices on the tabe !

Here's a crude and heavy pfix parser I use in my current rc.sysinit :
#puppy boot parameters:
if [ "$PUPMODE" = '2' ];then
for item in `cat /proc/cmdline` ;do
case $item in
    ITEMS=`echo "$item" |cut -f 2 -d '=' |tr ',' ' '`
        for item2 in $ITEMS;do
        case $item2 in
        nox)        echo 'nox' > /tmp/X.status;;
        xorgwizard) mv /etc/X11/xorg.conf /etc/X11/xorg.conf-"`date`";;
        noswap)     SWAPON=yes;;  #fake value,dunno why for now
        noalsa)     echo 'noalsa' >/tmp/pup_event_alsa_cnt ;;
        nofbcon)    NO_FBCON=1  ;;
        pupmode:*) PUPMODE=${item2#*:};sed -i "s/PUPMODE=.*/PUPMODE='$PUPMODE'/" /etc/rc.d/PUPSTATE;. /etc/rc.d/PUPSTATE;;
        fsck)  : ;;  #do filesystem check on lupusave (and host part. if ext2
        clean) : ;;  #file cleanup (simulate version upgrade)
        purge) : ;;  #more radical file cleanup (to fix broken system)
        rdsh)  : ;;  #for developers only (initramfs shell)
        copy)  : ;;  #copy lupu-511.sfs to RAM (slower boot, faster running)
#racy 522
        nocopy) : ;; #do not copy .sfs files to RAM (faster boot, slower running), #racy 522

        pdev1:*) : ;; #The boot partition.
        psubdir:*) : ;; #psubdir=puppies/wary501 Path in which Puppy is installed.

        psavemark:*) : ;; # =2 Partition no. (in boot drive) to save session to.

        pmedia:*) : ;; #Type of media booting from. Choose one of these:
             # usbflash usbhd usbcd ataflash atahd atacd atazip scsihd scsicd cd

        pupsfs:*) : ;; # =sdc1:/puppies/wary501/puppy.sfs Override auto search.
        zdrv:*) : ;;   # =sdc1:/puppies/wary501/zdrv.sfs  Override auto search.
#racy 522
        [0-9]) : ;;  #number of saved sessions to ignore (multisession-CD)
[ "`echo "$item" | grep '='`" ] || item="${item}=1"
kp=${item%=*};echo -n "${kp},"
eval $item
export $kp
Back to top
View user's profile Send_private_message 

Joined: 11 Oct 2008
Posts: 7904
Location: qld

PostPosted: Thu 08 Aug 2013, 05:57    Post_subject:  

Hello Karl

Actually, that version didn't make it into slacko, and as James points out I don't really need an initrd, however I decided to leave it as it may come in handy if someone has obscure modules they want/need to load. The current version reads a config file and the uuid of the partition is now stored there and not hard coded in the script.
#version 0.2
# init for f2fs USB install
# Puppy Linux, puppylinux.com
# (c) 2013 Michael Amadio 01micko@gmail.com, 01micko.com
# GPL2 (see /usr/shar/doc/legal)
# it is required that an initial ramdisk is used to
# boot from supported filesysytem and perform a
# switch root to the f2fs filesystem
# the first partition must be vfat or ext[2,3,4]
# influenced by init scripts from Puppy Linux, Barry Kauler, puppylinux.com
# and Slackware Linux, Patrick Volkerding, slackware.com

KERNELVER="`uname -r`"

# read config
rootdev=`grep 'rootdev' /init.cfg | cut -d '=' -f2`
WAIT=`grep 'WAIT' /init.cfg | cut -d '=' -f2`

mount -t proc none /proc
mount -t sysfs none /sys
mount -t rootfs -o remount,rw rootfs /

# variables set from config
[ ! "$WAIT" ] && WAIT=5

# for future, will need to add code here to generate block devices
# depending on if devtmpfs is available

# Barry's status function
  if [ $1 -eq 0 ]
    /bin/echo -en "\\033[74G" >/dev/console
    /bin/echo -en "\\033[1;32m" >/dev/console
    /bin/echo -en "done" >/dev/console
    /bin/echo -e "\\033[0;39m" >/dev/console
    /bin/echo -en "\\033[72G" >/dev/console
    /bin/echo -en "\\033[1;31m" >/dev/console
    /bin/echo -en "failed" >/dev/console
    /bin/echo -e "\\033[0;39m" >/dev/console
    echo -en "\\033[1;35m" >/dev/console #35=purple
    echo -n "Dumping last lines of /tmp/bootinit.log..." >/dev/console
    /bin/echo -e "\\033[0;39m" >/dev/console
    echo -en "\\033[1;31m" >/dev/console #31=red
    cat /tmp/bootinit.log | tail -n 4 >/dev/console
    /bin/echo -en "\\033[0;39m" >/dev/console
    echo -en "\\033[1;35m" >/dev/console #35=purple
    echo -n "Dumping last lines of kernel log..." >/dev/console
    /bin/echo -e "\\033[0;39m" >/dev/console
    echo -en "\\033[1;31m" >/dev/console #31=red
    dmesg | tail -n 4 >/dev/console
    /bin/echo -en "\\033[0;39m" >/dev/console
    #exit to initial ramdisk shell...
    exec /bin/sh >/dev/console 2>&1
    echo "Pausing for 60 seconds..." >/dev/console
    sleep 60

[ ! "$rootdev" ] && echo -n "NO ROOT defined, bye" && check_status 255

echo -n "Booting the system" >/dev/console
check_status 0

# load modules #likely builtin but won't hurt #more can be added
echo -n "Loading initrd kernel modules" >/dev/console
modprobe  hid 2>/dev/null
modprobe  usbhid 2>/dev/null
modprobe  ehci-hcd 2>/dev/null
modprobe  uhci-hcd 2>/dev/null
modprobe  f2fs 2>/dev/null
# likely not builtin
modprobe  mmc-block 2>/dev/null
modprobe  mmc-core 2>/dev/null
modprobe  sdhci-pci 2>/dev/null
modprobe  sdhci 2>/dev/null
modprobe  tifm-sd 2>/dev/null
modprobe  tifm-7xx1 2>/dev/null
modprobe  tifm-core 2>/dev/null
modprobe  ssb 2>/dev/null

check_status 0

# time set from install script, default 5
echo -n "Waiting $WAIT seconds for USB subsystem" >/dev/console
sleep $WAIT
check_status 0

# mount the real fs
echo -n "Mounting the root filesystem" >/dev/console
mount -t f2fs UUID=$rootdev /mnt # -o rw
check_status $?

# unmount before switch root
umount /proc
umount /sys

# switch root
echo -n "Switching root " >/dev/console
exec switch_root /mnt /sbin/init 2>/dev/null

# that's it

And the config is very simple

Those values are added by my installer script.

On full slackware installs (I imagine debian might have something similar) the default is to boot a huge kernel with most drivers compiled in, but they supply a "generic" kernel which has a smaller image and you choose what modules you want loaded and then run the slackware mkinitrd.sh script with modules as a passed param, well there is a bit more to it but that's basically how it works. As stated in the comments, that's where I got some of my ideas.

Of course there is a separate function to populate the /lib/modules/`uname -r` directory.

Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt

Joined: 20 Jun 2010
Posts: 4026
Location: Kiel,Germany

PostPosted: Thu 08 Aug 2013, 09:47    Post_subject:  

Michael : I am actually compiling everything into the kernel -- boot related : IDE, SCSI, libSATA, USB, FS, Keyboard , which results in 7,x MB xz compressed kernels, 9,x MB gz compressed kernels and 12,x MB lzo compressed kernels .

While I cannot confirm that gz boots faster than xz ( both 10-11 seconds to /sbin/init ) , lzo takes only 3-4 seconds on my machine .
Back to top
View user's profile Send_private_message 

Joined: 18 May 2008
Posts: 4494

PostPosted: Fri 09 Aug 2013, 02:29    Post_subject:  

Most of the config options that you are using can be passed to the kernel command line (the limit is much larger in 3.x kernels now) such that all of the little configuration details can be part of the install process to the menu.lst (and tweaked via a control panel-like program later) The options in the form of VAR="some value" get passed to the environment of init and other parameters go to $@ IIRC (I was using C with getenv and argv though and it was over a year ago, so ...)
...but that is a long term project, something that could be useful now to speed up boot is setting up config files to be source as scripts like:

[ -f /etc/init.cfg ] && . /etc/init.cfg

and for any variables that _should_ be in the config, you can use default values like:

mount ${ROOTDRV:-/dev/sda1} /

where normally ROOTDRV would be set in init.cfg, but the value following ":-" is used if the variable ROOTDRV is not set (missing from init.cfg or init.cfg missing etc...)

also rather than sleep X and a single mount attempt, perhaps it could be a loop with a mount attempt, smaller sleep and a max attempts? something like this pseudo-code:
while ([ $i -lt ${MAXTRIES:-10} ]) do
  mount ... && break
  sleep 1

Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
Karl Godt

Joined: 20 Jun 2010
Posts: 4026
Location: Kiel,Germany

PostPosted: Fri 09 Aug 2013, 11:43    Post_subject:  

Short update : Finally booted the external USB drive from grub on sda -> sda3 commandline :
cat /proc/cmdline
panic=56 loglevel=3 root=/dev/sdc7 rootdelay=20 debug vga=0x33a

rootdelay set to 20 and that was quiet enough :

<6>[ 3.602396] usb usb7: Manufacturer: Linux 3.9.9-KRG-iCore2-smp-pae-srv1000gz uhci_hcd
<6>[ 3.606199] usb usb7: SerialNumber: 0000:00:1d.2
<6>[ 3.610062] sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 sdb7 sdb8 sdb9 sdb10 sdb11 sdb12 sdb13 sdb14 sdb15 sdb16 sdb17 sdb18 sdb19 sdb20 sdb21 sdb22 >


<6>[ 3.610181] hub 7-0:1.0: USB hub found
<6>[ 3.610187] hub 7-0:1.0: 2 ports detected

<6>[ 3.610494] Initializing USB Mass Storage driver

<5>[ 4.888765] scsi 10:0:0:0: Direct-Access ST1000LM 024 HN-M101MBB 2AR1 PQ: 0 ANSI: 5
<5>[ 4.892311] sd 10:0:0:0: Attached scsi generic sg4 type 0
<5>[ 4.895995] sd 10:0:0:0: [sdc] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)

<5>[ 4.900239] sd 10:0:0:0: [sdc] Write Protect is off
<7>[ 4.903429] sd 10:0:0:0: [sdc] Mode Sense: 23 00 00 00
<3>[ 4.907613] sd 10:0:0:0: [sdc] No Caching mode page present
<3>[ 4.910820] sd 10:0:0:0: [sdc] Assuming drive cache: write through
<3>[ 4.916738] sd 10:0:0:0: [sdc] No Caching mode page present
<3>[ 4.919925] sd 10:0:0:0: [sdc] Assuming drive cache: write through

<6>[ 5.456742] hid-generic 0003:2635:0601.0003: input,hidraw2: USB HID v1.11 Mouse [ 2.4G RF MOUSE] on usb-0000:00:1d.1-1.3/input0
<6>[ 7.341240] sdc: sdc1 sdc2 sdc3 sdc4 < sdc5 sdc6 sdc7 sdc8 sdc9 sdc10 sdc11 sdc12 sdc13 sdc14 sdc15 sdc16 sdc17 sdc18 sdc19 sdc20 sdc21 sdc22 sdc23 >
<3>[ 7.350119] sd 10:0:0:0: [sdc] No Caching mode page present
<3>[ 7.354290] sd 10:0:0:0: [sdc] Assuming drive cache: write through
<5>[ 7.358448] sd 10:0:0:0: [sdc] Attached SCSI disk

[ rootdelay 20 ]

<6>[ 23.935061] md: Waiting for all devices to be available before autodetect
<6>[ 23.944105] md: If you don't use raid, use raid=noautodetect
<6>[ 23.948836] md: Autodetecting RAID arrays.
<6>[ 23.953227] md: Scanned 0 and added 0 devices.
<6>[ 23.957601] md: autorun ...
<6>[ 23.961967] md: ... autorun DONE.

<6>[ 24.375033] VFS: Mounted root (ext2 filesystem) readonly on device 8:39.
<6>[ 24.391937] devtmpfs: mounted

It appears that rootdelay=5 or 6 would have been straightest .
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1019s ][ Queries: 12 (0.0035s) ][ GZIP on ]