NSLU2-Linux
view · edit · print · history

OpenWRT.BootFromUsbDevice History

Hide minor edits - Show changes to markup

December 28, 2009, at 07:07 PM by anywhere -- nslu2 is equipped with high speed usb hardware, loading ehci modul after \"turnup\"-booting results in input7output errors
Added lines 1-3:

This guide covers fast (12mbit/s) usb and ext2 filesystem only

make shure you install package kmod-usb2 and load module ehci-hcd or your disk will be (very, hdparm -t < 12,5mbit/s) slow.

October 21, 2008, at 01:23 PM by mariob -- /dev/sda1 -> /dev/sda
Changed lines 33-34 from:

fdisk /dev/sda1 <- change this to your device

to:

fdisk /dev/sda <- change this to your device

April 16, 2008, at 01:19 AM by krbvroc1 --
Changed line 120 from:

ln -s /mnt/tmp/resolv.conf.auto /etc/resolv.conf

to:

ln -s /tmp/resolv.conf.auto /etc/resolv.conf

January 24, 2008, at 12:33 PM by fcarolo -- removed false wikilink
Changed lines 31-32 from:

Partition your disk. I have a 1GB Verbatim StoreNGo? and used 700 MB for ext2 and 300 MB for swap

to:

Partition your disk. I have a 1GB Verbatim StoreNGo and used 700 MB for ext2 and 300 MB for swap

January 24, 2008, at 02:17 AM by krim --
Changed line 8 from:
to:

[@

Changed lines 11-12 from:
to:

@]

January 24, 2008, at 02:16 AM by krim --
Changed line 17 from:
to:

[@

Changed line 20 from:
to:

@]

Changed lines 22-24 from:

insmod ext2 && insmod jbd && insmod ext3

to:
insmod ext2
insmod jbd
insmod ext3
January 24, 2008, at 02:14 AM by krim --
Added line 130:

echo "#!/bin/sh" >> /etc/init.d/swapspace

January 24, 2008, at 02:12 AM by krim --
Changed lines 19-25 from:

ipkg install kmod-usb-core ipkg install kmod-usb-uhci ipkg install kmod-scsi-core ipkg install kmod-usb-storage ipkg install kmod-fs-ext2 ipkg install kmod-fs-ext3

to:

ipkg install kmod-usb-core kmod-usb-uhci kmod-scsi-core kmod-usb-storage kmod-fs-ext2 kmod-fs-ext3

Changed lines 23-26 from:

insmod ext2 insmod jbd insmod ext3

to:

insmod ext2 && insmod jbd && insmod ext3

Changed lines 27-29 from:

ipkg install e2fsprogs ipkg install fdisk

to:

ipkg install e2fsprogs fdisk

January 24, 2008, at 02:09 AM by krim --
Changed lines 7-8 from:
which will give you something like this:
to:

which will give you something like this:

Changed lines 16-17 from:
First of all make sure you have all the modules required:
to:

First of all make sure you have all the modules required:

Changed lines 110-113 from:

and log in with ssh

To make sure it works issue df -h

Which will look something like this

to:

Log in with ssh

To make sure it works type 'df -h'

Which will give you something like this

January 24, 2008, at 02:06 AM by krim --
Changed lines 5-9 from:

If you are unsure what kernel you have use: uname -a

which will give you something like this:

to:

If you are unsure what kernel you have use: uname -a

which will give you something like this:
Changed lines 13-16 from:

First of all make sure you have all the modules required:

to:

First of all make sure you have all the modules required:
January 24, 2008, at 02:01 AM by krim --
Changed lines 4-5 from:

work on other devices too running OpenWRT? on 2.6

to:

probably work for other devices too running OpenWRT? kamikaze on a 2.6 kernel

January 24, 2008, at 01:58 AM by krim --
Changed lines 3-5 from:

This tutorial is for OpenWRT? (kamikaze 7.09) with 2.6 kernel, but it will

work on other devices too running OpenWRT? on 2.6

to:

This tutorial is for OpenWRT? (kamikaze 7.09) with 2.6 kernel, but it will work on other devices too running OpenWRT? on 2.6

Added lines 14-15:
January 24, 2008, at 01:56 AM by krim -- BootFromUsbDevice
Added lines 1-147:

BootFromUsbDevice

This tutorial is for OpenWRT? (kamikaze 7.09) with 2.6 kernel, but it will

work on other devices too running OpenWRT? on 2.6

If you are unsure what kernel you have use: uname -a

which will give you something like this:

root@OpenWrt:/etc/init.d# uname -a Linux OpenWrt 2.6.21.6 #1 Fri Dec 28 11:04:49 UTC 2007 armv5teb unknown

First of all make sure you have all the modules required:

ipkg update ipkg install kmod-usb-core ipkg install kmod-usb-uhci ipkg install kmod-scsi-core ipkg install kmod-usb-storage ipkg install kmod-fs-ext2 ipkg install kmod-fs-ext3

Then load these modules:

insmod ext2 insmod jbd insmod ext3

Install e2fsprogs and fdisk

ipkg install e2fsprogs ipkg install fdisk

Partition your disk. I have a 1GB Verbatim StoreNGo? and used 700 MB for ext2 and 300 MB for swap

fdisk /dev/sda1 <- change this to your device

Then format your partition:

mke2fs /dev/sda1

Mount it and copy the filesystem to your USB-device

mount -t ext2 /dev/sda1 /mnt
mkdir /tmp/root
mount -o bind /rom /tmp/root
cp /tmp/root/* /mnt -a
umount /tmp/root
umount /mnt

vi /etc/init.d/pivotroot

copy and paste this into /etc/init.d/pivotroot

#!/bin/sh
# change this to your boot device
boot_dev="/dev/sda1"
/sbin/hotplug2 --override --persistent --max-children 1 --no-coldplug &
for module in usbcore uhci 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 30s
        # mount the usb stick
        mount "$boot_dev" /mnt
        # if everything looks ok, do the pivot root
killall hotplug2
        [ -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/jffs2 /jffs2 2>&-
                mount -o move /mnt/sys /sys 2>&-
          }
}

Then make it executable

chmod a+x /etc/init.d/pivotroot

Now, make the symlink so it will start at boot time

ln -s /etc/init.d/pivotroot /etc/rc.d/S10pivotroot

replace everything in /etc/init.d/rcS with this

vi /etc/init.d/rcS

#!/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 '' &

Now reboot and telnet to your slug

Use 'passwd' to set your new root password

exit

and log in with ssh

To make sure it works issue df -h

Which will look something like this

root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/sda1                 1.0M      1.0M         0 100% /mnt/rom
/dev/mtdblock5            5.4M    752.0k      4.6M  14% /mnt/jffs
mini_fo:/jffs             1.0M      1.0M         0 100% /mnt
/dev/sda1               656.1M     19.0M    603.7M   3% /

Fixup resolv.conf symlink

rm /etc/resolv.conf
ln -s /mnt/tmp/resolv.conf.auto /etc/resolv.conf

If you created a swap partition you may want to use it

ipkg update
ipkg install swap-utils
mkswap /dev/sda2
swapon /dev/sda2

Make it start at boot time

echo "swapon /dev/sda2" >> /etc/init.d/swapspace
chmod a+x /etc/init.d/swapspace
ln -s /etc/init.d/swapspace /etc/rc.d/S99swapspace

Use free to see if it worked

root@OpenWrt:/etc# free
              total         used         free       shared      buffers
  Mem:        30472        11628        18844            0          960
 Swap:       297192            0       297192
Total:       327664        11628       316036
view · edit · print · history · Last edited by anywhere.
Based on work by mariob, krbvroc1, fcarolo, and krim.
Originally by krim.
Page last modified on December 28, 2009, at 07:07 PM