Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Summer Project: Conversion of my Asus RT-N16 router to an all-in-one pxe-boot device [Completed]
New Posts  All Forums:Forum Nav:

Summer Project: Conversion of my Asus RT-N16 router to an all-in-one pxe-boot device [Completed]

post #1 of 15
Thread Starter 
memdisk.zip 26k .zip file

I thought I should start a summer project. All the cool kids are doing it.

I re-wrote this post July 26th 2013. I didn't have any replies before and I've made some progress now. Maybe someone will find it useful if nothing else.

Table of contents


In summary, the idea is to turn my Asus RT-N16 router into really a MIPS-based Linux box. Using said Linux box-router I'll then setup DNSMasq/a TFTP daemon for easy PXE network booting of multiple PCs at once.
Summary of router specs (Click to show)

  • CPU: MIPS R2 clocked at 480Mhz (reportedly capable of running at 533MHz) -- All references seem to say Linux kernel 2.6 only (no 2.4)
  • Flash storage: 32 Megs
  • System memory: 128Megs
  • USB ports: USB 2.0 x 2
  • Wifi: 802.11b/g/n
  • Wifi Chipset: WLAN DSP Broadcom Processor (BCM4718A SoC, otherwise known as BCM47xx)
  • Networking: 4 Gigabit Ethernet ports + 1 WAN Gigabit port


Specs at Asus support page
Information from infodepot
Update as of August 2nd 2013 (Click to show)
As almost entirely thoroughly mentioned in the below posts I've actually switched things up a little to get to where I am right now:
  • No longer pursuing a DebWRT-based solution because I'm not sure I would have ever figured it out and apparently the site is completely dead/gone (not even a filler/spam sort of page).
  • Having switched over to OpenWRT, I originally found a work TRX file on a site called ravio.ro (I'll just call this the "ravio build") since the actual regular release builds won't work with the rt-n16. I couldn't get the storage device to work with the ravio build. I had some many problems I decided to just try the "barrier breaker" bleeding edge trunk build from OpenWRT (and this working much better).
  • It's fortunate the trunk builds work with the n16 because the ravio.ro domain is gone as well.

Since switching to barrier breaker (dated July 31st), I have successfully been able to mount my 20 gig 2.5" usb hard drive.
Update as of August 4th 2013: success? (Click to show)
I'm effectively done with the project right now (see my August 3rd post). The USB storage mounts, DNSMasq/the tftp daemon both look to the USB storage for all the files they need and I successfully booted two clients into memtest86+ at the same time.

Only thing really missing is some how assigning a WPS button push to mounting the usb storage device. Or possibly automounting said storage at device bootup and using the WPS button to unmount it. Haven't figured that part out yet.

Now you might say "when not just build a router from an atom-based box/netbook/whatever".

The advantage of a router as a Linux machine is that it's small, super low power consumption/no fans and already has WiFi and a multi-port gigabit Ethernet switch built in (as of this writing the RT-N16 is about $75, also). This N16 also has two USB ports for adding storage devices. Although a netbook with a usb ethernet NIC and 8 port switch strapped to it and also no battery so it powers off when you pull the power cord...well that would require two power cords anyway but...meh, forget it.

The original idea was to install DebWRT, basically Debian built for MIPS processors, on this router so I could set it up the same way I setup all my other servers.

I've run into a few snags in doing this however: DebWRT is a derivative of OpenWRT and the N16 is only available via the bleeding edge, recently compiled "trunk builds" of OpenWRT (referred to as "Barrier Breaker"). In other words DebWRT doesn't actually install on the N16 with a simple firmware download (as far as I know). It might with a custom compilation but I'm not sure I'm going to try that or want to do so that badly. And that the DebWRT web site keeps going down doesn't exactly help.

As of this writing I actually have my new first step completed: I managed to install OpenWRT on my N16. This took an enormous amount of time and frustration to simply realize it was supported in the bleeding edge trunk builds, not in the official release builds. As far as I can tell. Even then I got the build that finally worked from a server in Romania. And now, AFTER I figured this out, the OpenWRT wiki page finally shows as much.
Steps to installing OpenWRT on the RT-N16 (Click to show)
I flashed over to the stock asus firmware to start this but there's no reason this wouldn't work from some other firmware like tomato. No idea about DD-WRT, haven't even tried that one...

List of ingredients:
  • ASUS RT-N16 Firmware Restoration Utility (only for windows)
  • OpenWRT firmware that works on the RT-N16. It's supposed to work with the latest trunk builds. As of this writing I got the working from firmware at http://openwrt.razvi.ro/ (just using the one with the most recent date).
    Update: this ravi.ro site seems to go up and down at random. I haven't tried the plain trunk build hosted by OpenWRT.org yet but that would be the next easiest pre-built image to try: http://downloads.openwrt.org/snapshots/trunk/brcm47xx/
    Update again (august 1st, 2013): After struggling with USB support (see the July 31st post below) I decided I would "start over" with the latest barrier breaker/trunk build which was, appropriately enough, dated July 31st 2013. See link above.
May or may not be possible/necessary: clear the NVRAM (Click to show)
  1. unplug router
  2. push and hold down the RED WPS BUTTON
  3. plug router in
  4. power LED should start blinking in a 3 blinks-and-pause sort of a pattern
  5. release WPS button

The router is supposed to "reboot itself twice". I have no idea how to tell if it's doing this. Outside of the power LED going of for a second or so. Never found out how long this is supposed to take either. I don't think it hurts to try it. Wait at least a few minutes before continuing to the next steps

For the next steps you'll need some ingredients/make a few PC adjustments:
First set a static IP address for 192.168.1.2 on your PC. On Windows this is easy with this command:
netsh interface ip set address name="Local Area Connection" static 192.168.1.2 255.255.255.0
Next download the Asus rescue flash utility. This is supposed to be possible via TFTP push as well but I never did get that to work.
Flashing the firmware (Click to show)
  1. Unplug router
  2. Use pen/paper clip/etc to push and hold down BLACK RESET BUTTON
  3. plug router in: within a second a two the power LED should start flashing in a once-per-second sort of pattern
  4. let go of reset button
  5. Use Asus flash utility to push the router firmware over. It will transfer over and start doing a restoration.
  6. You're supposed to wait "at least 7 minutes" for the router to reboot itself. Mine apparently rebooted in less than five seconds (the power LED blinked off, came back on and 192.168.1.1 was again ping-able).
You can now set your PC back to DHCP:
netsh interface ip set address name="Local Area Connection" source=dhcp

The first the you want to do is logon to router via telnet. Just put in root for the user name and you'll be logged right in. Use the command passwd to set a new password. After that it should let you SSH into it with no issues.

Update: When I first wrote this I thought the convenient web interface for OpenWRT was already installed. Since re-installing I've learned it perhaps is not. The web interface is thus installed:
opkg install luci
The secondary step on enabling the http daemon is also necessary:
/etc/init.d/uhttpd start
After that the router should be reachable at http://192.168.1.1/
I should mention I switched firmware, from a pre-built binary from the Romanian site to the most recent trunk build. It could very well be the Romanian person compiled the luci into the firmware because the Luci I have now for the latest trunk build is way different/much better than the one I was on.

Theoretical summary of steps to completing this project:
  • Get OpenWRT/DebWRT installed on my RT-N16 [completed with OpenWRT]
  • Setup DNSMasq and a TFTP Daemon [All the router ports provide an IP and TFTP works!]
    Update: it occurred that I didn't actually cover how to install tftpd-hpa so I'll make a quick little paragraph here.
    • First, once I was sure the router was actually on the internet I learned about the package manager, opkg: it's a lot like apt-get so I issued the update:
      opkg update
    • Then, similar to apt-get as well, issue the command to install tftpd-hpa:
      opkg install tftpd-hpa
    • This could as easily have been done through the web interface, luci, but i hadn't gotten there yet and I wanted to learn the commands
  • Confirm USB storage devices are easily recognized in OpenWRT
  • Successfully PXE boot a PC from the RT-N16 into DBAN/DOS image/memtest86+/whatever via image stored on USB storage device

Assuming this is all done...the goal is to see how many PCs I can get installing an OS through this router at the same time.
Edited by subassy - 8/23/13 at 12:13pm
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #2 of 15
Thread Starter 
Still have a few things left with this project:
  • I already figured out how to connect the router's wifi to the main/cable modem router (a linksys 54g!) but the internet doesn't connect through it. It's probably an easy configuration change.
  • I need to learn more about the UCI system. Specifically figure out if I can use that to configure tftpd-hpa with it. Or figure out how to use DNSMasq's built-in TFTP daemon.
  • For that matter figure out the proper configuration for DNSMasq in general: accessing the rest of the network via the wireless interface, setting a static IP, etc.
  • Still haven't tried plugging in a USB thumb drive so be sure it autdetects/mounts it. And also mounts it the same every time. Never did figure out where the fstab is located. I assume it has something to do wit the UCI thing.

Update, 28 July 2013

I spent a few hours searching and experimenting trying to figure out how to make a UCI compliant config file for tftpd-hpa. I wanted to set the default TFTP directory to /etc/config so I could conveniently test that the daemon was working from the windows client. But no matter what I did and how I modified the config file it wouldn't let me "GET" a file with my windows TFTP client.

I was about to move on and attempt to use DNSMasq's TFTP feature when I happened to not only look at the /etc/init.d/ttpd-hpa file but actually notice it was passing said default directory as part the command to start/stop the tftpd daemon.

It was so easy and I had even looked in that file before. Just didn't connect it I guess. I have since successfully grabbed a file over tftp from my windows machine.

Jump down to July 31st
Edited by subassy - 7/31/13 at 11:39pm
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #3 of 15
Thanks for posting this - gives me an idea for a nice project to do at some point. I'm already OpenWRT on my primary router - I plan on adding a magic PXE menu to my router now. Should be relatively straightforward.
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
post #4 of 15
Thread Starter 
Quote:
Originally Posted by Xaero252 View Post

Thanks for posting this - gives me an idea for a nice project to do at some point. I'm already OpenWRT on my primary router - I plan on adding a magic PXE menu to my router now. Should be relatively straightforward.

That's the dream...I want to be able to bring this router and a usb-powered 2.5" hard drive/thumb drive/whatever with me any place and just plug it in and go: dban five machines at once, install a different OS on one or two while testing the memory of others...maybe install one while creating an image of another. Possibilities are endless. In theory. I've learned the rt-n16 while a good router with lots of system memory and flash storage isn't quite ideal for opernwrt. Unless you compile your image. Or catch that Romanian site before it goes down.
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #5 of 15
Thread Starter 
The last couple days I started working on choosing a method of mounting a storage device. I'm still a little unclear on how the auto-mounting/fstab is supposed to work...assuming it works at all...so I was researching scripting a event around pushing the WPS button. Like plug in a thumb drive and push the WPS button and it mounts then push and hold to umount or vice-versa.

I reading the helpful and I can only assume accurate page when it occurred to me I should probably try manuaully mounting a storage device to be sure that works and...it doesn't. No idea why.

I've mainly tried it with a USB 2.5" drive, the kind that requires two usb ports so there's enough power (or whatever).

I actually took it out of a earlier gen xbox 360 enclosure, a 20 gig, with the assumption that a real hard drive would have better performance than a 16gig micro sd card. I actually dban'd it and ran a hard drive utility to make sure it was healthy first. But I digress.

I formatted it the drive as FAT32 and attempted to mount. Didn't matter what variations in the mount command I did I can't get it to mount. Issuing a dmesg | tail clearly shows the system sees the SDA device and the sebsequent partitions but the thing won't mount.


Here's what I tried so far (Click to show)
mount -t fat32 /dev/sda1 /mnt/usb
which gives me
Quote:
mount: mounting /dev/sda1 on /mnt/usb failed: No such device

similar result if I say the file system is "vfat" instead:
mount -t vfat /dev/sda1 /mnt/usb
Quote:
mount: mounting /dev/sda1 on /mnt/usb failed: Invalid argument

Ok so no such device versus invalid argument. Doesn't really matter as either way it's not mounted.

Update/note: I should have noted that around this point I had actually switched from a FAT32 formatted 20 gig spindle hard drive to a 16 micro sd card with a USB adapter. This adapter approach most likely had something to do with if not entirely the cause of the issues described here-in.

I decided to try the only thing left I hadn't tried: re-partitioning/formatting the drive with the actual fdisk included with openwrt:
A great many fdisk commands (Click to show)
First, issue the fdisk command on sda:
fdisk /dev/sda
Well at least that didn't give me an error

Then, the following commands:
  • m lists all the options
  • p to list all the partitions (have to delete the existing one)
  • d to delete: deleted existing partition (apparently win95 LBA)
  • w to write changes and quit, then fdisk'd right back into /dev/sda

Issued:
  • n for add new partition, p for primary
  • 1 to select partition 1
  • used enter at cylinder prompt for default value
  • used enter to again use defaults at size of partition prompt
  • t for change partition’s system id
  • L to list available hex codes
  • 83: Linux - didn't see ext3 or ext2 listed so I just picked "Linux"
  • w - write changes to disk and exit

As I eventually remembered it's necessary to both partition and format a drive I also then found out mkfs is not included by default with openwrt and therefore I managed to install it:
opkg install e2fsprogs
Then, used the mkfs command to attempt to format the device:
mkfs.ext3 /dev/sda1

So now, having used opernwrt itself to natively partition and format the device, surely I will be able to mount it. Surely.
Quote:
root@OpenWrt:~# mount -t ext3 /dev/sda /mnt/usb
mount: mounting /dev/sda on /mnt/usb failed: Invalid argument

i-love-linux-i-love-linux-i-love-linux-i-love-linux-i-love-linux-i-love-linux-i-love-linux....sigh. Where's that emote of the guy banging his against a wall? Well this is close enough. buttkick.gif

Okay despite myself I'm still trying to do this. I did find a forum thread on the openwrt site that said I need the kmod-nls-iso8859-1 package (and also to refer to the usb storage openwrt wiki page), so I tried installing it:
opkg install kmod-nls-iso8859-1
And here is what I get:
Quote:
root@OpenWrt:~# opkg install kmod-nls-cp437
Installing kmod-nls-cp437 (3.8.13-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/brcm47xx/packages/kmod-nls-cp437_3.8.13-1_brcm47xx.ipk.
Collected errors:
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-nls-cp437:
* kernel (= 3.8.13-1-83f9d1ba115ccf300173e20538e0a85c) *
* opkg_install_cmd: Cannot install package kmod-nls-cp437.

Well, good thing I know what means. It's easy sailing from here! What an easy, intuitive time I'm having. I think I'm going to bed.

For reference in case anybody was going to ask:
An fdisk -l (Click to show)
Disk /dev/sda: 16.0 GB, 16021192704 bytes
64 heads, 32 sectors/track, 15279 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 15279 15645680 83 Linux
Or if cfdisk is the preference (Click to show)

root@OpenWrt:~# cfdisk -P s /dev/sda
Code:
Partition Table for /dev/sda

               First       Last
 # Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
-- ------- ----------- ----------- ------ ----------- -------------------- ----
 1 Primary           0    31291391     32    31291392 Linux (83)           None
When plug in device, run: logread | tail (Click to show)
Jul 31 23:32:22 OpenWrt kern.notice kernel: [48857.456000] sd 5:0:0:0: [sda] Write Protect is off
Jul 31 23:32:22 OpenWrt kern.debug kernel: [48857.460000] sd 5:0:0:0: [sda] Mode Sense: 03 00 00 00
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.476000] sd 5:0:0:0: [sda] No Caching mode page present
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.480000] sd 5:0:0:0: [sda] Assuming drive cache: write through
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.532000] sd 5:0:0:0: [sda] No Caching mode page present
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.536000] sd 5:0:0:0: [sda] Assuming drive cache: write through
Jul 31 23:32:22 OpenWrt kern.info kernel: [48857.552000] sda: sda1
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.592000] sd 5:0:0:0: [sda] No Caching mode page present
Jul 31 23:32:22 OpenWrt kern.err kernel: [48857.596000] sd 5:0:0:0: [sda] Assuming drive cache: write through
Jul 31 23:32:22 OpenWrt kern.notice kernel: [48857.604000] sd 5:0:0:0: [sda] Attached SCSI removable disk
Output of mkfs.ext3 /dev/sda (Click to show)
root@OpenWrt:~# mkfs.ext3 /dev/sda1
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
979200 inodes, 3911420 blocks
195571 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4005560320
120 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done
mkfs.ext3: Invalid argument while zeroing block 3911392 at end of filesystem
Writing inode tables: 16/120
Could not write 6 blocks in inode table starting at 524290: Invalid argument

Edited by subassy - 8/1/13 at 8:05pm
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #6 of 15
When I first read your OP I should have mentioned getting the USB storage function to work is going to be an adventure. You've already gotten farther than I ever managed with it. I gave up and just added another server VM to the mix and let it handle PXE booting. Good luck with this project. I'll be watching it for updates.
Red-Scout
(18 items)
 
Asus G53SX-TH71
(12 items)
 
Big Blue
(12 items)
 
CPUMotherboardGraphicsGraphics
AMD 8320 FX Asus Crosshair V Twin Frozr 6950 Twin Frozr 6950 
RAMHard DriveHard DriveHard Drive
Corsair Vengence Red Crucial M4 Western Digital Raptor 300gb Western Digital 1 TB Black 
Optical DriveCoolingOSMonitor
LG Blu-ray Corsair H80 Windows 7 Professional Asus VE248H x3 
KeyboardPowerCaseMouse
Logitech MX 5500 Revolution Black Thermaltake TR2 RX 750w CoolerMaster Storm Scout MX Revolution Cordless Laser Mouse 
AudioAudio
Logitech X-540 5.1 System Creative Sound Blaster X-Fi Titanium Fatal1ty 
CPUMotherboardGraphicsRAM
Intel Core i7 2670QM G53SX NVIDIA GeForce GTX 560M Samsung  
RAMRAMRAMHard Drive
Corsair  Samsung  Corsair  Corsair Force GT3 
Hard DriveOptical DriveOSMonitor
Hitachi Blu-Ray Drive Windows 7 Professional 15.4" 1080p 
CPUMotherboardGraphicsRAM
AMD FX 8120 Asus M5A99FX Pro R2.0 MSI Windforce 6850 Kingston Hyper-Blue 16Gb 
Hard DriveHard DriveHard DriveCooling
3x Seagate Barracuda 3Tb OCZ Agility 2 64Gb 3x OCZ Vertex 2 Plus 32 Gb Cooler Master Seidon 120mm 
OSOSPowerCase
Windows Server 2012 Standard VMs (Server 2012, Windows 7, Windows 8, Ubuntu,... PC Power and Cooling 500w Silencer NXZT Switch 810 
  hide details  
Reply
Red-Scout
(18 items)
 
Asus G53SX-TH71
(12 items)
 
Big Blue
(12 items)
 
CPUMotherboardGraphicsGraphics
AMD 8320 FX Asus Crosshair V Twin Frozr 6950 Twin Frozr 6950 
RAMHard DriveHard DriveHard Drive
Corsair Vengence Red Crucial M4 Western Digital Raptor 300gb Western Digital 1 TB Black 
Optical DriveCoolingOSMonitor
LG Blu-ray Corsair H80 Windows 7 Professional Asus VE248H x3 
KeyboardPowerCaseMouse
Logitech MX 5500 Revolution Black Thermaltake TR2 RX 750w CoolerMaster Storm Scout MX Revolution Cordless Laser Mouse 
AudioAudio
Logitech X-540 5.1 System Creative Sound Blaster X-Fi Titanium Fatal1ty 
CPUMotherboardGraphicsRAM
Intel Core i7 2670QM G53SX NVIDIA GeForce GTX 560M Samsung  
RAMRAMRAMHard Drive
Corsair  Samsung  Corsair  Corsair Force GT3 
Hard DriveOptical DriveOSMonitor
Hitachi Blu-Ray Drive Windows 7 Professional 15.4" 1080p 
CPUMotherboardGraphicsRAM
AMD FX 8120 Asus M5A99FX Pro R2.0 MSI Windforce 6850 Kingston Hyper-Blue 16Gb 
Hard DriveHard DriveHard DriveCooling
3x Seagate Barracuda 3Tb OCZ Agility 2 64Gb 3x OCZ Vertex 2 Plus 32 Gb Cooler Master Seidon 120mm 
OSOSPowerCase
Windows Server 2012 Standard VMs (Server 2012, Windows 7, Windows 8, Ubuntu,... PC Power and Cooling 500w Silencer NXZT Switch 810 
  hide details  
Reply
post #7 of 15
Thread Starter 
As of last night I was able to
  • Mount the 20gig usb hard drive (spindle) with mount -t auto /dev/sda1 /mnt (I don't know if that's technically a good command but it works so I'm not questioning).
  • Tell tftpd-hpa to use /mnt as the root tftp directory and successfully grab a file from it via my windows TFTP client



Contents of my /etc/init.d/tftpd-hpa (Click to show)
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=50

start() {
mkdir -m 0755 -p /var/tftpd-hpa
# hash marks are commented out lines, as below which original
# service_start /usr/sbin/tftpd-hpa -l -s /var/tftpd-hpa
service_start /usr/sbin/tftpd-hpa -l -s /mnt/ubuntu
}

stop() {
service_stop /usr/sbin/tftpd-hpa
}



Still a few issues:
  • I didn't properly umount the drive before turning off my PC last night so the drive is still one and extremely hot. Possible solutions are a spin down program available for openwrt and configuring pushing the WPS button as a mount/umount scripted event. Or keep trying SD card USB adapters until I found one OpenWRT likes.
  • The OpenWRT wiki is all over the place when it comes to auto-mounting things. Some places it says to use fstab while other pages say fstab configuration (via uci) has been completely replaced. This again can be avoided with some sort of mount/umount solution tied to the WPS button push.
  • For whatever reason starting/stopping/restarting the tftpd-hpa daemon takes multiple minutes. Other daemons don't take any time, but that one seems to. Seems to not hesitate at all when I use the Luci web interface.

Outside of the tftpd service hanging so long on the CLI...I could actually test this project right now (assuming the hard drive didn't get too hot and die). Amazing inside of 3 days I went from throw-it-out-a-window to "almost done".
Edited by subassy - 8/3/13 at 10:18am
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #8 of 15
Thread Starter 
Last night I made some big jumps in progress. In fact I'm probably 95% done. I only say that amount because minor details sometimes like to jump out and decide to muck things up to the point of...ya.

All the ingredients were in place: DNSMasq for DHCP, tftpd-hpa for TFTP, my usb storage device (a 2 gig thumb drive for this particular leg of trying to get it to work) and something to boot like memtest for instance. The only left is pulling it all together. Also, I need a pxelinux package.

Although upon further thought I realize I didn't actually need this entire file for the demonstration purposes experiment, here's what I did anyway: first my thumb was already mounted to /mnt (via mount /dev/sda1 /mnt) and changed over to it. I then created a directory called ubuntu and switched there. So at the CLI in /mnt/ubunutu ran To grab the netboot tar ball from ubuntu (the 12.04 LTS one though in this case the version doesn't matter that much) and put it on the thumb drive.
Then, extract the tar ball:
tar -xzvf netboot.tar.gz

Then copied /mnt/ubuntu-installer/i386/pxelinux.0 to /mnt/ubuntu

With pxelinux.0 in my new tftp root of /mnt/ubuntu I was ready for the next step. I'll note hear that pxelinux.0 is effectively a boot loader and the first thing it is going to do is look for a directory called pxelinux.cfg with a file in it called default.

As a side note since this will up later one of the first things the default file is going to do is display a text file which is effectively the boot menu, called boot.txt which is located in /mnt/ubuntu. Here are the two files:
Contents of default and boot.txt (Click to show)
default file:
/mnt/ubuntu/pxelinux.cfg
Code:
DISPLAY boot.txt

LABEL memtest86+
LINUX memdisk
INITRD memtest/mt420.iso
APPEND iso

PROMPT 1
TIMEOUT 0

boot.txt contents (/mnt/ubuntu)
Code:
Available Boot Options:
=======================
memtest86+

I should also mention I was memtest86+ as a test bed for my network booting since it's easy and the ISO can be used. The ISO on the memtest site is zipped up so I needed to install the unzip package:

opkg update
opkg install unzip

Then create a directory to store it:
mkdir /mnt/ubuntu/memtest

and unzip ISO to said memtest directory:
unzip memtest86+-4.20.iso.zip


I've been a little confused (and the OpenWRT wiki is sometimes little help) about which files exactly various things are supposed to be configured from. There's /etc/config/dhcp and there's /etc/init.d/dnsmasq. I'm not sure if I'm supposed to configure things in one more than the other. I'm only assuming they're related.

I did note that the /etc/init.d/dnsmasq pointed to file /var/etc/dnsmasq.conf (which really a sym link to /tmp/etc). Any changes I tried to make to /var/etc/dnsmasq.conf didn't survive a reboot but I did note that /var/etc/dnsmasq.conf pointed to /var/etc/dnsmasq.conf.

I modified /var/etc/dnsmasq.conf to include the line
dhcp-boot=pxelinux.0

I actually tried pxe booting a this piont but the client returned No boot filename received reponse. Okay, so it knows we're talking but can't find pxelinux.0 to find the pxelinux.cfg directory. That's how I interpret it.

So next thing, there's establishing the "root" of the tftp daemon is in fact where I think it is. Since nothing I was trying was working I took a step back and looked at a laptop of mine (i call it kicktop-2) that already has this pxebooting thing working for a working version of the tftpd-hpa config file:
Code:
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"

So apparently there's more options than just that "-l -s /var/lib/tftpboot" established back in my /etc/init.d/tftpd-hpa config file start line.

So the choices are either figure out how to properly format a custom config file via the UCI system or...figure out how to just paste that content into a new file and use that.

When I was in the "/var/etc/dnsmasq.conf" file I noted the line CONFIGFILE="/var/etc/dnsmasq.conf" which gave me the idea a similar sort of line in the /etc/init.d/tftpd-hpa file, thus my new /etc/init.d/tftpd-hpa file:
edited /etc/init.d/tftpd-hpa (Click to show)
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=50

CONFIGFILE="/etc/tftpd-hpa"
start() {
mkdir -m 0755 -p /var/tftpd-hpa
# service_start /usr/sbin/tftpd-hpa -l -s /var/tftpd-hpa
service_start /usr/sbin/tftpd-hpa -l -s /mnt/ubuntu
}

stop() {
service_stop /usr/sbin/tftpd-hpa
}

Then I created the file /etc/tftpd-hpa with the following, based on that working configuration I mentioned:
New /etc/tftpd-hpa file (Click to show)
FTP_USERNAME="tftp"
TFTP_DIRECTORY="/mnt/ubuntu"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
RUN_DAEMON="yes"
#this is convered in the init.d file so i commented it out
#OPTIONS="-l -s /var/lib/tftpboot"

I then restarted dnsmasq/tftpd-hpa and the network and tried booting a device again:
boot.txt display!
Typed in memtest86+ and got a message something to the effect of:
couldn’t find the kernel image memdisk

I spent probably multiple hours working on that little problem. It's really annoying to be so close to finishing a thing and be stuck on that one little last step.

I'll save you the head-pounding trial-and-error details and skip the solution: as you may notice, in the default file is the line
LINUX memdisk
obviously referring "linux" to "memdisk". Well apparently I didn't take thorough enough notes when I was first doing this because this memdisk file apparently doesn't come in the boot image tar ball. I think it may come with syslinux. I haven't actually downloaded the different packages to find out which one it's in. But I digress

I unmounted and connected my thumb drive to the working config kicktop-2 and copied the memdisk file over and connected the drive back to the router and mounted.

Once the default file could actually find the memdisk file...

it actually works!!

Not necessarily 100% done yet but this is as close as I've come so far. I still need a way of at least mounting the storage device either automatically at boot up or via a button push so that running the command via SSH is not necessary.
Edited by subassy - 8/3/13 at 5:51pm
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #9 of 15
Thread Starter 
Adventures in button pushing

I think I mentioned this previously but I'll mention it again: OpenWRT does not use /etc/fstab. It's pretty much impossible to tell from the wiki what it would use in its place.

Even though I'm doing basically everything I set out to do with this router being able to mount and unmount the storage device without rebooting the router or having to SSH in and manually adjust would be a significant usability feature. So I set out to try and accomplish this.

What I soon realized, in my mount/unmounting manually adventures, is that unmounting /dev/sda1 is going to error out if the TFTPD daemon is running and pointing at it (says the device is in use). So I had to really assign the button to both stopping TFTPD and then unmounting /dev/sda1.

The TFTP daemon is this case is tftpd-hpa and I've been using /etc/intit.d/tftpd-hpa start/stop/restart/reload to control the status of the daemon.

First, I had to figure out if I could even capture the button press/release event.

I should mention is my desperation/inpatience to try and get some kind of response out of the button I was copy/pasting a lot of install package commands and putting in a lot of files. At some point I simply pushed the WPS button the the wifi disabled. So I had the task of finding where this action was being assingned. Doing a find command I found these three files:
Quote:
/etc/rc.button/failsafe
/etc/rc.button/reset
/etc/rc.button/rfkill

I tried editing them and creating my own scripts with similar syntax but I couldn't get the button to do anything with my own script so I moved all the scripts to subdirectory under rc.button called backup so at least the button wouldn't be doing anything.

Next, even though I have no idea if it's really necessary or not, I followed the instructions on the OpenWRT wiki about assigned a button push only the script in the first didn't actually exist so I created it with the suggested content. The wiki doesn't say anything about having to make it executable but I did anyway.
/etc/hotplug2.rules (Click to show)
Code:
$include /etc/hotplug2-common.rules
 
SUBSYSTEM ~~ (^net$|^input$|button$|^usb$|^ieee1394$|^block$|^atm$|^zaptel$|^tty$) {
        exec /sbin/hotplug-call %SUBSYSTEM%
}
 
DEVICENAME == watchdog {
        exec /sbin/watchdog -t 5 /dev/watchdog
        next-event
}


Then, per the wiki, created this buttons file:
/etc/hotplug.d/button/buttons (Click to show)
Code:
#!/bin/sh
logger $BUTTON
logger $ACTION

I tried pushing the button after that: the wifi stayed enabled and upon running the logread | tail command got the desired output:
Code:
 OpenWrt user.notice root: RESSET 
 OpenWrt user.notice root: pressed   
 OpenWrt user.notice root: RESET    
 OpenWrt user.notice root: released

Ok so I didn't copy/paste the exact entry from the SSH window. It's close enough and point is I've got some kind of acknowledgement of the WPS button's existence. Also, the OS is referring to the button as RESET.

After much experimenting with the entries the /etc/config/system file I determined that a push of the button could almost entirely reliably stop TFTPD and unmount /dev/sda1 but could not, under any circumstances start TFTPD.

Generically, the entry in the /etc/config/system file looks something like this:
Code:
config button
        option button 'RESET'
        option action 'pressed'
        option handler 'mount /dev/sda1 /mnt'

For whatever reason using an echo in that handler statement doesn't do anything. It is possible to add an entry via logger and get output that way with the logread | tail command.

It is possible to hand off that handler entry to a separate shell script, which I did.

And wow, I so many different combinations of commands to make this button work.

I was trying to build in some logic: if sda1 is mount then stop TFTPD and run the umount command. It isn't mounted then mount it and start TFTPD command.

This command, for instance, will run on the CLI and works 100% of the time:
Code:
if [ $(ls -l /mnt/) == ""]; then mount /dev/sda1 /mnt; /etc/init.d/tftpd-hpa restart; /etc/init.d/dnsmasq restart; else /etc/init.d/tftpd-hpa stop;  cd /;  umount /mnt; fi

But if I literally paste that entry into either an external script or directly into that option handler entry it doesn't work.

I finally just tried stopping tftpd-hpa and putting in nothing but /etc/init.d/tftpd-hpa start for the handler and...it didn't work.

I actually tried this:
(mount /dev/sda1 && /etc/init.d/tftpd-hpa start) && logger -t tftpdstart "started?"

which unless I don't understand command lines and boolean logic as well as I think (which is possible) should be saying first run the mount and tftpd start commands AND ONLY IF THOSE TWO WORKED run that logger command... right? So if either the mount or daemon start things didn't work I shouldn't have that logger entry...

Well I still got the logger entry, sda1 was mounted, but tftpd was still stopped.

So I've about had enough of banging my head against the wall trying to get that logical mount/unmount button push functionality to work.

As a work around I put in the mount and tftpd commands in the local.rc file so sda1 is just mounted as the device boots. I then used the above method to try and unmount it when I push the button. Without any kind of external visual indicator I don't have a way of knowing if this actually worked.

Any suggestions/help on this are welcome. Otherwise this project is officially declared done. Until I decide to do a start-to-end article for the articles section anyway...

I may or may not post come bonus content (one or more scripts I ended up creating in my trying to get this work) below.
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
 
VM Server
(17 items)
 
 
CPUGraphicsRAMHard Drive
Intel Ivy Bridge Core i7-3630QM nVidia GeForce GTX 680M 16GB DDR3 1600MHz Dual Channel Memory (2 SODIMMS) Hard Drive: Serial-ATA II 3GB/s 
Hard DriveOSMonitorPower
Hard Drive: Serial-ATA II 3GB/s Windows 10 Pro x64 17.3" FHD 16:9 (1920x1080) Battery: Smart Li-ion Battery (8-Cell) 
Audio
Sound Blaster Compatible 3D Audio 
CPUMotherboardGraphicsRAM
Intel Core i7 860 Biostar T5 XE Radeon HD 5870 Corsair 16GB  
Hard DriveHard DriveOptical DriveOS
Western Digital hard drive wd1001fals-00e8b0 Maxtor 300GB I don't need no stinking optical drive Microsoft Windows 7 Ultimate x64 
MonitorMonitorKeyboardPower
HP ZR24w 24'' Samsung SyncMaster 24" logitech wireless k360 Seventeam ST-850ZAF 850W ATX 
CaseMouseAudioAudio
Thermaltake V9 Black Edition Logitech G500 Programmable Gaming Mouse FiiO E7 USB DAC and Portable Headphone Amplifier Sennheiser HD555 Professional Headphones 
  hide details  
Reply
post #10 of 15
Hey, I know this is from a little while ago, but I just randomly happened to come across it. Just wanted to let you know if you usedd dd-wrt pretty much everything you wanted to do is already built in and could be achieved with just changing a few configs. But it seems like you probably enjoy doing it this way and the learning... well good luck and thanks I took some notes from your posts.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Summer Project: Conversion of my Asus RT-N16 router to an all-in-one pxe-boot device [Completed]