loading

The little network routers you can purchase in the store are ok, but they are not upgradeable. With things changing so fast, that seems like a boon only for the router manufacturers. Also firmware upgrades quickly cease. Having a router on a pc makes more sense not only for the ability to upgrade the hardware, but you can add so many more features software wise. You are not limited by the memory or space of the boxed routers. Nothing wrong with the boxed routers for a turnkey setup. If you are like me, you want more. That is why I also use Openwrt.

This is a great project to put an old pc back to work. Openwrt is a cousin so to speak of DD-WRT that  is installed on many brand name routers to increase their capabilities. Openwrt will also allow a pc to act as an expensive router without the big price tag. Of course, you could easy use some of the router distros such as ipcop and many others (see http://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions). openwrt is so much more upgradeable and expandable.

Did this with the original image on a pentium2 and it worked well. If you want the gui, you may need to install the web add-on.

Installing OpenWrt x86 on a PC. (Try this at your own risk!!!)

Requirements:

An X86 compatible pc (i386) or greater with at least 16MB of RAM, 2 network cards, and a hard drive. With newer versions of openwrt require higher hardware requirements. Check openwrt.org for more details.

OpenWrt binary file, for x86.

Old:

http://downloads.openwrt.org/kamikaze/8.09.2/x86/openwrt-x86-ext2.image

Newer:

http://downloads.openwrt.org/snapshots/trunk/x86/openwrt-x86-generic-combined-ext4.img.gz (need to gunzip first) to openwrt-x86-generic-combined-ext4.img

($ gunzip openwrt-x86-generic-combined-ext4.img.gz)

Installation:

For M$ Windows, please also get physdiskwrite. [http://m0n0.ch/wall/physdiskwrite.php]

For Linux just use dd.

Grab the latest binary code from OpenWrt download site.

dd if=openwrt-x86-2.6-ext2.image of=/dev/hda (where hda and image name must be changed)

or

dd if=openwrt-x86-2.6-ext2.image of=/dev/sda (where hda and image name must be changed)

Step 1: Adding the Web Interface.

Appendices: 

Howto get OpenWrt up and running with a web interface given the base image is running.

Edit the network configuration '/etc/config/network' (this assumes a static IPv4 address):

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   eth0
        option type     bridge
        option proto    static
        option ipaddr   192.168.0.126
        option netmask  255.255.255.0
        option gateway  192.168.0.254
        option dns      192.168.0.16 192.168.0.2

Load the updated lan network configuration

# ifup lan

Edit /etc/ipkg.conf. Add the last line (bold)

(use the version for your openwrt. Latest version is 8.x)
src release http://downloads.openwrt.org/kamikaze/7.09/x86-2.6/packages
src packages http://downloads.openwrt.org/kamikaze/packages/i386
dest root /
dest ram /tmp
src X-WRT http://downloads.x-wrt.org/xwrt/kamikaze/7.09/x86-2.6/packages 
(use the version for your openwrt. Latest version is 8.x)

 Update and install webif

root@OpenWrt:~# ipkg update
root@OpenWrt:~# ipkg install webif

Update

 # ipkg update
Downloading http://downloads.openwrt.org/kamikaze/7.09/x86-2.6/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/release
Downloading http://downloads.openwrt.org/kamikaze/packages/i386/Packages
Updated list of available packages in /usr/lib/ipkg/lists/packages
Downloading http://downloads.x-wrt.org/xwrt/kamikaze/7.09/x86-2.6/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/X-WRT
Done.

Install webif

# ipkg install webif
Installing webif (0.3-12) to root...
Downloading http://downloads.x-wrt.org/xwrt/kamikaze/7.09/x86-2.6/packages/./webif_0.3-12_i386.ipk
Installing haserl (0.8.0-2) to root...
Downloading http://downloads.x-wrt.org/xwrt/kamikaze/7.09/x86-2.6/packages/./haserl_0.8.0-2_i386.ipk
Configuring haserl
Configuring webif
Linux OpenWrt 2.6.22 #2 Sun Sep 30 21:02:32 CEST 2007 i586 unknown
Committing new firmware id ...
Device: PC Engines WRAP
Committing new device id ...
SUCCESS! Webif^2 installation appears OK. Welcome to X-Wrt!
You may need to do a hard REFRESH to clear old CSS style from your browser.
Reinitializing httpd ...
Done.

 

Step 2: Adding Space.

This section requires knowledge of bash. Please get a professional to help if you are unsure.

The root partition of the official x86 OpenWrt image is not very big, about 50 MiB.  Many find it too small after installing a few add-on packages.  Here I will cover the steps to expand it.  The resultant image can be used in a live USB (see Easy Live USB for x86 OpenWRT) or copied to a hard disk.

Procedure Outline

  1. Get an uncompressed disk image.
  2. Pad image to desired size
  3. Attach the image file to a loop device
  4. Edit image partition table to enlarge the root partition
  5. Resize the file system in root partition
  6. Detach the image from the loop device.

All commands below are run in Bash.

Uncompress Image File

Use whichever method you like to download an image file from OpenWrt (http://downloads.openwrt.org) and uncompress it using gzip.  For example, these two commands download and uncompress the 10.03.1-rc6 disk image.

bash$ wget --quiet http://downloads.openwrt.org/backfire/10.03.1-rc6/x86_generic/openwrt-x86-generic-combined-ext2.img.gz
bash$ gunzip openwrt-x86-generic-combined-ext2.img.gz

Alternative, you can just copy an image file from a live USB flash drive.  This will save you the trouble of restoring custom configurations.

Pad Disk Image

The next step is to use “dd” to increase the size of the disk image.

bash$ dd if=/dev/zero bs=1M count=50 >> openwrt-x86-generic-combined-ext2.img

This command appends 50 MiB of zeros to the end of the disk image:  “if=/dev/zero” tells dd to copy data from /dev/zero; “bs=1M” sets the block size to 1 MiB (1024*1024 bytes); “count=50” tells dd to copy 50 blocks.

Attach to Loop Device

Note:  All commands from this point to the end need to be run by a user with root privilege.

These commands find an unused loop device and attach it to the image file.

bash$ loop_dev=`losetup -f`
bash$ echo $loop_dev
/dev/loop3
bash$ losetup $loop_dev openwrt-x86-generic-combined-ext2.img

The first command uses “losetup -f” to find an unused device and stores the result in the shell variable loop_dev.  The “echo” command shows the device found.  Finally “losetup” attaches the device to the disk image.

Edit Partition Table

To expand a disk partition, it needs to be deleted first.  A new, larger partition is then created to take its place.  This new partition must start from the same sector as the old to prevent loss of data.

fdisk is used to manipulate the disk partition table.

bash$ fdisk -u=sectors -c=dos $loop_dev

The -u option asks fdisk to list partitions in sectors.  The -c option tells fdisk to operate in DOS compatibility mode.  $loop_dev is the loop device attached to the image file.

To see the existing partitions, type “p” at the fdisk prompt.

Command (m for help): p

Disk /dev/loop3: 107 MB, 107437568 bytes
16 heads, 63 sectors/track, 208 cylinders, total 209839 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

      Device Boot      Start         End      Blocks   Id  System
/dev/loop3p1   *          63        9071        4504+  83  Linux
/dev/loop3p2            9135      107855       49360+  83  Linux

fdisk shows /dev/loop3 has 209839 sectors.  It also lists two partitions.  The first one, /dev/loop3p1, is a small boot partition.  The second, /dev/loop3p2, is the root partition.  The root partition starts from sector 9135.  Make a note of this number.

Now delete the root partition and create a new one that covers all available space.

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 2): 2
First sector (9072-209838, default 9072): 9135
Last sector, +sectors or +size{K,M,G} (9135-209838, default 209838): 209838

Command (m for help): w
The partition table has been altered!

The “d” command asks fdisk to delete a partition, and “2” selects the
 second partition for deletion.  The “n” command asks fdisk to create a 
new partition.  “p” specifies a primary partition, and “2” selects the 
second primary partition.  The first sector of this partition is sector 
9135, same as the deleted partition.  Its last sector is sector 209838, 
the default choice.  This is also the last sector on /dev/loop3.  
Finally, the “w” command writes the new partition table through 
/dev/loop3 to the disk image.

Resize Root File System

The following commands will expand the root file system to the size of the root partition.

bash$ kpartx -a $loop_dev
/dev/mapper/loop3p1: mknod for loop3p1 failed: File exists

The “kpartx -a” command creates device nodes for the partitions in the disk image.  The output of “kpartx –a” (“mknod for loop3p1 failed”) seems to be a bug in my system.  As far as I can tell, the creation and deletion of loop3p1 occur normally.

Another thing worth noting:  kpartx and fdisk use different naming conventions.  kpartx uses “/dev/mapper/device_name”, for example ”/dev/mapper/loop3p1″.  fdisk uses “/dev/device_name”, such as “/dev/loop3p1″.  This is because kpartx works with the device mapper.

Now run “fsck” to check the file system before resizing it.  In fact, some file systems can’t be resized until they are checked.

bash$ fsck -f /dev/mapper/loop3p2
fsck from util-linux 2.19.1
e2fsck 1.41.14 (22-Dec-2010)
Filesystem did not have a UUID; generating one.

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/mapper/loop3p2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/loop3p2: 957/6000 files (0.2% non-contiguous), 8173/49152 blocks

The “-f” option forces a run even when the file system seems clean.
Finally, resize the root file system.

bash$ resize2fs /dev/mapper/loop3p2
resize2fs 1.41.14 (22-Dec-2010)
Resizing the filesystem on /dev/mapper/loop3p2 to 100352 (1k) blocks.
The filesystem on /dev/mapper/loop3p2 is now 100352 blocks long.

bash$ kpartx -d $loop_dev

After resizing, “kpartx -d” reverses the changes made by “kpartx -a”.

Detach From Loop Device

The final step is to detach the image file from the loop device.

bash$ losetup –d $loop_dev

That’s it.  The disk image is now ready to be used in a live USB or copied to a hard disk.

Step 3: Portable Openwrt.

From: http://macbruins.wordpress.com

After creating my OpenWRT live USB (Easy Live USB for x86 OpenWRT), I wanted to use it on an older PC but ran into a problem:  its BIOS does not support booting from USB.  I had two choices.  One was to boot up Linux from CD then switching to USB drive.  The other was to get a CD bootloader that can read USB drives.  Not wanting to do more work, I went searching and found Plop Boot Manager.  It is very impress.  Compact but full of features.  It handles multiboot.  It works with many bootloaders.  It can boot OS on USB or CD without BIOS support.  It even has a great GUI reminiscent of video arcade games.  And it’s free.  Do take a look.

But if you just want to get down to business, I have a ready-to-use CD image (plpbt_hiddenusb.iso on my SkyDrive).  Just insert  the CD and plug in your USB drive.  Plop Boot Manager will do the rest.

Step 4:

Gargoyle (offshoot of Openwrt) running in as an x86 using Qemu.

Step 5: First Pc We Had With X86 Openwrt.

Exerpt from my blog:

Update openwrt PC (x86).

 
More and more of the plastic routers you get from a retailer are limiting you from installling a third party firmware to make the unit more valuable. So it is nice you can put an old pc back to work and install the same kind of firmware you would put on the store bought routers. Also with the pc you can swap the nic cards for better nics without getting a whole new system.


Pulled out of the closet the pc I was using as a router and found that a few things have changed. I just went ahead and installed the latest openwrt kamikaze image on the system. What does the system have? Intel PII 266 mhz with 192 meg ram. The openwrt hard drive is only 2 gig. Thinking about using another case. The system actually has two drives. one with a minimal Debian linux to be able to get the latest image or dd (or install) to the openwrt drive. The Debian linux drive is usally left unconnected.






First thing I did was to change the dead motherboard battery.  Second  thing I did was change the password from the console.



There have been a few changes and a few quirks. When I cranked up the system it did not seem to see the wan (internet). so I had to do a couple of things. 

# Copyright (C) 2006 OpenWrt.org

config interface loopback
    option ifname    lo
    option proto    static
    option ipaddr    127.0.0.1
    option netmask    255.0.0.0

config interface lan
    option ifname    eth0
    option type     bridge
    option proto    static
    option ipaddr    192.168.6.1
    option netmask    255.255.255.0

config interface wan
    option ifname eth1
    option proto dhcp

First I had to add the wan interface to the /etc/config/network file. Those are the last three lines. then I had to bring up the interface with: (ifup wan)

# ifup eth1

I also changed the default ipaddress of the lan from 192.168.1.1 to 192.168.6.1 so as to not interfere with my local network.

local network 192.168.1.x) > router > private network (192.168.6.x)

Then there were changes to some of the commands. You used to use ipkg, so now to update the system you would use (opkg replaced ipkg):

# opkg update

You can ssh root@openwrtbox and do everything remotey from the command line.


So far so good. Then I tried to access a web interface remotely. Did not work, So I had to install a web interface to the system. There are actually three to choose from. I chose Luci or the first on the list suggested in the install notes.  To do that you have to add the repository (where to get the files from). So you add that repository to the /etc/opkg.conf file. In this case it was just one line or the last line in the file:

src/gz snapshots http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /jffs
src luci http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages

Now you let the system know the file has changed, so again you do:

# opkg update

The you need to install the web interface. There are quite a few modules you can install, but I just did the basic interface. You can add more later.

# opkg install luci-web

At this point it would not hurt to do a reboot. You should then be able to see the router's web page.

Cool!  Almost forgot. If you have more than one pc to connect to the router, you will need to get a switch.

Note: Some people say that using a pc for a router has much better throughput that the plastic store bought routers. Your mileage may very. 

Step 6: Almost Embeded

Probably will replace the hard disk with compact flash to reduce energy comsumption and not have to worry about a hard drve moving parts wearing out

Step 7: Hotspot.

I do not know  the pc version of open wrt has drives for a lot of pc cards, but I was able to at least use the following to see if the pc version woul take the install.

http://www.hotspotsystem.com/installation-guide-openwrt
<p>I didn't understand the dd part on linux. </p><p>How do I boot into the partition, and also what kind of file system should I format it to?</p>
<p>If done correctly, you do not need to format the drive dd will take care of that. dd i a command line version norton ghosting utility. If yop are using mswindows, dd will not work, has to be done from a nix box.</p>
<p>I am facing issue while booting up on my PC . I am trying to boot the openWRT from usb on my x86 pc.<br>I have downloaded code from here : git clone git://git.openwrt.org/openwrt.git <br></p><p>I compiled the openWRT for X86 target and generated the below binaries. <br></p><p>openwrt-x86-generic-combined-ext4.img.gz<br>openwrt-x86-generic-combined-squashfs.img<br>openwrt-x86-generic-Generic-rootfs.tar.gz<br>openwrt-x86-generic-rootfs-ext4.img.gz<br>openwrt-x86-generic-rootfs-squashfs.img<br>openwrt-x86-generic-vmlinuz <br></p><p>and I have used openwrt-x86-generic-combined-ext4.img.gz using below mentioned command <br>sudo umount /dev/sdb1<br>sudo dd if=&lt;image&gt; of=/dev/sdb <br></p><p>I am getting below mentioned error. <br></p><p>usb 2-1:2: USB disconnect, device number 8<br>usb 2-1:2: new low-speed USB device number 9 using ehci-pci<br>usb 2-1:2: USB disconnect, device number 9<br>usb 2-1:2: new low-speed USB device number 10 using ehci-pci<br>usb 2-1:2: USB disconnect, device number 10<br>usb 2-1:2: new low-speed USB device number 11 using ehci-pci<br>usb 2-1:2: USB disconnect, device number 11<br>usb 2-1:2: new low-speed USB device number 12 using ehci-pci<br>usb 2-1:2: USB disconnect, device number 12<br>usb 2-1:2: new low-speed USB device number 13 using ehci-pci <br></p><p>I have selected x86, x86_64, </p><p>and I have enabled to yes : kmod-usb-core kmod-usb-uhci kmod-usb-storage <br></p><p>but after that also My issue has not been resolved. <br></p><p>Is it a problem due to scsi ? should I enable kmod-scsi-core also ? <br></p><p>I think it is a issue of configuration settings. Please let me know any suggestion. My requirement is very simple I just want to boot x86 machine and I have downloaded repository from git://git.openwrt.org/openwrt.git.</p>
<p>If you compiled it yourself, then the questions should be directed at the developers. We have only use the compiled and tested versions. You did not mention your specific hardware, so it is kind of hard to answer your question. x86_64, is for 64 bit machines not the true x86 32 bit machines. looks like you are using several nics. try just using two to begin with. The Iso suggestion is not a bad idea for test your system. </p>
<p>try this <br>First Openwrt x86 Installation ISO (24MB) <br>http://www.easyzonecorp.net/network/view.php?ID=1807</p>
<p>I do wonder if it would be possible to adapt the (Open|DD)WRT web interface to work with HostAPD. Been using the config file for a while now on a Linux desktop I keep in my room and it's been working fine. Figure if you're able to do that, you might be able to multipurpose the machine into running a desktop OS at the same time.</p>
<p>Anything is possible, but I prefer to just use the web interface, gui desktop interface will slow the box down and could lead to security issues. The smaller the target the better. On a closed network, it might not be so bad. One two half dozed of another.</p>
Nice one <br>Thanks
Your welcome.
<br>So how do we actually obtain plpbt_hiddenusb.iso ? <br> <br>I have a Stylistic 3400 tablet that won't boot from its USB... this might be just the thing. <br> <br>Thanks, <br> rp <br> <br>
<a href="https://skydrive.live.com/?cid=8fd6b3af3b3cbd39&id=8FD6B3AF3B3CBD39!161" rel="nofollow">https://skydrive.live.com/?cid=8fd6b3af3b3cbd39&amp;id=8FD6B3AF3B3CBD39!161</a>
I use dd-wrt on my router and I absolutely love it. I didn't know this was even possible, and if I had a desktop, I would definitely try this. Wireless-N cards can be purchased for as little as $10 a piece and older computers can be found for free.
Your right and that is what I did. There is a version of dd-wrt for x86, but I never could get the free version to work. Actually openwrt will work in a virtual machine.

About This Instructable

91,681views

43favorites

License:

Bio: computoman.blogspot.com Bytesize articles instead of a trilogy in one post.
More by Computothought:Coffeepot meals Easy sun hat Easy cakes and pies. 
Add instructable to: