Category Archives: Windows

Developer lost in Windows

Admittedly, I am not a Microsoft fan, but Windows is a quite fine operating system nowadays. This article is not about complaining with Windows.

This article is also not about native Windows development for Windows. That is, if you use Windows, Visual Studio and C# (or other languages native to Windows development) to produce software targeting Windows, this article is not for you.

I and other programmers use Linux, OS X or possibly BSD to develop software meant to be OS independent. Our core tools are perhaps bash and a terminal emulator. We use tools like grep, head, tail, curl, iconv, sed, bc, emacs, vim, ssh, nc, git or svn on a daily basis (without them we are in a foreign land not understanding the customs). Depending on programming language we use compilers and interpreters like gcc, python, perl, php, nodejs and sbcl. In Linux, OS X or BSD this all come very naturally but sometimes we find ourself using a Windows computer:

  1. We just happen to have a second Windows computer that we want to use
  2. Company policy requires us to use Windows
  3. We want to be capable of working in Windows
  4. We want our project to work fine in Windows
  5. Perhaps you are a Windows developer/user who need/want to do unix-like development without getting a separate computer.

This article is for you!

The good news is that basically everything you wish to do can be done with free software (also on Windows). What is also good is that you have plenty of choices of good stable software to choose from.

The bad news is that finding just what is right for you and making it feel as simple and smooth as you are used to can be time consuming, difficult and frustrating.

Embracing Windows
To be productive in Windows you should (at least to some degree) embrace Windows. One approach is to do as the Windows developers. This would mean using cmd.exe (the old DOS-shell) or Powershell, and learn/embrace what comes with it. You would perhaps install only node/php/python native for Windows and git. I encourage you to try this, but I will not write more about it.

This might be the best solution if you develop in JavaScript or Java AND basically all tools you use are part of a JavaScript/Java ecosystem. Perhaps git is the only thing you need apart from what you install with npm.

Avoiding Windows
One approach is to just use Windows to access (and possibly run a virtual) Linux (system). It can work better or worse depending on your situation. A full screen VM might be the best solution if Linux GUI tools are central to your development, or if you are anyway very used to working with VMs. SSH to a remote system might be the best solution if mobility is not a problem. However, some development gets more complicated when different things are on different IP addresses, and security becomes more relevant when everything is not on 127.0.0.1. I will not write more about this.

Make Windows Unix-like
So, our gool is to feel reasonably at home in Windows by installing what is missing. It is always tricky to divide things in clear categories, but I would say you will want a stack of four layers:

  1. A Terminal Emulator: Windows already comes with one, but chances are you will not find it good enough. I have very modest demands but I expect copy-paste to work nicely and I expect multiple tabs. This works perfectly in any default Linux desktop and Mac OS X, not so in Windows.
  2. Editor: Unless you prefer to use vim or emacs directly in the terminal you want to install a decent or familiar text editor (Nodepad or Wordpad are not suitable for serious programming).
  3. The standard UNIX/GNU tools: Windows does not come with bash, head, tail, grep, sed, vim, bc and most other tools you take for granted. The old (DOS) equivalents are simply inferior. The new (Powershell) equivalents are… well… lets just say it is a steep learning curve and your bash scripts will not run.
  4. Interpreter/Compiler: Windows does not come with gcc, python, perl, nodejs or php. However, they are most often available as a separate download for Windows. Such a native Windows version may be slightly different from the Unix-version you are used too (command line options, especially related to paths may be different).

The short version is that you can install things like Cygwin or Windows Subsystem for Linux and you might just be fine with it! Or not. If you are bored of reading, try it out now.

To make a more informed choice you need to consider what types of binaries you want to run (and perhaps produce).

Native Windows Binaries
A Native Windows binary can (with some luck) be copied from a Windows computer to another and run. To interact with Windows (and you) it uses the APIs of Windows (typically Win32). It probably expects paths to be formed like in Windows (c:\tmp rather than /tmp).

Native Linux Binaries
A Native Linux binary was typically built on a Linux system to run on that Linux system (like Debian). Until recently it would not run on Windows, however Microsoft put a massive effort into Windows Subsystem for Linux, which allows you to run Linux programs (including bash) directly in Windows 10 (only). This is not perfect though. A Linux filesystem is quite different from a Windows filesystem so access between the two filesystems is limited and may require some thinking. This is perhaps the best approach if you are targetting Linux (like development for Docker) but it is obviously a bad approach if you want your program to work on a Windows server or other Windows computers.

Hybrid / Cygwin
There is an old (as in proven and reliable) project called Cygwin. It is basically a DLL-file that translates all (most) Linux system calls into Native Windows calls. This means that the unmodified source code of (most) programs written for Unix can be compiled with Cygwin, for Cygwin, and run on a Windows computer that has the Cygwin DLL installed. There are some drawbacks. First, performance suffers (from nothing to quite much depending on what you do). Second, for more advanced software, especially with GUI or heavy on network (like Apache), the hybrid solution can feel like the worst of two worlds. Third, access to the entire filesystem is smooth, but when it comes to access rights it sometimes does not work perfectly (files created by Cygwin get weird, even broken, permissions).

Now, to complicate things, there is a project called MSYS2 that maintains a fork of Cygwin, very similar to Cygwin. Cygwin or MSYS2 can be included/embedded in other projects (such as cmder). If you install multiple unix-compability-suites on your system it can get confusing.

Choosing binary type
At first glance Windows Subsystem for Linux, or Cygwin, seem very attractive. But lets assume that we do web development in Python. If you go with Windows Subsystem for Linux you will need to run a webserver (apache, lighttpd) inside that subsystem. To me, configuring, starting and stopping services inside this subsystem is not attractive. What could possibly go wrong? Well, a lot of things. With Cygwin you can probably make Windows IIS invoke Cygwin Python (if you really dont care about performance), because running Cygwin Apache sounds creepy (it can be done though). If, on the other hand you install Python built for Windows you get the real thing. All Windows/Python documentation and forum information suddenly applies to you. But then you end up with a Cygwin shell where everything is just like in Linux, except Python is not (except Cygwin will come with Python too, so you can end up with two versions of Python, with different features).

I would hesitate to run apache inside Cygwin and even more so inside Windows Subsystem for Linux. But I always also hesitate to do anything with IIS. Perhaps the best thing is to install Apache and Python for Windows (not depending on Cygwin) and just find the tools you need to edit your files?

The same reasoning can apply to PHP, nodejs or whatever you do.

Most configurations can probably be made to work. But you just want your Windows computer as simple and standard as possible, and you want your usual Linux (or OS X or BSD) stuff just to work the way they usually do. This is really not a matter of right or wrong, it is more a matter of taste (what kind of worthless errors do you want to solve just because you are a foreigner in Windows doing stuff not the way it was really meant to be done in Windows?).

Maintainability and Management
One thing is to make it work. Another thing is that it works week after week, month after month. Also another thing is to keep your software up to date and being able to add new tools along the way. You will find that some of the software I mention in this post does not come with the Windows installer/uninstaller that you are used to.

There is something called Chocolatey for Windows, which is a package manager dealing with installing, upgrading and uninstalling software on Windows in a uniform way. I don’t know much about it, and I will not write more about it.

While unix programs typically have a .file with configuration (there are a few places to look though) Windows programs typically use the registry. When it comes to unix software adapted for Windows you never really know: registry, config file, both or… depends on? And if a config file, where is it?

While unix programs can usually be installed in the home directory of an unpriviliged user, or in /opt, programs in Windows often require administrative priviliges to spread their files a little bit everywhere.

The more stuff you try and throw out, the more garbage you have left on your computer, which could possibly interfere with a newer version of something you install in the future. Keep this in mind. One day you will install some exotic software that does not work as expected, and you dont know if some old garbage on your computer caused it.

Git
Git is a very popular version control system. Originally designed for Linux it is today (?) the officially preferred system also for native Windows development. Git is so popular (or demanding?) that you can get it bundled for Windows together with some of your favourite tools. This might be just enough for you!

  • posh-git : git for powershell
  • git for Windows : based on Git for Windows SDK
  • cmder : based on MSYS2
  • …more?

cmder
I have tried cmder and I dont like it. It is an ugly install of just unpacking a huge zip file. MSYS2 itself is hidden inside the cmder-folder, so I dont feel comfortable managing it on my own. There seems to be no upgrade strategy (except throwing it all away and downloading the latest version). Git is run from one shell (a traditional Windows shell with a lambda prompt) but a msys2/bash (identical to Cygwin) shell is started separately. I dont want to change console to run git: I run git all the time. But it might be perfect for you (many people like cmder).

Cygwin
Cygwin is nice becuase it comes with an installer (setup.exe) that is also a package manager. It has a lot of packages, and it is capable of installing things like apache as windows services. My experience is that I am too lazy downloading the latest setup.exe, and I am too lazy running setup.exe regularly. Sometimes you end up with old versions and upgrade problems.

My disappointment with Cygwin is that it comes with its own (compared to standard Windows) terminal Mintty that still does not have tabs. I also do nodejs development and nodejs is not a Cygwin package, so I need to use standard Windows node. This sucks a little because node in Windows behaves slightly different from node in Linux/OS X (particularly when it comes to where packages go) so the Cygwin experience is a bit broken when you start using Windows node and (perhaps particularly) npm.

Also, I like bash scripts and they tend to run significantly slower in Cygwin than in Linux (process forking is extremely cheap in Linux and rather expensive in Windows, so with the Cygwin overhead it can get rather slow for heavy scripts).

As I now try to update and configure my Cygwin environment for my Node.js project I find:

  • I use Cygwin wget to download setup.exe (so I get it where I want it, rather than Downloads) to update Cygwin. When I double click it (to run it) permissions are wrong and I cant execute it. It is an easy fix, but compared to OS X / Linux this is awkward.
  • I run node from Cygwin. I get no prompt (>). It turns out node.exe does not recognize Cygwin/bash as a terminal and I need to run node.exe -i.
  • Symlinks keep being a mystery. There are some kind of symlinks in Windows now, Cygwin seems to try to use them, but the result is not consistent.

For a Terminal with tabs, check Fatty below.

MinGW & MSYS
While the idea of Cygwin is to provide a Posix compliant environment on Windows the MinGW/MSYS project was about porting unix tools (perhaps particularly a gcc-based C/C++ build environment) to run natively on Windows. According to the Wikipedia page of MinGW this is pretty much abandoned.

Gow: GNU on Windows
Gnu on Windows is a lightweight alternative to Cygwin. It appears to not have been updated since early 2014 (when 0.8.0) came out (and the Windows Subsystem for Linux seems to be one reason it is less relevant). I will not write more about it.

MSYS2
MSYS2 is the successor to MSYS, and (surprise) it is based on Cygwin. I tried it quickly and I find that:

  • It seems safe to install side by side with Cygwin
  • Using the MSYS2 is very similar to Cygwin
  • Instead of the Cygwin GUI package installer, MSYS uses pacman from Arch (if you much prefer that, go with MSYS2)
  • MSYS2 has some emphasis on MinGW32 and MinGW64. As I understand it this is about being able to use MSYS2 to build native Windows software from C/C++ code (if you do this in Cygwin, you end up with a Cygwin dll dependency)

So, for my purposes MSYS2 seems to be quite equivalent to Cygwin. Expect the same annoyances as I mentioned for Cygwin above.

Windows Subsystem for Linux
If you try to run bash from a Windows 10 command line you will probably get something like:

-- Beta feature --
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
In order to use this feature you must have Developer Mode enabled.
Press any key to continue...

Note that this can be quite confusing if you have installed some other bash.exe on your system. If you unexpectedly get the above message, check your PATH and make sure you invoke the right bash executable.

Installation is very easy (activate Developer mode and run bash), after giving username+password you are actually good to go! If you are used to Debian/Ubuntu you will feel surpisingly at home.

I find my Windows files in /mnt/c (not too surprising).
I find my Linux home files in c:\Users\zo0ok\AppData\Local\lxss\home\zo0ok.
(copying files there from Windows did not make them appear in Linux though)

So, if you want to edit files using a Windows GUI editor, they need to be in Windows-land, and that is obviously not the optimal environment for you project.

In general it works very well though. My node services had no problems listening to localhost:8080 and accepting incoming http requests from a Windows web browser.

If you are not happy with Ubuntu or you want more control of your Linux environment you will need to do further research. Ideally, Windows Subsystem for Linux has most of the advantages of a virtual machine, but none of the drawbacks. However, depending on what you really do and need, it can turn out to have most of the drawbacks and few of the advantages instead.

Fatty
The Mintty terminal that comes with Cygwin is ok, but it does not support tabs. There are different alternatives, and a simple one is Fatty (it is really Mintty with tabs). Installing Fatty requires doing a git clone and compiling it yourself. If you are brave you can download fatty-1.6.exe from me.

The web page for fatty tells you how to make a desktop shortcut but it did not work for me. What works for me is to set Shortcut target: “C:\cygwin64\bin\fatty.exe -“. Simple as that. I think I will be quite fine with fatty, actually.

Making Fatty run Windows Subsystem for Linux was trickier (as in no success) though.

ConEmu
ConEmu seems to be the ultra powerful flexible console. After 5 minutes I have still not found out how to change the font size.

ConsoleZ
ConsoleZ is good. Under Edit->Settings>Tabs you can add your own shell types.

Cygwin:                       Shell = C:\cygwin64\bin\bash.exe --login
Windows Subsystem for Linux:  Shell = bash.exe

Apart from that, ConzoleZ is reasonably easy to configure and it stays out of your way (I hide toolbar, status bar, search bar).

Editors
I am fine with vim in the console. However, there are many fine editors for Windows:

  • Visual Studio Code (at no cost)
  • Atom
  • Notepad++

Conclusions
I have had Windows as a 2nd/3rd platform for many years and I can see that the game has changed a bit. Microsoft has started supporting Ubuntu on Windows and at the same time the native options (like MSYS) are fading away. There are reasons to think general development is getting more and more based on Unix.

I would say:

  • Posh-git : Powershell is your thing, and you don’t care about unix tools
  • Git for Windows : You want Git, but you don’t care much about other unix tools
  • Cygwin : You want plenty of choices of unix tools in Windows
  • MSYS2 : You like pacman (Arch) or you want to build native Windows C/C++ binaries using free software
  • Windows Subsystem for Linux : You have a Windows 10 computer but you want to keep your Linux development separate from Windows

If you use Cygwin and just want tabs, get Fatty. Otherwise ConsoleZ is good. Chocolatey is more a Windows power user tool than something you need to provide unix capabilities.

In the past I have mostly been using Cygwin (with mixed feelings). Lately, when I have heard about the options (cmder, poshgit, Git for Windows, MSYS2) I have got a feeling that it is rather hard to configure an optimal environment. Now however I have come to realize that the differences are not very big. Most options are hybrids based on Cygwin and/or with Cygwin embedded (perhaps in the name of MSYS2). For Windows developers not used to Unix it is good with things like Git for Windows that just come with the basic Unix tools with no need to think about it. For developers with a Unix background it makes more sense to run Cygwin and MSYS2 (or Windows Subsystem for Linux). The days of unix tools built natively for Windows are over, and it is probably a good thing.

What you need to think about is your compiler, interpreter and/or web server.

Upgrade windows hard drive

So, you have a Windows 10 (this probably applies to Windows 7 and forward) computer and you want to replace your system drive because you have a bad feeling about the health of the current drive, or you just want a larger SSD.

If you start searching on Google (or Bing) for this, you will get so many crappy answers: plenty of companies want to sell you tools, and Microsoft provides so much information that is hard to make any sense of. This is a simple and (quite) safe procedure that worked for me.

What you need

  1. A new hard drive, larger than the previous one
  2. A USB key, at least 8GB
  3. A USB hard drive, with enough space for backing up all your files

All drives should contain nothing of value as they will all be reformatted in the process.

Steps

  1. Create a Recovery Drive to the USB key (2)
  2. Create a System Image to the USB hard drive (3)
  3. Turn your computer off
  4. Replace your current system drive with the new one (1)
  5. For safety, unplug drives that you don’t want restored
  6. Start computer from your Recovery Drive (2)
  7. Choose Advanced
  8. Plug in System Image drive (3)
  9. Restore System Image
  10. Restore to your new hard drive (1)
  11. Profit!

This is a safe way to upgrade hard drive because:

  • You always have your original system intact and you can put your old hard drive back if anything goes wrong.
  • You completely only use standard Windows tools. From Windows/Microsoft perspective your original hard drive broke, you were smart enough to have proper backup, and you simply restored your backup.
  • It is anyway a good thing to always have (2) and (3) in case of disaster.

Problems, Annoyances, Caveats
The process is quite annoying.

  1. Just finding out where in Windows to create Recovery Image and System Image is a pain.
  2. Creating the Recovery Drive is very slow, despite you have a fast USB Key
  3. I did not click Advanced after starting the Recovery Drive. That ended up formatting a non-system-drive that was plugged in (I realised my mistake too late).

References
Howtogeek

Upgrading Windows 7 to Windows 10

After installing Windows 10 on a friends’ computer, I thought it was time to upgrade my own. My primary concern was my limited available space on my C-drive (I have two more drives with plenty of space). I tried to find good advice or information online, but no luck, so here is my report:

Upgrading Windows 7 to Windows 10: storage requirements

My Windows 7 computer had a C-drive with the following available capacity:
12.6 of 55.3 GB Free (after running disk cleanup).

That is, Windows and some programs were installed on C, most files on other drives. Anyway, Windows 7 was pretty eager to upgrade, and I started the procedure.

  1. It was “Checking requirements” (3 times, different dialogues)
  2. Downloading: available space down to 9.4GB
  3. Preparing for installation: down to 8,1GB

So far it had been the typical low-quality MS experience of different dialogs giving quite dull information and no real sense of progress, but now it got really bad:

win7to10_1

The f**k is this? I did not know anything about installing the Insider Preview (there has never been any pre-release W7 whatsoever on this computer). And “something needing my attention”, being thrown back from the Windows 10 upgrade wizard to the Windows 7 system upgrade, not very impressive. Anyway, I just clicked “check your PC”, the Windows 10 upgrade continued, and I got this:

win7to10_2

This is really crap! It had already checked requirements three different times, yet not figured out I had too little space. I could have told it, before it even started, that I probably had too little space. The good thing however was that I could pick another drive to use for extra space, and I happened to have an internal drive available.

After that, up to 10.5Gb availble space on my C-drive, and restart. Now my computer was working on its own for almost an hour. After that Windows 10 came up, and everything seemed fine.

With Windows 10, I now have 17.8GB free space on my C-drive. That was nice! Perhaps a reason in its own to upgrade to Windows 10.

Conclusion: upgrading to Windows 10 with limited available space on C is a good idea, but make sure to have an extra external (or internal) drive for the process itself.

(Tried) Installing Windows 7 for the last time

A friend of mine came to me with his broken gaming computer. He does not know much about computers, but had surely invested in good hardware (some store configured and built it).

Why did it break? Well, a 90GB SSD + 1TB HD, Windows 7, is a guaranteed disaster for someone not an expert. Paging is on the SSD and it can be hard to get out of there. Everything installs on C: and it can be hard even for en export to not put stuff there. Eventually, the C drive will be full, fragmented, thrashing, and the SSD drive will break down.

We put a brand new 250GB SSD drive in place of his old broken down, and started installing Windows 7. I decided to try a Windows 7 with SP1 DVD – that worked fine with his original product key. That was the end of the good news.

First thing to do is Windows update… millions up critical updates I expected… except the only thing it updated was Windows update itself. After that, it got “stuck”. I tried numerous things like:

  • Waiting…
  • Someone suggested a proxy reset, or other network related problems.
  • Windows Update Troubleshooter (found 4 problems, fixed 3 of them). This is possibly the most retarded Windows tool I have seen. How would “working in the first place” be?
  • Some command line command to search for corrupted system files (there were none on this 1h young system and brand new hard drive).

After about two hours I thought enough is enough. Microsoft offers a free upgrade from 7 to 10, but not for my friend who had a legitimate Windows 7 key, with no way of getting to the point where upgrade to 10 is possible.

I believe Windows 7 (even with SP1) is just “too old and outdated” to successfully communicate with the Microsoft upgrade servers, and without some special knowledge it is impossible to get through.

Why is this Microsoft?

  • Are MS incapable of keeping old (but still supported) versions working?
  • Are MS intentionally breaking fresh Windows 7 installations to enforce Windows 10 migration?

In any way, it

  • Wastes peoples time.
  • Drives people to hacks and cracks to install software they already paid for.
  • Drives people to pay for something (Windows 10) that they should be able to upgrade to for free.

Anyway, while I spent several hours trying to install Windows 7 on his desktop, without much assistance he installed Xubuntu on his (Virus-sick Windows 8) laptop. And he was very happy with it.

In the end we installed Windows 10 on the desktop, and I think it is the only version of Windows currently worth installing (unless you have a server). That was, admittedly, a quite positive experience and it worked quite fine.

Visual Studio alternative folder – a joke?

I was thinking about installing Visual Studio 2013 Express… if nothing else to compile my program from my last post.

Well, 5.3Gb was not so bad, but I do not really want Visual Studio on my C drive, since:

  • C is an expensive SSD drive, that I want to avoid filling up
  • I am not going to use Visual Studio a lot, and it is fine for me if it is a little slower – can live on my Q-drive (an old IDE drive)
  • I am just going to use the command line tools that come with Visual Studio anyway, so I really don’t need to waste my SSD C-drive with 5.3 GB of dev tools

Perhaps my arguments are just stupid, but they make sense to me.

This is the funny dialog I got when installing…

VSExp2012

I mean, seriously??? I can change installation directory, which will move 1GB to the other drive, and keep over 4GB on C. Why did you even bother with an alternative install path, Micro$oft? Why does Windows support more than one hard drive at all?

Obviously there are other people being annoyed with this too. And there are ideas about using symlinks in Windows to solve the problem… but the problem is that a lot of those 4GB may go just everywhere on the C-drive anyway.

The people who design Windows are obviously retarded and Windows is a mess. I am not going to make my Windows gaming computer dirty by installing stupid Visual Studio on it. I remain happy to use Windows as little as possible.

This was annoying with my Nokia N8 that put plenty of stuff on the little C-partition that could not be moved to the big D-partion. But Windows 7 not being better than Symbian – come on?

How it is done right
For those of you who only ever used Windows, I will quickly explain how this is done right. You give the user the option of installing anywhere, in particular

  • Standard system path – so everyone can use it (c:\Program files)
  • Non standard path – so everyone can use it, but it does not get in the way for those who dont care (q:\extra\devtools)
  • The users home directory!

The last option obviously requires no admin rights whatsoever. This is very good, because you know for sure nothing is installed elsewhere.

For development tools, this has several advantages:

  • If installing the dev tools does not modify the system in any way, you can be sure that the programs you build behave the same way for your end user as they do for you – and with behave, I typically mean “work”
  • You can install several dev tools/versions side by side, and be sure they do not disturb each other or rely on each other
  • You can be sure that your system works just as it used to, even after you installed dev tools

Finally, I want to remind that even though dev tools (compilers, linkers, libraries, IDEs) are very advanced stuff… in the end of the day they only produce regular files; sequences of bytes. No privileged access is needed to produce a binary file! There is no magic about it.

It is not only unnecessary that Visual Studio installs itself in C – it is a suspicious behavior. Only bad things and bad practices can come from it.

Finally, clever software providers get this right! And Valve have ambitious Linux plans… just because they are clever.

Connect to Office Communicator/Lync with Pidgin

This is a post I have wanted to write for a very long time 😀

My company has an Office Communciator 2010 setup, and for a long time I have tried to connect to it with my (X)Ubuntu computer. Pidgin has not worked, and installing Office Communicator 2010 in Wine has not worked either. But now… the stars were obviously aligned, I was lucky to try the right configuration, or some update to the Office Communicator Plugin for Pidgin fixed something. Error messages from Pidgin are usually not very detailed or helpful.

My configuration:

  1. You need the pidgin-sipe package (Xubuntu 13.04)
  2. Username: my email address
  3. Login: username\domain
  4. Advanced:
  5. Server: set this one
  6. Connection Type: TCP
  7. Authentication Scheme: NTML

Of course, your OCS Server might be configured in a different way. But perhaps this is a little helpful to someone. The way I obtained the server address was to run the netstat command on a windows computer before and after starting and stopping the Office Communicator 2010 client.

Hard drive full of Steam DLC

As I am getting more and more DLC for Train Simulator 2013 my C-drive was getting full. Steam was installed there, c:\Program Files (x86)\Steam.

Moving stuff to another hard drive is not so easy in Windows, since there are no real symbolic links. I thought about getting a new (bigger) hard drive and migrating to it using backup/restore of entire Windows… felt like too much work.

Then I found this article about moving Steam to another location! Obviously, the Steam poeple are smart people! I moved Steam using this method from my 60GB SSD drive to and old internal IDE-drive I had available. It worked perfectly! The whole process took less than an hour and caused little problems; the Steam desktop shortcuts stopped working, and Steam does not auto-start now. Load times for Train Simulator 2013 increased 2x-3x, not as bad as I thought actually. Not sure if I will invest in a new SSD just for Steam.

Sid Meiers Railroads crashes

Like many other people, I found that Sid Meiers Railroads crashes (at least on Windows 7 x64). I downloaded the official 1.10 patch which did not help much. However, this modified binary seems to work for me.

Download and use at own risk.

Death of my SSD

My new SSD drive lasted about 6 weeks. It is the first one I ever bought (not counting the built-in one in my Eee 701). And I thought I had taken extra good care of it, not even using it for the pagefile.

If you run Windows 7, I recommend making a System Image Backup (Control Panel -> System and Security -> Backup And Restore) to a spare drive. When I did that I got the following error message:

The Backup Failed. New bad clusters were found on the source volume. These clusters were not backed up.

Before I ran the backup, I had noticed nothing suspicious about the drive. Now I checked the Windows Event log (System Log), and found Errors from Source=Disk, with ID=7.

Trying to fix
I tried to run chkdsk over and over again. First via right-clicking on c:, clicking Properties, Tools, and checking/fixing errors. I also tried running chkdsk /b from the command line. This reduced the number of errors in the event log down to one (when the computer started), but I could not get rid of the last error. The Image Backup kept failing. Days later I had several errors again. This made me definitely give up on the drive.

The Windows Backup Image
The Windows Backup Image feature is simple and nice. But as usual with Microsoft it is after all a half-crappy tool that works if you are lucky. I don’t like:

  • When the backup above failed, the tool anyway created a backup image. How am I supposed to know if I can use that backup or not?
  • When running the backup again, the tool obviously just read files/data that had changed, effectively avoiding the bad blocks. So when running again I did not even get an error, making me even more uncertain about the usability of the backup.
  • The recovery CD can only recover to a hard drive that is not smaller than the original hard drive. This applies even if the original backed-up Windows partition is smaller than the new drive. (I was afraid replacing my 128GB SSD with another brand/model 128GB SSD, because the new drive could very possibly be a few blocks smaller than the original one).

I recovered the system to an old non-SSD drive with success, but performance was so depressing.

New Drive
In the end I replaced my broken 128 GB OCZ Octane S2 with a 60GB Intel Series 520 drive. They were almost exactly the same price. I re-installed Windows from scratch. Online Windows Activation was OK this second time I used the same key – I did not have to call Microsoft and explain anything.

Conclusion
The performance of SSD on the system/root drive is fantastic. Booting and starting programs is so fast. I just could not go back to a normal drive. But I hesitate to store my own files on SSD, and I will think twice before getting a budget SSD drive again.

Recover scenarios to the new smaller drive
I will be honest and admit I never tried to restore the old system to my 60GB drive. My experience with not being able to restore to a smaller hard drive comes from another computer.

Intel has an SSD Toolbox, and I think it contains migration tools. Perhaps those tools could have handled the smaller (albeit large enough) destination Intel SSD drive.

There are ways to resize partitions, backup and restore them and make them bootable. But I did not trust the quality of my backup 100% (after all Windows said it failed). And I hesitate to use dd to write images to SSD drives.

Fixing the bad blocks?
Bad blocks are supposed to be more common on SSD drives than traditional drives, but firmware should handle it. I found no useful tools from the drive manufacturer, OCZ. My nice dealer allowed me to replace the drive after I explained that Windows failed to backup it, and chkdsk didn’t fix it.

Indications in Linux
I booted the Ubuntu 12.04 CD, and ran the following commands:

$ sudo md5sum /dev/sda
md5sum: /dev/sda: Input/output error
$ sudo badblocks -b 4096 -c 1024 -e 10 /dev/sdg
1312474
1312575
(and another 8 lines with bad blocks)

The system log or dmesg command gave more details.

Problem with Pagefile on second drive in Windows 7

My Windows 7 computer has 4GB of RAM and a 128GB SSD drive. I dont want to page on my SSD drive (because I believe it will shorten the life of it, and I dont believe in paging anyway), so I disabled paging. However, occationally Windows claimed it ran out of memory and killed my applications. I am very suspicious it really ran out of memory (4GB should have been plenty for what I did), but nevertheless it killed my applications.

I decided to install a second drive, an old rotating hard drive, that I assigned the drive letter b: and named backup. That is where I want my pagefile.sys (and some backups).

When configuring Windows the way I wanted, I got the error:
Windows created a temporary paging file on your computer because of a problem that occured with your paging file configuration when you started your computer. The total paging file size for all drives may be somewhat larger than the size you specified
.
What this really meant was that I got a pagefile on c: anyway. And the error message popped up every time i started my computer.

Like many other people who have written about similar problems, I tried all combinations of disabling and enabling pagefile for the different drives, but very very hard to get it the way I wanted.

Finally it worked – and as usual with Windows it is impossible to know what really made the difference. And I dont want to break the configuration just to fix it again to learn!

Anyway, these are things I did that MIGHT have had anything to do with it (perhaps it had to do with the stars or something):

  1. I renamed b: to q: (in case Windows 7 does not believe in paging on its second floppy drive) (Most Likely This One!)
  2. I first obtained a working configuration with pagefile on both c: and q:, both of them using an interval, none of them System managed
  3. I reduced c: in steps, first to 16-256, next to 16-16
  4. I finally effectively disabled pagefile on c: by setting “initial size”, to 0 (not by using No Pagefile)

I recommend that you change your folder view setting so you can see systems/hidden/protected files along the way.

Sometimes people say Windows is good. Sometimes I say, “well, yes, Windows 7 is ok, they got it right now”. But the truth is that Windows f***ing sucks. This reconfigure/reboot/pray-way of solving problems is so braindead. And it is impossible to learn or understand.