OpenWrt Forum Archive

Topic: Boot from the USB device - Kamikaze 8.09.1

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I would like to follow the USB storage howto to enable booting from the usb device on my Asus500gp with Kamikaze 8.09.1.
This is the link to the howto: http://wiki.openwrt.org/oldwiki/usbstoragehowto or http://oldwiki.openwrt.org/UsbStorageHowto.html

On Kamikaze 8.09.1 the content of the file /etc/init.d/rcS is:

>  #!/bin/sh
>  # Copyright (C) 2006 OpenWrt.org

>  run_scripts() {
>          for i in /etc/rc.d/$1*; do
>                  [ -x $i ] && $i $2 2>&1
>          done | $LOGGER
>  }

>  LOGGER="cat"
>  [ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"

>  if [ "$1" = "S" ]; then
>          run_scripts "$1" "$2" &
>  else
>          run_scripts "$1" "$2"
>  fi


This differs optically so much from the /etc/init.d/rcS from the howto:

>  #!/bin/sh
>  # Copyright (C) 2006 OpenWrt.org
>  if test $2 == "boot" ; then
>  /etc/init.d/pivotroot
>  fi
>  {
>          for i in /etc/rc.d/$1*; do
>                  $i $2 2>&1
>          done
>  } | logger -s -p 6 -t '' &

I don't have much experience in writing scripts.
So I feel a little bit uneasily in just replacing the former with the latter one. ;-)

Can I just replace it - or should I take some changes?

(Last edited by theno on 10 Aug 2009, 23:02)

Well, now I gathered courage and tried the version from the howto for
/etc/init.d/rcS.

...But it didn't worked.

Because in my /etc/init.d/pivotroot one module (ehci-hcd for USB 2.0) was
missing. After fixing it the kamikaze is now booting from my (small) stick:

> root@OpenWrt:~# df -h       
> Filesystem                Size      Used Available Use% Mounted on
> rootfs                  121.0M     21.3M     93.5M  19% /
> /dev/root                 1.6M      1.6M         0 100% /mnt/rom
> tmpfs                    14.9M    720.0k     14.2M   5% /tmp
> /dev/mtdblock/4           5.7M      4.9M    792.0k  86% /mnt/jffs
> mini_fo:/jffs             1.6M      1.6M         0 100% /mnt
> /dev/scsi/host0/bus0/target0/lun0/part1
>                         121.0M     21.3M     93.5M  19% /

nice

My pivotroot now looks like this:

> #!/bin/sh
> # change this to your boot partition
> boot_dev="/dev/scsi/host0/bus0/target0/lun0/part1"
> # install needed modules for usb and the ext3 filesystem
> # **NOTE** for usb2.0 replace "uhci" with "ehci-hcd"
> # **NOTE** for ohci chipsets replace "uhci" with "usb-ohci"
> for module in usbcore ehci-hcd usb-ohci scsi_mod sd_mod usb-storage jbd ext2 ext3 ; do {
>         insmod $module
> }; done
> # this may need to be higher if your disk is slow to initialize
> sleep 4s
> # mount the usb stick
> mount "$boot_dev" /mnt
> # if everything looks ok, do the pivot root
> [ -x /mnt/sbin/init ] && {
>         mount -o move /proc /mnt/proc && \
>         pivot_root /mnt /mnt/mnt && {
>                 mount -o move /mnt/dev /dev
>                 mount -o move /mnt/tmp /tmp
>                 mount -o move /mnt/jffs /jffs 2>&-
>                 mount -o move /mnt/sys /sys 2>&-
>         }
> }
>

You all should look at the block-extroot package in trunk...

block-extroot looks very interesting as a pivot-root method.  Is there end-user documentation available for it?

Theno, et al:

The block-extroot package in the trunk was designed for this. It is fully operational and has good documentation.

marc.

The discussion might have continued from here.