Monday, August 18, 2014

Installing Puppy Linux to Hard Drive

I was having some trouble that I felt was unnecessary, trying to install Puppy Linux to a hard drive (HDD) on an older computer.  The Puppy Universal Installer makes it easy, but I was messing something up.

This post assumes you just want Puppy Linux on your HDD, so no partitioning to make it simpler (I would recommend this to only PC's you keep off the internet).  Otherwise, you would have to use a program like GParted and partition your drive how you want (maybe even encrypt for extra security).

Before you begin, first you should already have a copy of bootable Puppy Linux on a USB stick or CD/DVD, previous posts show how to do that and the procedure stays the same mostly and is pretty easy.

You need to check the type of your HDD as Puppy Linux will ask you in the Universal Installer.  Check to do the Full Install and not Frugal (unless you want to use the HDD for something else, putting Puppy Linux on a HDD is assuming the computer is old and can't run much else with modern speed and convience).

These parts were all pretty self-explanatory.  What's tricky is after you get done.  DO NOT DELETE THE TEXT FILE THAT COMES UP AFTER INSTALL.  You need it.  Set up Grub4Dos and install on the MBR.  Mostly point and click setup that's made easy for you.  Now, *IF* you have a IDE-base HDD, you should change the line in the menu.lst file.  Otherwise the install won't work.  It's about 3 lines.  Copy the lines from the text file and paste into menu.lst.

This should work and you should be able to boot Puppy Linux from your HDD now.

Questions in the comments if you have any.


Simplified USB Wiping Via Linux Command-Line

Method taken from: [ http://www.pendrivelinux.com/restoring-your-usb-key-partition/ ]

They have a universal live USB-stick program that works in windows very easy and consistent (which means there's code bloat that you don't need, but it's OK to get to simpler OS's)

1. Note any drives you have plugged in.
2. Plug in stick and note drive letter (sdx) x being some letter.
3. Open terminal and type "fdisk -l", that's a lowercase "L".
4. Type "fdisk /dev/sdx" (replace x w/ drive letter, don't add the number if there is one)
5. Type "d" to delete partition.
6. Type "1" to select 1st partition (and go thru typing "d" and deleting all partitions)
7. Type "n" to make new partition.
8. Type "p" to make partition primary.
9. Type "1" to make it first partition.
10. Press "enter" to accept default first cylinder. If there's a virus in those 2000+ blocks, you can't solve that yet if you're doing this. Start somewhere, practice, research, learn, and kill the malware eventually; but not yet. Press "enter" again to accept default last cylinder.
11. Type "w" to write new partition to USB-stick.
12. Type "umount /dev/sdx1" (again replace 'x' w/ drive letter).
13. Type "mkfs.vfat -F 32 /dev/sdx1" (again replace the 'x'). Had a little hiccup on my end when messing around, doing "mkfs.vfat -t /dev/sdx1" got me back to reading the USB stick again for unknown reasons.

You can load the drive w/ whatever massive file[s] and then delete again if it makes you feel better. If you're up to it, try to learn the actual (likely C) code and corresponding Assembly code (you can keep going deeper if you want) and find compilers/assemblers you trust or make one yourself if you're truly badass.


/***** NOTE *****/

It may help to use the "Format" utility in the OS first too.  But this procedure works pretty good, just not 100% as there's still all sorts of weird things that can happen and this uses less code than downloading another program to do everything for you automatically (and not doing a full wipe perhaps).

Making a Simple "Robot" From 3V DC Motor and Switch

This tutorial came about as I made a promise to a friend to make her a "robot".  My initial plan was to gut a computer mouse and make one of those robots you see here:

http://www.instructables.com/id/PC-Mouse-Robot/

That didn't pan out well because of size constraints and I didn't want to spend a lot of time on this project.  So I went and got a little AA battery pack as the motor that I'm using is a 3V one from a broken shaver (the motor still worked for some reason).

I also had this I believe is capacitive touch module that was given to me, and it lights up.  Hope the battery in it lasts for a little while longer as it's sealed in there pretty good.

I decided to just do a simple switch on and off, which will spin the mouse's face.  Pretty silly, eh?  Well, hopefully it'll make someone smile...

Materials needed are quite a bit for what is mostly an "arts & crafts" project:
--Glue gun
--Plastic box
--3V DC motor
--AA battery pack for 2 AA's
--Soldering iron / solder
--Felt materials, anything decorative
--Wire cutters
--Dremel tool
--Foam with sticky side
--A switch
--2 twist-on wire connectors
--Scissors

1) Plan your layout, and dremel holes into the plastic box.  Make note of dimensions and how things will fit was all packed in.  I didn't get really specific here, just a lot of "eyeball" measurements.

2) Connecting the motor, switch, and 3V from the batteries is fairly straight forward.  There's 3 leads off the switch, the power source goes on the 2 exterior leads.  If you only have one power source, you can leave the other outside lead blank.  And ground (technically the "relay") is the center lead.  Hopefully your motor marks (+) and (-), otherwise just find that out before you begin placing it in the box.  All 3 wires can be twisted together with a twist-on wire connector.

3) Add any decorations you want, mine's pretty silly and pretty bad.  I'm no artist. :p

4) Drill out a hole for the motor and I just glued the mouse's face to the end, so it should spin in circles really fast.  Drill out a hole for the switch, and I applied copious amounts of glue to hold it in place.

5) I left the battery case unglued in the event batteries need replacing.  It's held mostly in place by the motor and some more foam pads.

/***** WARNING *****/

This design has issues that have yet to be resolved.  Testing showed that the circuit was OK, but final product showed it clearly wasn't.  Batteries get discharged extremely fast and get really hot (can burn you).  This means that there is resistance somewhere in the circuit allowing this leakage, or a fundamental flaw in my circuit (I tried to keep it as simple as possible).  I heard that it could be a bad switch, which is frustrating.

So, be sure to test your circuit extensively.  And a good-looking and functioning "robot" won't turn out on the first run usually.








Reflashing a Linksys E2500 Router with DD-WRT Firmware

Have an extra router laying around (I plan on doing a cooler radio tutorial with the classic Linksys WRT54G router later) and I felt like reflashing the firmware; meh, why not?

This isn't necessarily something that needs a tutorial as the DD-WRT wiki pages and their walkthroughs are pretty thorough (yet still a little bit scattered on some parts, but pretty good), but having now done it, I think I could condense some of the reading (it's not very much) and make it even easier and faster to reflash firmware with confidence.

/***** WARNING *****/

This is a potentially very dangerous operation (danger is my middle name :P ) because if you don't strictly follow the procedures you could either write the wrong file size or begin writing to the NVRAM in the wrong place, thus "bricking" your router. Which usually means you now have a new plastic box and a scrap-board to get some spare parts off of...  While it's not 100% gone if you do this (there's some recovery procedures given, you would have to make or buy a JTAG connector), you really don't want to be messing around with all the frustrating errors and potentially permanent damage to flash chips, unless you enjoy learning and hacking it (I kind of do), then by all means brick your router and try to fix it!  Speaking of which, that would be a good tutorial to do...

So for the list of materials, you need:
--Linksys E2500 router
--12V power supply for the router
--A standard Ethernet cable
--Stopwatch
--A computer with an Ethernet port and web browser
--Software (firmware .bin files from online)
--Saved HTML webpages for offline use
--Thin button pusher for the router reset button (could be many things, so get creative)

1) First, check to see if your router has been ported with DD-WRT.  Initially I was going to flash Open-WRT but they didn't support the E2500, I was glad to see DD-WRT did though.  Odds are, you can flash some open firmware on your router.

2) Start off firstly by reading up on how to do this.  Once you do it, it's really not that bad; actually quite easy.  The firmware writing and porting is the real hard work.  Keep reading until you feel comfortable.  All it took for me was these pages:

http://dd-wrt.com/wiki/index.php/Linksys_E2500
http://www.dd-wrt.com/wiki/index.php/Installation
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=51486

Download and save all these pages and of course the binary firmware files to a thumb-drive or your hard-drive for off-line viewing, you can keep a separate device to still look things up online too.

3) Now the most annoying part of flashing router firmware, in my opinion, is the "30/30/30" reset.  I've never heard of it nor seen it in my limited embedded development experience.  You have the router plugged in, and while plugged in, you need to hold the reset button (not the one on front, but on bottom of the device) for 30 seconds, then still holding the reset button, unplug the router for 30 seconds, then still holding the reset button, plug the router back in for 30 more seconds; totally 90 seconds of holding the reset button.

Make sure you have a little thin solid object to hold down the reset button and that you situate the router and your hands such that you can easily unplug and plug in the router while holding the button down.  This is the hardest part of flashing, in my opinion, so not that hard.

4) Next connect your ethernet cable to the computer and your router.  Since you shouldn't be connected to the internet, disable as many plug-ins and add-ons, virus protection, and clear caches; just to avoid some funny errors.  Log into the web interface (type 192.168.1.1 into your browser).  Now, they recommend to strictly use Internet Explorer (the default Microsoft browser) but I was able to flash the router just fine with the open-source Iceweasel browser, which is very much like Firefox.  If you already have IE and you're on Windows, then go ahead and use that first.  It's funny because at where I'm interning now, Internet Explorer by default worked the best with a product, instead of say Google Chrome.

Anyway, the default User name for the E2500 (with Cisco firmware) is "root" and the default password is "admin".  Now click on "Administration" tab, then "Firmware Upgrade".  You should already have the firmware file.

/***** WARNING *****/

Make sure the firmware file is the "mini" one, read the file name used in the picture.  DO NOT FLASH ANY OTHER FILE BESIDES THIS ONE FIRST.  Another part here where you could really brick the router.  This file is needed before you can flash some other custom DD-WRT firmware.

5) So browse and find the file where you downloaded it, and click "Start Upgrade".  Now, here's why I said you need a stopwatch.  Wait for 5 minutes after you flash, to "insure integrity" as they say.  Then after that, unplug the router for 10 seconds to power cycle and wait for 3 minutes after plugging back in.  Then do yet another 30/30/30 reset.  Then wait for 3 minutes to plug in the ethernet cable and log into the web interface.

And that's it! Congrats you flashed the firmware!  Now you can download and flash other custom DD-WRT firmware.  Just make sure it's no bigger than 8MB and is specifically for the E2500!  Follow the same procedure above to reflash.  I honestly didn't see that many more new features in the "big" firmware than in the "mini", so I may try another one.

Depending on your knowledge of the internet and networking, you can customize a lot of settings in the router.  Like port settings, MAC-addresses allowed on, IP-logs, VPN settings, and on and on...I would leave most of the settings as default if you don't know them, and add the highest encryption (WPA2/AES) with a large key (63 chars), like you would make a secure password that's hard to crack.  You could also disable WDS as there's a tool to hack into routers using this PIN number...

Also, if this is another router not connected to your modem, you can go to Setup -> Advanced Routing -> Operating Mode, and select "Router" to establish a link.  There's another page for doing that as well:

http://www.dd-wrt.com/wiki/index.php/Wlan_Repeater

This covers it pretty well but I wasn't able to get it to work exactly how I wanted.  You have to disable a lot of security to do it, and I don't feel comfortable doing that.  I also don't have my own internet connection.  I'll eventually get it working how I want, and will update this post when I do.