OpenWrt Forum Archive

Topic: [HowTo] OpenWRT on x86 PC

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

Salut !

In order to get more familiar with the lightest and awesome distro that OWRT is, I had to install it on my PC or in VMWare.
And there are not much information for almost beginners like me... So I will write here what I do with 8.09 version.

Note : This HowTo is based on the Slitaz 2.0 distro, the next lightest distro after OWRT : http://www.slitaz.org
"SliTaz is an open source and free operating system providing a fully featured desktop or server in less than 30 Mb."
Great for old PC with 192 MB Ram min and small HDD. Thanks Slitaz (and Erjo how help me) !
Slitaz is also available as a core distro (without Xorg) : only 6 MB and only 128 MB Ram !
See the slitaz-2.0-base.iso version here : http://mirror.slitaz.org/iso/2.0/flavors/


[HowTo] Install OpenWRT on x86 PC

1 - Get the image here : http://downloads.openwrt.org/kamikaze/8.09/x86/

Some informations first : The openwrt-x86-XXX.fs files contain only the rootfs partition whereas the openwrt-x86-XXX.image.kernel files contain the kernel partition.

I download the openwrt-x86-ext2.image file. It produces a standard installation, like any Linux distro. Try this first !
(If you want to see how jffs with mini_fo works like in a router, you can use the openwrt-x86-squashfs.image. I didn't try yet the jffs2 files...)

Copy the image on a USB key.

2 - Copy the image on HDD :

For this, download the LiveCD Linux distro Slitaz : you don't need to install it.

Boot your PC with the Slitaz CD and login as tux (No PWD). The disk where to install OWRT (I'll say it is /dev/hda) will be detected automatically by Slitaz (Note : I don't have tested this with SATA HDD).
Insert USB key, it'll appear in the file manager (in the dir /media/USB2 or something like that, depends on your key)
Open a console and get root via "su -" and the root pwd which is : root.
Copy the image on HDD : "dd if=/media/USB2/openwrt-x86-ext2.image of=/dev/hda bs=1M count=100"
That's all folks !

3 - Boot on HDD and enjoy OWRT
:)


Now, for those who want to make a "LiveUSB Key" installation of OWRT, you need the ramdisk image of OpenWRT. It's not available in the download repository so you will first need to compile it. Here's my method :
[HowTo] Compile OpenWRT

1 - Install Slitaz 2.0 on a dedicated 4 GB min HDD (in a VM, for example) :

Boot your PC on the Slitaz CD and login as tux (no PWD).
Open a console and get root via "su -" and the root pwd which is : root.
Partition your HDD with "fdisk /dev/hda", type "n" to add a new partition hda1 and "w" to write the partition table.
Launch "slitaz-installer" as root and follow instructions. You can get help with Slitaz on forum (http://forum.slitaz.org).
Slitaz is now installed on /dev/hda1.

Now, you will need to install some more packages. Run this as root : "tazpkg recharge; tazpkg get-install slitaz-toolchain".
Do the same "tazpkg get-install XXX" for : bash, ncurses-dev, zlib-dev, gawk, flex, bzip2, python, tar, findutils, wget, patch, diffutils, perl, coreutils. Though it's not checked by prereq.mk, the m4 package is necessary to compile 8.09.1 sources (for the trunk compilation, no m4 package but you'll need the subversion package).

Note : you can also install sakura package (another xterm) to help copy and paste in console.

2 - Get sources of OpenWRT 8.09 and compile it :

Now you can get, configure and compile OWRT as normal user Tux :
Download and go into the extracted tar.bz2 sources directory (from http://downloads.openwrt.org/kamikaze/8.09.1/).
("svn co svn://svn.openwrt.org/openwrt/trunk owrt; cd owrt" for the trunk)
"make menuconfig"
Select in the target system menu, the X86 generic PC. Then in the target image menu, select generating a ramdisk file.
Save configuration before exit then run "make".

After a quite long time, the result of compilation is in /owrt/trunk/bin. The ramdisk file is a very little file called openwrt-x86-vmlinuz, containing the kernel and ramdisk rootfs.

Here is my own build :
stock 8.09.1 Ramdisk
(R15955 of the trunk)

Nota : You can find another HowTo here with Ubuntu/VMWare for WhiteRussian : http://forum.openwrt.org/viewtopic.php?id=8410.
You can also find generic help for building OWRT there, as usual : http://downloads.openwrt.org/kamikaze/docs/openwrt.html

3 - Install OpenWRT image on a USB key :
We're going to install Slitaz on an existing FAT USB key and add the OWRT image to it.
So in Slitaz, launch "tazusbbox" as root. Select the source to install (CDRom) and the USB key for destination (certainly /dev/sda1). Then generate.
That's it : Slitaz is installed on the key. Try it, that's great !

Next, copy the ramdisk file as vmlinuz in a OWRT directory on the USB key. Then modify the file boot/syslinux/syslinux.cfg as this :

display syslinux.msg
label slitaz
    kernel /boot/bzImage
    append initrd=/boot/rootfs.gz rw root=/dev/null vga=normal autologin home=2C3F-6155

include common.cfg

label owrt
    kernel /OWRT/vmlinuz
    append console=tty0 reboot=bios

default owrt
timeout 20

With this, Openwrt will boot as default after 3 seconds (Slitaz is still available). You can enjoy OpenWRT on any PC, boot in 2 seconds. But your modification will not remain after a reboot...


Next one, my method to :
[HowTo] Make "LiveUSB Key" OpenWRT

Needed : The steps above are supposed to be done.

1 - Create a rootfs addon to modify the stock ramdisk :

The modifications will be made via another initrd append to the first one (see here : http://www.mjmwired.net/kernel/Document … s.txt#210). I called it modUSB.gz.

I create a modUSB directory in my home where will be the rootfs modifications.
Add an opkg directory where you can place all the packages you want to add to the stock ramdisk.
So I download (from http://downloads.openwrt.org/kamikaze/8 … packages/) and place :
* In opkg/std, the packages needed to have the ext3 and loop support :
kmod-fs-ext3_2.6.25.20-x86-1_i386.ipk
kmod-loop_2.6.25.20-x86-1_i386.ipk
* In opkg/fat, all the packages needed to see VFAT partition on the key :
kmod-fs-vfat_2.6.25.20-x86-1_i386.ipk
kmod-nls-base_2.6.25.20-x86-1_i386.ipk
kmod-nls-cp437_2.6.25.20-x86-1_i386.ipk
kmod-nls-iso8859-1_2.6.25.20-x86-1_i386.ipk
* In opkg/usb2, all the packages needed to have USB2 support for the key :
kmod-scsi-core_2.6.25.20-x86-1_i386.ipk
kmod-usb-core_2.6.25.20-x86-1_i386.ipk
kmod-usb-storage_2.6.25.20-x86-1_i386.ipk
kmod-usb2_2.6.25.20-x86-1_i386.ipk

* And everything else you need...

Then I use this little script to create the modUSB.gz :

#!/bin/sh
(cd modUSB; find . | cpio -o -H newc | gzip -9) > modUSB.gz

2 - Modify the init script to add the loop function :

The stock one is in the OWRT directory, there : target/linux/generic-2.6/base-files/init.
I made it a little more simpler, faster and add loop function and ability to use opkg added to the directory called "modUSB".

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

## ModUSB
# Copie du rootfs initial
mkdir /modUSB/tmp
cp -a /* /modUSB/tmp 2>/dev/null
rm -r /modUSB/tmp/modUSB/tmp

# Changement du clavier si besoin
[ -n "$lang" ] && loadkmap < /modUSB/$lang.kmap

INITRAMFS=1

. /etc/preinit

# if we have no root parameter, just go to running from ramfs
[ -z $rootfs ] && {
  export NOMOUNT="No Root"
  exec /sbin/init
}

#if we have a failsafe boot selected, dont bother
#trying to find or wait for a root mount point
[ -z "$FAILSAFE" ] || {
  exec /bin/busybox init
}

# Chargement des packages presents dans /modUSB
opkg install /modUSB/opkg/*.ipk >/dev/null
opkg install /modUSB/opkg/*/*.ipk >/dev/null

# Load the modules we have in initramfs, this should
# make the media accessible, but, it may take some time
. /etc/functions.sh
load_modules /etc/modules /etc/modules.d/*

#wait 10 seconds for the disc to show up
#usb stick typically takes 4 to 6 seconds
#till it's readable
#it's quite possible the disc never shows up
#if we netbooted this kernel
COUNTER=0
while [ ! -e ${rootfs%-loop} ]; do
  sleep 1; echo -e "\nWaiting for device ${rootfs%-loop}"
  let COUNTER=COUNTER+1
  [ $COUNTER -eq 9 ] && {
    export FAILSAFE="NoDisc"
    exec /bin/busybox init
  }
done

# Test si mode loop : rootfs=XXX-loop
[ "$rootfs" != "${rootfs%-loop}" ] && loop=/tmp/mnt/FsOWRT

# now we'll try mount it, again with a timeout
# This will fail if the inserted stick is formatted
# in a manner we dont understand
e2fsck -p ${rootfs%-loop}
COUNTER=0
[ -z $loop ] || mkdir -p /tmp/mnt
while ! mount ${rootfs%-loop} ${loop:+/tmp}/mnt; do
  sleep 1
  let COUNTER=COUNTER+1
  [ $COUNTER -eq 9 ] && {
    export FAILSAFE="MountFail"
    exec /bin/busybox init
  }
done

[ -z $loop ] || {
# Montage du filesystem en loop (apres initialisation si besoin)
[ ! -f $loop ] && mke2fs -V >/dev/null && {
  dd if=/dev/zero of=$loop bs=1024 count=49152
  mke2fs -q -j -F $loop
}

cp /modUSB/FsOWRT.bz2 $loop.bz2
[ ! -f $loop -a -f $loop.bz2  ] && {
  cp $loop.bz2 $loop.1.bz2
  bunzip2 $loop.bz2
  mv $loop.1.bz2 $loop.bz2
}

COUNTER=0
while ! mount -t ext3 -o noatime,sync $loop /mnt; do
  sleep 1
  let COUNTER=COUNTER+1
  [ $COUNTER -eq 9 ] && {
    export FAILSAFE="LoopMountFail"
    exec /bin/busybox init
  }
done

[ ! -e /mnt/etc/banner ] && rm -r /mnt/* && mv /modUSB/tmp/* /mnt

# Nettoyage
for i in `ls /modUSB/opkg/e2fs | sed 's/_.*//'`; do opkg remove $i; done
rm -r /modUSB/opkg
}

rm -r /modUSB/tmp

#It mounted, lets look for a postinit file, again, give it time
#I've seen this take 6 seconds to actually complete
COUNTER=0
while [ ! -e /mnt/etc/banner ]; do
  sleep 1
  let COUNTER=COUNTER+1
  [ $COUNTER -eq 9 ] && {
    export FAILSAFE="No Openwrt FS"
    exec /bin/busybox init
  }
done

unset rootfs loop

for i in proc dev "dev/pts" tmp sys; do
  mount -o move /$i /mnt/$i
done
killall -q hotplug2
exec switch_root -c /dev/console /mnt /sbin/init

3 - Modify your OpenWRT installation on your USB key :

Modify the file boot/syslinux/syslinux.cfg to add the rootfs directive with loop : for example /dev/sda1-loop for a key that the system see in sda1. Add also the initrd directive to take the modUSB.gz into account. I also add a "lang" parameter (see below for the keyboard layout).

In bold, are the modifications :
label owrt
    kernel /OWRT/vmlinuz
    append initrd=/OWRT/modUSB.gz lang=fr-latin1 rootfs=/dev/sda1-loop console=tty0 reboot=bios

With this, Openwrt boot in 12 seconds from the USB key on my not so new notebook.
I can now enjoy OpenWRT on any PC, and all my modifications remain after a reboot...

You can find my modUSB.gz here.


[HowTo] Change keyboard layout in OpenWRT

When you have no network and have to use OWRT console, it's a pain to use the default US keyboard with a french one...

So you'll have to add the loadkmap utility to busybox via the .config located in the root of the OpenWRT sources. Search for the loadkmap word and change the line "# CONFIG_BUSYBOX_CONFIG_LOADKMAP is not set" to "CONFIG_BUSYBOX_CONFIG_LOADKMAP=y". Then launch the compilation of your ramdisk image as usual.
If you have already compile it, you can re-compile only busybox and get the new ramdisk image with :
"make package/busybox/clean; make package/busybox/install; make target/install"

The busybox package is only 0.1 Kbytes larger with this. Now add, for example, the fr-latin1.kmap to your rootfs (you can find it in the /usr/share/kmap dir of the slitaz distro). To use it, just try "loadkmap < fr-latin1.kmap". Et voila, no more headake ;)

If needed, I can provide the 8.09.1 ramdisk with loadkmap inside.


[HowTo] Add cpio archive creation in OpenWRT

Will be interesting for next step...
Like above, via the .config located in the root of the OpenWRT sources.

Search for the CONFIG_CPIO word and change the line "# CONFIG_BUSYBOX_CONFIG_CPIO is not set" to "CONFIG_BUSYBOX_CONFIG_CPIO=y". After this, add the line "CONFIG_BUSYBOX_CONFIG_FEATURE_CPIO_O=y".
Re-compile only busybox and get the new ramdisk image with :
"make package/busybox/clean; make package/busybox/install; make target/install"

The busybox package is only 0.75 Kbytes larger with this.

If needed, I can provide the 8.09.1 ramdisk with cpio and loadkmap inside.




Next HowTo to come, if I succeed it, I'll try next to had informations how to modify the ramdisk image in order to have a /jffs file on the USB key and save all your modifications there (based on this : http://oldwiki.openwrt.org/ReplaceJFFS2 … edia.html).

Stay tune ;)

A+

PS : no support via PM, forum is here for everyone's use.

(Last edited by fxmx86 on 3 Jul 2009, 22:35)

Dear

thanx for reply is it possible to install it on USB stick,,,,

any how to,,,,, that is tested.

obrienj wrote:

I have VMware Workstation 6.5 and would like to build an Openwrt x86 virtual machine to do testing with so I don't have to carry a router around with me.

Do you have any thoughts on how I might adapt your HowTo to accomplish this?

I'm also not sure how the last step of your HowTo works. It seems you have two bootable images on the disk, do you use Grub to decide what to boot.

Bear in mind that even though I have worked on and off with Unix based systems over 45 years some of the nuiances of Linux are not that familiar to me.

Any help you can provide would be greatly appreciated.

Hi,

With VMWare, you do exactly the same :
After creating your VM, you boot with Slitaz ISO, dd the image on your HDD, and reboot without Slitaz.
Your VM will boot on the HDD, with OWRT installed.

Bye

1st post updated to add HowTo compile OpenWRT on Slitaz 2.0, a great and very light distribution !

Enjoy !

I just saw one hour ago that Slitaz is available as a core distro (without Xorg) : only 6 MB !

See the slitaz-2.0-base.iso version here : http://mirror.slitaz.org/iso/2.0/flavors/

Slitaz seems to be interesting for creating an OpenWrt build environment smile

fxmx86 wrote:

As the time of writting, I can't get the svn://svn.openwrt.org/openwrt/branches/8.09 to compile so I take the trunk.

I tried to compile 8.09.1 tar.bz2 sources and get the same error when building autoconf-2.62 :
"There seems to be no Makefile in this directory.
You must run ./configure before running 'make'"

I resolved this when installing the m4 package in slitaz (though it's not checked by prereq.mk and unneeded for the trunk version).
Cool, we're going to be able to use all the 8.09.1 packages !

1st post updated with the 8.09.1 ramdisk compilation !

Enjoy...

hi,

I'm trying OpenWRT on x86 hardware and need the pegasus usb-to-nic module (when I boot, just integrated nic is found). just to confirm, this rebuild procedure could be used to add this module, right ?

thanks,

matheus

Certainly, that's the goal : Modifying, adding packages already compiled quite easily on x86 hardware !

For now on, the recipe isn't finished yet but step by step ...

Bye

1st post updated with howto change the keyboard layout in console.

Enjoy...

1st post updated with howto add cpio archive creation...

Here it is :
1st post updated with howto have a LiveUSB key !!!

Enjoy...

fxmx86 wrote:

1st post updated with howto have a LiveUSB key !!!

/etc/preinit.arch should be used instead of modifying /sbin/init.

Dogge wrote:
fxmx86 wrote:

1st post updated with howto have a LiveUSB key !!!

/etc/preinit.arch should be used instead of modifying /sbin/init.

Thanks.
You're right, I should put all the modUSB specific things in preinit.arch.
But the loop modification of /init will certainly stay there.

matheusber wrote:

hi,

I'm trying OpenWRT on x86 hardware and need the pegasus usb-to-nic module (when I boot, just integrated nic is found). just to confirm, this rebuild procedure could be used to add this module, right ?

thanks,

matheus

So matheus, did you find a solution with my little HowTo ?

I'm trying to run Slitaz LiveCD in VMWARE workstation to install slitaz in dedicated 4GB disk. But fdisk /dev/hda produced the error "can't open /dev/hda. no such device or address". I checked the dmesg. Only CD-ROM is detected as hdc. No hda and hdb. Does someone know why this happened with slitaz live cd installation in vmware?

Thanks a lot.

Lou

madmatrix wrote:

I'm trying to run Slitaz LiveCD in VMWARE workstation to install slitaz in dedicated 4GB disk. But fdisk /dev/hda produced the error "can't open /dev/hda. no such device or address". I checked the dmesg. Only CD-ROM is detected as hdc. No hda and hdb. Does someone know why this happened with slitaz live cd installation in vmware?

Thanks a lot.

Lou

Hi !
May be you try with SCSI HDD, and Slitaz don't support this ?
Try again with IDE, as it's the same setup than mine and I've no problem
And you can find some help on Slitaz Forum, they were very nice to me...

bye

(Last edited by fxmx86 on 26 Aug 2009, 23:50)

Please , I need to configure an Access Point with openwrt in my PC x86.
How can i do?

I need to configure:      wireless interface (with atheros)
                                   ethernet
bye

Hi,
First did you manage to start openwrt on your X86 ?

help~!

slitaz 2.0
"tazpkg get-install XXX" for : bash, ncurses-dev, zlib-dev, gawk, flex, bzip2, python, tar, findutils, wget, patch, diffutils, perl, coreutils.

all install

make menuconfig

build dependency:  please install gnu fileutils        why?

(Last edited by kemp on 17 Nov 2009, 18:15)

Hi Kemp,

Did you try to compile 8.09.1 sources ?
If it's the trunk, certainly the packages needed change...

You didn't find the gfileutils (or something like that) in the slitaz packages ?

Tell us more ...

I have used SVN to download (svn co svn://svn.openwrt.org/openwrt/trunk )

GOOGLE could not find the information with glistutils

You try to compile the trunk so it's normal then you need differents packages...
You need to use tazpkg to install some more packages needed by Owrt compilation : try "tazpkg recharge; tazpkg search file" to know which ones could help you...

fxmx86 wrote:

You need to use tazpkg to install some more packages needed by Owrt compilation : try "tazpkg recharge; tazpkg search file" to know which ones could help you...

I have compiled OpenWRT SVN trunk to use on my FON2100 and WGT634U device for a couple of years now. Yet, this is the first time I have seen/heard about tazpkg. What exactly is tazpkg and why would one need it if OpenWRT SVN trunk can be compiled without it?