Thursday, April 02, 2009

D-Link DIR628, 192.168.0.1, Knoppix, "out of range" etc.

ALERT: severe jargon ahead
You have been warned

I was heading for southern California -- taking a personal retreat and then picking up the ex-teenager. The lovely Carol prevailed upon me to leave the day before and see our friend Sylvia to help her with some computer issues. I chatted with her a few times, and we decided that, among other things, I'd set her up with a wireless router (and firewall), and transfer data from the rather small (5Gbyte) hard disk drive on her WinXP box to her new Mac.

The Monday before I left, we had breakfast with our buddy Neil, who volunteered to pray for the router setup. My initial thought was, "it'll be a piece of cake," but then I remembered something about pride going before a fall -- and also that things are often more difficult than we thought they'd be.

And so it was. I got to Sylvia's, and before doing anything with the router, connected my laptop directly to her DSL modem. DHCP said my IP address was 64.x.x.x, but my one and only nameserver would be unroutable, 192.168.0.1 (a typical rfc1918 address) -- a little weird, given the "normal" IP address the DHCP gave me, but no big deal, right?

Except that the router, a D-Link DIR628 -- the same model I have at my house iirc -- comes up thinking that it should be 192.168.0.1 and that it should have authority over the entire 192.168.0.* space. My first attempt, which was rather shortsighted, accounted for that first fact but not the second: I assigned the D-Link to be 192.168.0.254, reminiscent of some default I remembered from long ago -- maybe the LRP?

As I mentioned, this didn't account for the D-Link's opinion that it owned the entire 192.168.0.* space, and so it would not route any packets from the "inside" (i.e., the computers on the "safe" side of the firewall) to any 192.168.0.* address on the "outside" -- thus any attempts to talk to the nameserver on the DSL modem would fail. (And have I mentioned that it's weird for a DSL modem to run a [caching?] nameserver with an unroutable IP address? I think it's weird.)

It took some head-banging to figure this out. I finally decided to have the D-Link manage some other space, but didn't remember all the other rfc1918 unroutable ranges. I knew about the 10.*.*.* space, and I suspected there was a 172.16.*.* space (with 20 free bits), but couldn't remember the address exactly. Probably I could have used 192.168.0.128 and set the netmask to ffffff80 (or left the netmask alone and used 192.168.1.*, but I didn't think of that 'til later). Therefore, I chose 10.11.12.* (because it seemed less trite and more, uh, zany and madcap than 10.0.0.*). And with that, we could talk to the outside world!

Now, to get the data off the old whitebox. It booted into WinXP (funny about that) and very soon a "virus warning" popped up. My personal opinion is that the so-called warning was itself a virus, but since I don't do windows.... Sylvia assured me that this "virus warning" would log you out from windows shortly after you tried to do anything, so I pulled out my brand new Knoppix 5.1.1 CD. After a few futile attempts to boot it, I figured out how to get the BIOS to boot from CD. Up came the Knoppix boot screen, and oops, there it went. I got an "out of range" message on the monitor. Oh joy. Setting "vsync" and/or "hsync" didn't do any good; neither did saying "knoppix 2" (where "2" is the runlevel -- text mode only).

But since we had networking up to the outside world, I used my own laptop to search the web for knoppix + "out of range" and finally hit on using "knoppix vga=0 2"

That did it. The first surprise, after "fdisk -l /dev/hda", was that her HDD had 5GB all right... and about 55GB more on the same platter! This was a 60GB HDD, all in one 'vfat' partition. Yow. I mounted it readonly.

Now Sylvia had an (external) USB HDD -- with over 600GB of space on it. OK, cool. I found a power outlet, plugged it in, and connected the USB cable to the hub. Knoppix recognized it right away, scanned it, and created a symlink for me from /mnt/sdb1→/media/sdb1. Yippee! I blithely (et naïvement) tried "mount /media/sdb1"

The bad news is that the USB drive had previously been unmounted uncleanly; Knoppix refused to mount it. The good news is that Knoppix told me what to do: "ntfsfix" or something like this. (What I really should have done was "mkfs.msdos" but I'm not sure that works on a 600+GB HDD -- also, I wasn't sure if Sylvia might someday want to use all the "features" of NTFS. Sheesh, I wonder if Mac OSX can read/write ext2 filesystems.)

But the ntfsfix worked well enough. I figured out that the data of interest resided under Documents and Settings and proceeded to cp -a /mnt/hda1/Documents\ and\ Settings /media/sdb1/from-windows in the background.

For some reason, Knoppix didn't understand that Alt-F2 was my way of saying "chvt 2" so after a while, I just typed in "chvt 2" and did a little "df -k; sleep 20; df -k" to see how fast we were getting data across.

Well, the "df -k" on the NTFS USB drive took a couple of seconds; I decided we were getting about 28Mbytes moved in about 22 seconds. Not stellar; this meant it would take about 14 hours, as of my (literal) midnight calculations.

But in the morning I had another idea. How fast does the 'N' wireless move data? 100 Mbits/second would be not quite 10X as fast.

I told Knoppix to "/etc/init.d ssh start" and it dutifully started sshd. And Knoppix could ssh to my laptop.

But my laptop couldn't ssh into Knoppix. I asked Knoppix, "netstat -tln and it gave me this:
tcp     0.0.0.0:68       *.*.*.*
tcp     :::22            *.*.*.*

Wha...? That 68 thing was listening on tcp4 but sshd was only doing tcp6?

A quick "ps wwwx|grep ssh" told me that /usr/sbin/sshd was running with no parameters, so I said "/etc/init.d/ssh stop" and (thank you manpage) "/usr/sbin/sshd -4" to turn on sshd/tcp4. Yippee!
Meanwhile, I noticed that the fancy NTFS formatting on the external USB HDD prevented several filenames from being created. Most of these filenames had accented characters like "ñ" -- yet another reason I should have just reformatted the drive. Oh, and top(1) on Knoppix told me that some NTFS-related program was consuming some 20% of the CPU. That probably wasn't making the data copy any faster!
Back on my laptop, I said "ssh root@10.11.12.197" and... no joy. Harrumpf, I thought. "ssh -v root@10.11.12.197" gave me something about how it didn't like the numeric IP address (but maybe that was just a warning). Anyway I created an entry in /etc/hosts for a machine called "doze"; now "ssh -v root@doze" got me to a "Password:" prompt. It took maybe a minute -- no doubt paging some stuff in from that CD drive.

After copying my id_dsa.pub into root's authorized_keys file on Knoppix, I tried rsync -av -e ssh root@doze:/media/hda1/DOCUME~1/ALLUSE~1/MYDOCU~1/MYPICT~1 tmp and things started moving.
What's with the DOCUME~1 stuff? I seemed to remember rsync having issues when a remote pathname contains whitespace, and since the vfat filesystem contains these alternate names, I decided to take advantage of them.
Cool, I thought, and then did the "df -k; sleep 20; df -k" thing. It seemed 2½-3 times as fast as the wired USB drive.

Well, that's cool, I thought. Sylvia brought her mac over to me, and I did the ssh-keygen thing and sent one of her public keys to Knoppix. then I created a directory on her Desktop called "From Windows" or something like this, cd'd into it, and kicked off an "rsync -a root@10.11.12.197:/mnt/hda1/DOCUME~1 ." Once the file list got created, we were transferring data a lot faster (I also did ^C on the aforementioned cp -a and "eject /media/sdb1").

I left Sylvia's about 9:30am, and I think something like 28 Gbytes had already been transferred (out of maybe 48 total wanting to be). I'm sure we didn't start before 6:30am so I felt pretty confident it would all be done by lunch time.

The best thing is, Sylvia can just click on the "From Windows" folder on the Desktop on her Mac, and click, click, click to whatever pictures or music she wants to import into iPhoto or iTunes Library....

Guess I'd better tell her about Carbon Copy Cloner, which people on our mac mailing-list say is great; hopefully it won't object to running on that huge external USB HDD.... but some backup is probably in order.

I should probably suggest that she buy some DVD+RW media; she could probably burn a few optical backups of her photos. (If I said 'no pun intended,' would you believe me? Thought not.)

No comments: