Clone Disk to a Smaller Disk using Clonezilla

On and off I need to clone a larger disk to a smaller disk. There are some software to do that but usually it is paid. As I don’t like to spend time to evaluate the quality of those software, I still kept using Clonezilla as my tool to do disk clone.

So back to the topic, how to clone a larger disk to a smaller disk? There are 2 choices. I am not going to the details step, but a high level steps only.

Choice 1: Clone all partitions in the source disk

If the destination disk is big enough to hold all data in the source disk, but smaller than the source disk, probably you want to choose this. The screenshot below is taken using clonezilla-live-20170905-zesty-i386.

  1. Shrink and move the partitions of the source disk, so that the size of sum of all partitions is less than the size of the destination disk. You can do that using Disk Management in Windows, or GParted in Ubuntu live CD. If you need to move partitions, then you will need to use GParted to do that.
  2. Optionally create a disk image from the source disk.
  3. Boot to Clonezilla, choose restoredisk if the source is an image, or choose disk-to-local-disk is the source is a disk.
  4. Follow the instruction on screen. When come to mode selection, choose Expert mode.
  5. Make sure the -icds is selected in the advanced extra parameters screen.
    Clonezilla Skip Destination Disk Size Check
  6. Make sure to use the partition table from the source disk or source image. Although this post suggest to Create partition table proportionally, but during my testing with 3 partitions in a source disk, it generate errors.
    Use Partition Table from Source Image
  7. Follow the rest of the instruction on screen to complete the clone.

Choice 2: Clone selected partitions in the source disk

You may want to use this method when you don’t want all partitions to be cloned to the destination disk. For example, you may want to clone the recovery partition only, and have a blank OS partition for factory restore, or you may want to clone only OS partition but drop the recovery partition because the recovery partition is too big.

  1. Shrink all source partitions which want to clone to the destination disk, so that each destination partition is equal or larger than the source partition. Use Disk Management in Windows, or GParted in Ubuntu live CD to do that.
  2. In the destination disk, create all partitions which you want to clone from the source disk. Each destination partition must be equal or larger than the source partition. Use Disk Management in Windows, or GParted in Ubuntu live CD to do that.
  3. Create any additional partitions which you will need. For example, you want to clone the recovery partition only, but you want to perform a factory restore next, then you may want to create an blank OS partition.
  4. Set the destination partition type same as the source partition type. For well known partition type such as NTFS or FAT32, you can do that by perform file system format. For other partition type such as Dell Utility, you will need to use fdisk command in Linux to set it.
  5. Port all partition flags from each source partition to destination partition. For example, setting the boot flag to OS partition and setting diag flag to recovery partition.
  6. Using Clonezilla, clone the source partition to the destination partition one by one.

sleepbot-to-sleep_as_android is Released!

I was a user of Sleepbot since 2013. However it was abandoned by the developer later on and no more new release for a few years. I tried to check their blog but no reason found behind this.

Anyway I was still using Sleepbot until my Nexus 5X was dead, due to the infamous bootloop (but what the news said, LG did repaired my phone) and I lost a month of data even I have do regular backup. Coincidentally I saw Sleep as Android on the editor choice of Google Play a few days ago before the phone dead, so I decided to switch to something else.

After comparing with Sleep as Android and Sleep Better with Runtastic, I decided to got for Sleep as Android because what I need is just sleep tracking, I don’t need alarm and it seems Sleep Better with Runtastic has no way use sleep tracking without an alarm.

So now I am using Sleep as Android, and then I did a quick search to see if there is any methods to import the data from Sleepbot. In the documentation, it did mention someone made a Ruby script for import data, which convert the exported file from However I didn’t use cloud save so it just doesn’t work for me. So based on that script, I wrote my own version which convert the exported file from the app itself instead to a file that can be imported in Sleep as Android. So that is the why the script is here. The reason why I used Python is just because I have very little knowledge with Ruby.

Enough for the background information. Anyway you can find the script and more technical details at the project page.


PS: I just found that there is no annual report from WordPress in year 2016!

Visual Studio Code Zip / Portable Version for Windows

Recently I was given an exercise to work on Node.js. A few years ago I was using Aptana Studio on Node.js. So after these few years I guess there should have some IDE or editor available for Node.js. So I ended up found Visual Studio Code and Atom.

I tried both Visual Studio Code and Atom, and I choose Visual Studio Code at this moment because the autocomplete suggest is much more better than Atom.

For software that I use, I usually prefer portable version. I found someone has made one, but I don’t like unofficial release. I looked again and lucky found a post here which mentioned that there is a portable version of Visual Studio Code.

After further checking, it is actually a zip version and officially the download link is located deep inside the FAQ section of Visual Studio Code.

Anyway for those who like no installer version, below is the link to download it directly.

Edit 2016-08-13: Finally they have provided the Zip archive download link in their download page.

Error 1918 when Installing MySQL ODBC Connector 5.3.6 on Windows

It is somewhat a frustration that even the official website at the time of writing this doesn’t correctly list out the dependency software.

Anyway in short, make sure you have installed Visual C++ Redistributable Packages for Visual Studio 2013 if you are installing MySQL ODBC Connector 5.3.6.

The official website and many other website I found only mentioned to install Microsoft Visual C++ 2010 Redistributable Package. Some websites even gave an inappropriate installation instruction to user. Although Microsoft Visual C++ 2010 Redistributable Package might be required for older version of ODBC connector, but definitely not version 5.3.6.

Also, it is better if you are installing the latest version of Visual C++ as well. Many website I found (such as this, this, this and this) are still providing link to the old version of Visual C++ even a new version is already available at the time of their writing. You may check the latest version of Visual C++ at Microsoft website here but, even the official website cannot be trusted as I can find a more updated version of Visual C++ 2015 here at the time of writing this article…

In summary, trust yourself.

Building Ncat Portable for Windows


I used to use telnet for testing if the firewall working properly in the office. Telnet is good for simple test, but when comes to testing a large number of destination IP and ports it will be very time consuming. After searching on the Internet I found Netcat, a tool for testing connection. It is build-in in most Linux OS but not on Windows. So I found Ncat here as part of the Nmap for Windows by, but too bad that it won’t execute on some Windows as it requires Microsoft Visual C++ Redistributable Package installed.

A Ncat portable is an alternative, but the website only provided a beta version of Ncat 5.59BETA1, and require you to compile your own if you would like a newer version.

They did provide a documentation on how to compile Ncat with static linking library, but if you follow the steps you will encounter a few problems which you have to troubleshoot yourselves.

So here is my steps on compiling Ncat portable after I had gone through all the trouble.If you are someone who can edit the documentation on, please do that for me as I don’t want to get an extra account for just editing the document :)

If you want to avoid the trouble to compile, you can download the Ncat which I compiled here, however use it at your own risk as I might have inject some malware inside :)

Building Ncat Portable for Windows


The following steps has been tested using the following environment:


  1. First, follow all steps on the original documentation at till you copied the resulted static libs and include files from “C:\OpenSSL” to the “mswin32\OpenSSL” directory in the Nmap source tree in step 5. Below is a screenshot of the original documentation in case it is edited at the time you read this article.
    Building Ncat Portable
  2. Assuming that everything went fine till now, you’re about 7 steps away from building Ncat portable.
    1. Open Nmap solution in Visual Studio from mswin32\nmap.sln and switch the build configuration to “Ncat Static” like so:
      1. Right click on Solution “nmap” in the Solution Explorer sidebar and choose “Configuration Manager“.
      2. Switch the active solution configuration to “Ncat Static“. Check the “Build” check box for project “liblua“. Make sure that the nsock, nbase and ncat projects have switched to the “Static” configuration also. Then close the “Configuration Manager”.
      3. Right click on the ncat project and select “Set as StartUp Project“.
    2. Right click on the “nsock” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “General“, in “Additional Include Directories“, add path “..\mswin32\OpenSSL\include
    3. Right click on the “ncat” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “General“, in “Additional Include Directories“, add path “..\mswin32\OpenSSL\include” and “..\liblua
    4. Right click on the “ncat” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “Linker” > “General“, in “Additional Library Directories“, add path “..\mswin32\OpenSSL\lib
    5. Expand the “ncat” project, double click the file “ncat_ssl.c” and comment out the line “#include <openssl/applink.c>
    6. Right click on the “liblua” project in Visual Studio and click “Properties“. In “Configuration Properties” > “General” > “C/C++” > “Code Generation“, set “Runtime Library” to “Multi-threaded DLL (/MD)
    7. Right click on the “ncat” project in Visual Studio and click “Build“. Alternatively you can press the F7 key to start building.

Open Video File using omxplayer on Raspberry Pi without Terminal

I was trying to make Raspberry Pi running Raspbian OS to turn it as a media player with can play video without using a keyboard so that it is portable for a trip.

The only software that allow video playback on Raspbian is omxplayer. It is a command line tool and therefore need a keyboard to start playing video. Searched on the Internet and found that it is possible create an application, allowing you to play the video via right clicking the video file and choosing the application to open. However most of scripts included in the Internet are not working on my Raspbian. After a long research I finally figured out a working one.

Later on, I actually found that there other OS such as Raspbmc, OpenELEC which is actually designed turn Raspberry Pi to be a media center and I have another Raspberry Pi for that now. Anyway below are the steps to create applications for video playback on the LXDE desktop environment on Raspbian OS:

  1. Create a file with the following content at /usr/share/applications/omxplayer-hdmi.desktop. This will allow you to hear the sound output to HDMI.
    [Desktop Entry]
    Name=OMXPlayer (HDMI)
    Exec=lxterminal --command "sudo omxplayer -r -o hdmi %f"
  2. Create a file with the following content at /usr/share/applications/omxplayer-local.desktop. This will allow you to hear the sound output to the 3.5mm audio jack.
    [Desktop Entry]
    Name=OMXPlayer (3.5mm)
    Exec=lxterminal --command "sudo omxplayer -r -o local %f"

Enabling “Clean Solution” Option in Visual Basic 2010 Express

  1. Under the Tools menu, go to the submenu Settings and switch to Expert Settings. The Build menu should be available by now, but Clean Solution menu item is still missing.
    Switch to "Expert Settings"

    Expert Settings

    Build Menu

    Build Menu

  2. Under the Debug menu, click Options and Settings.

    "Options and Settings" Menu Item

    "Options and Settings" Menu Item

  3. Under Project and Solutions item, inside the General item, check the check box for Always show solution. Press OKto exit.

    "Always show solution" Option

    "Always show solution" Option

  4. In the Build menu again, the Clean Solutionmenu item should be there finally.

    "Clean Solution" Menu Item

    "Clean Solution" Menu Item