Learnosity Logo
Learnosity Banner Image

Windows File Sharing (SMB/CIFS/Samba) over SSH

While working with a client recently setting up a Netgear VPN so he could securely access his internal file server. The VPN setup was straightforward but every time the VPN client connected to the VPN server the VPN server/firewall would crash - leaving no connectivity.

In order to come up with a reliable solution to this we decided to use the SSH server we had available and tunnel the windows sharing across the local port forwards, much simpler and more reliable.

Thanks to this article it was a breeze to set up.

Steps are as follows:

  • Create loopback adapter on windows
  • Configure loopback adapter on windows
  • Reboot
  • Configure SSH connection
  • Test it all out

Create loopback adapter on windows

We'll give your computer an additional (fake) IP address, and we'll port forward to that address instead of the computer's real IP. Windows XP will continue to do file sharing on the real IP address. We'll assign it an IP of 10.0.0.1 (that's what we configured putty to use above.)

  1. System->Control Panel->Add Hardware
  2. Yes, Hardware is already connected
  3. Add a new hardware device (at bottom of list)
  4. Install the hardware that I manually select
  5. Network adapters
  6. Microsoft , Microsoft Loopback Adapter
  7. (Go through the installation procedure.)

Configure loopback adapter on windows

  1. Open your new fake ethernet adapter (Network Connections) , enter a made-up IP address (I suggest 10.0.0.1, which is a privately routable address that most folk don't use.)
  2. Enable Client for Microsoft Networks.
  3. Disable File and Printer Sharing for Microsoft Networks
  4. Enable Interent Protocol (TCP/IP)
  5. Click on properties for TCP/IP.
  6. Enter your chosen IP address (10.0.0.1), subnet mask (255.255.255.0). You can leave gateway blank.
  7. Under advanced->WINS, Enable LMHosts Lookup and Disable NetBIOS over TCP/IP

Reboot

In order to make it all work now it he appropriate time to reboot so windows initialises everything correctly.

Configure SSH connection

  • Download Putty
  • Enter IP address
  • Enter Auth Key (if using SSH keys)
  • Enter Port forwards for: (these connect the ports on you local machine to
    • 10.0.0.1:137 to 127.0.0.1:137
    • 10.0.0.1:138 to 127.0.0.1:138
    • 10.0.0.1:139 to 127.0.0.1:139
    • 10.0.0.1:445 to 127.0.0.1:445
  • Save the config.

Test it all out

Now to connect you need to do the following steps:

  • Open putty, load the settings and connect.
  • Open Exporer and type in: \\10.0.0.1\

You should now be connected to your remote windows system over a secure encrypted tunnel.

Cheers, Mark

Clear MSSQL Query Caches

Found this useful little snippet for when you are load testing MSSQL Servers.

You can use it to clear the query cache - to ensure you are starting from a level playing field. Or if you are tuning queries in a application and want to ensure they are not cached run it before each run:

dbcc freeproccache
go
dbcc dropcleanbuffers
go

Cheers, Mark

DVD to iPod conversion - Linux, Mac & Windows

I've been looking for a while for a way to convert DVD's and other movies that I have into iPod format and have been failing miserably. That is until today, when I came across the unusually named HandBrake.

It does exactly what is says on the tin and makes it very easy to copy dvd's. Initially I used it from my Mac and it worked flawlessly.

I also tried the Linux version on Ubuntu Hardy (8.04) which has no GUI but it is pretty simple when you get the hang of it.

Here's a typical command line:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

This reads from /dev/cdrom and uses the handy "iPod Low-Rez" preset which fixes it all up nicely for the iPod.

And here's one that takes the second title:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

The wiki has more information on command line usage.

Happy iPodding.

Cheers, Mark

Gmail, Docs, Calendar and Analytics standalone with Prism

I came across Mozilla Prism the other day and while I'm still deciding if it's going to be a permanent addition to my machine so far so good.

Screenshot of Prism Gmail Prism is a cut down version of Mozilla which is designed to run single sites from icon - what's the use of that you may ask? Well it allows you to have an icon on your desktop for Gmail or Google Calendar or docs or analytics and get to it nice and quickly.

It also free's up some much needed screen real-estate as all the other toolbars relevant for a web-developers browser can get in the way and are not used when you are using you email and calendar.

Additionally - as web developer I tend to restart firefox more often than some - and having my email seperated from that is nice.

Give it a try and see if you like it. On Ubuntu Hardy you can do the following to install it:

#install calendar
sudo apt-get install prism-google-calendar
#install google docs
sudo apt-get install prism-google-docs
#install gmail
sudo apt-get install prism-google-mail
#install analytics
sudo apt-get install prism-google-analytics

On other platforms (windows,mac or other linux versions) you can go to the Prism site and download it.

For the different applications check out the Bundles section or the User contributed bundles section.

Obviously this shares a lot of similarities with the adobe AIR platform albeit not as full featured. It will be interesting to see what further development plans there are for the prism platform.

Cheers, Mark

Pretty network diagrams and flow charts with Open Source software.

I had been using Dia for all my charts and diagrams, and it does a very good job. The only downside is that it doesn't produce very pretty charts of the like of Omnigraffle.

However, inspired by this article, I'm starting to use a new solution, Inkscape, that fulfills my criteria that works on Linux, Mac and Windows.

Dia Omnigraffle Inkscape
Can create pretty pictures No Yes Yes
Cross Platform (Linux, Mac, Windows) Yes No - Mac only Yes
Open Source Yes No Yes
Open file format (to work with version control) No - Binary No - Binary Yes - SVG
Export to PNG Yes Yes Yes

Now you may argue that Inkscape is not a diagraming tool but a generic drawing tool. This is true, but with the addition of a few templates of pre-drawn items it become a very good diagramming tool.

I've created a few simple flow chart elements which I use and also scoured the net for some SVG icons for network based diagrams which were sourced from Gnome (via Ubuntu) and from Quantum Bits.

Templates Previews

Flow chart diagram preview

Computing devices preview

Download

Download the svg templates (right click - Save As):

Give it a try - it's very easy.

Cross platform Database IDE

Ever since I've moved to using Linux full time I've been looking for a solid Database IDE. I've tried and tested quite a few.

Aqua Data Studio
This is my current DB IDE of choice and has some significant features in the new version 6.5 that means I'll be staying with it for a while, particularly as it runs on Linux, Macs and Windows identically.
  • Schema Comparison - very handy for keeping development and production db's schemas in sync.
  • Charts & Pivot Tables - makes it easy to create adhoc graphs withouth having to resort to Excel/OpenOffice Calc
  • Morph to Delimited List - A simple but powerful function that saves a lot of time. Allows you to take the results of a sql query and convert to comma seperated list. I've done dozens of adhoc CF scripts to handle this before :-)
  • Subversion Support - As we use subversion for our code it's handy to have it built in.

MySQL GUI tools (Query Browser & Admin)
These have some very nice functionality but have always found them to be pretty unstable - they just crash a lot with no explanation.
Navicat
This is pretty good option, but the Linux version is the poor cousin to the Windows & Mac versions.

Love to hear any comments feedback or suggestions.

howto document your code with ASDoc

Last night I was trying to document our AS3 code, using ASDoc, for a project that we have been working on. For those of you who don't know, ASDoc is a command line utility which allows you to generate code documentation in HTML format. A good example of what ASDoc output looks like would be, Flex 2 Language Reference.

Documenting code wasn't as easy as I thought it would be, so I thought I'd share this with you and hopefully it will save someone some time. I use an Intel Mac and this is what you need to do to get your basic code documentation generated successfully:

1. In your terminal window go to your Flex SDK bin directory. Typically this is located under /Applications/Adobe Flex Builder 2/Flex SDK 2/bin

2. From "bin" directory run this command:

./asdoc -doc-sources=/Users/marko/Documents/workspace/yourFlexProject/ -source-path=/Users/marko/Documents/workspace/yourFlexProject/

If you have any external Libraries in your Flex project you will need to include them in your command:

-external-library-path=/path_to_your_swc/myLib.swc

The key thing to remember for Mac users is that you need to run the command from Flex SDK bin directory and use -source-path option to tell the compiler where the source is located. -doc-sources will tell the compiler to generate output for the current directory and all subdirectories recursively. If you run this utility from any other directory other than "bin", you will get NoClassDefFoundError.

I haven't tried running ASDoc in Windows yet, but it should be very similar to running it on a Mac. And since ASDoc is a command line java utility, you would think it would run on Linux too. Well, for all you Linux users out there, this is the message I got from the compiler:

Error: Could not create toplevel.xml: Unknown OS for ASDoc. ASDoc will only run on Windows and Mac OS X.
That last sentence is pretty self explanatory :)

ASDoc is nicely documented here.

Cheers
Marko

HOWTO Add 1680x1050 resolution to Windows VMware Server clients

I make extensive use of VMWare Server on my laptop for Flex and Flash development as Adobe haven't released Flash and Flex for Linux yet (hint hint).

When I'm flicking back and forth between Windows and Linux I typically leave the Windows window at 1024x768 which allows it to have no scrolling and still fit on my 1680x1050 screen.

However, there are times when you just need more screen real estate in windows and as the VMWare driver doesn't come with a native 1680x1050 resolution you need to make some minor registry edits to get it working.

A bit of searching got me to an knowledge base article but the instructions didn't work for me, as the registry keys didn't exist there but were located pretty close. So without further ado (there's been quite a bit already I admit).

  • Start->Run and type regedit
  • Select the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{device id}\0000. Note the deviceid is a big horrible uuid, and there may be multiple ones. Use the one that has a key "Device Description" of VMWare SVGA II
  • There are a load of Resolution.x lines, add a new "Binary Value" 1 higher than the highest resolution. Eg Resolution.11
  • Enter the binary value of: 31 36 38 30 78 31 30 35 30 which is ASCII for "1680x1050"
  • Close regedit and reboot.
  • After reboot you should have a new resolution available to you.

For other resolutions you can use the following numbers keys:

ASCIIValue
300
311
322
333
344
355
366
377
388
399
78x

Cheers, Mark

IE6 and IE7 running side by side

I knew it was possible to do, but not this easy.

I've added it here for my own reference IE6 & IE7 side by side.

Also useful link to evolt standalone browsers archive.

Essential for debugging IE6 CSS issues.

VMWare partial snapshot recovery HowTo

I recently came across a Vmware server machine that was had a drive that kept expanding until it filled the entire host machine's avaiable space.

The machine in question had a number of drives including a 100GB and a 200GB partition and the host machine had a 600GB partition to hold all this. After digging around a bit I discovered that the drives were performing snapshots. Which means that they main drive was frozen in time and all changes were written to another file.

This should have been an easy fix, tick a box in the admin to remove the snapshot. However, in the admin for the machine there were no snapshots registered and no way to remove them. A bit of hunting found a couple of articles on the subject:

However, I used the following approach to fix the problem which seems to be simpler than the techniques documented above.

Note: make sure you have a backup before proceeding - my 600GB backup took 6 hours but was worth it.

  • Step 1: Make a backup to another drive (internal or USB)
  • Step 2: Check that you can boot your VM from the backup.
  • Step 3: Identify and document all disk names and files
    • Document all drives, paths and scsi/ide nodes
    • Create a text file in the root of each drive - you can then check for this to ensure you have the correct snapshot.
  • Step 4: Use the following command to convert a snapshotting disk to a new clean disk:
vmware-vdiskmanager -r sourceDisk.vmdk -t 3 destinationDisk.vmdk
  • Step 5: In VMWare remove the disk for this machine and then add back your new disk. Make sure you use the same SCSI/IDE node numbers.

Note 1: It is important to select the correct snapshot as the source disk. For example: sourceDisk.vmdk could have a number of snapshots, sourceDisk-000001.vmdk sourceDisk-000002.vmdk. Have a look at the timestamps to determine the active one.

Note 2: If you get the following error:

Failed to open the disk 'sourceDisk-000001.vmdk' : The parent of this virtual disk could not be opened (23).
Don't panic - as long as you have the backups you will be fine. Have a look in the sourceDisk-000001.vmdk and make sure the "parentFileNameHint" path is correct. I.e. if it is an absolute path and you are trying to restore it from a different location (i.e. your backup) you can correct it or simply make it a relative path.

Note 3: It is also very helpful to edit the network settings for the VM to ensure that the network is Not Connected on boot. Particularly if there are mail services or similar running on the machine. This allows you to boot the machine safe in the knowledge that it is completely isolated from outside influence.

Resources

Another useful document which helped out what the file reference on the vmware site - What Files Make Up a Virtual Machine?

Hope it helps. Cheers, Mark

More Entries