Wednesday, October 3, 2012

BASH: Plot graph with one line command using gnuplot

This is for a quick visual inspection of your job data output as XY plot. The XY data containing is read from the file data_input.dat

    1.00    0.00000
    2.00    0.74103
    3.00    0.79751
      ..     ....
      ..     ....

$ gnuplot
> plot "data_input.dat"

Now a scatter plot will pop up as a window. If you are logged into remote session with ssh, make sure you have forwarded the X. i.e.  logged in with -X flag

$ ssh -X yourhost

Change it to line plot by adding 'with lines'

$ gnuplot
> plot "data_input.dat" with lines

__________________________________________________________

Now for more advanced options:
1) To save the plot as png image:
add set terminal png, set output "plot.png"

-----------------------------------------------------------------------------
set terminal png
set output "plot.png"
plot "data_input.dat" with lines
-----------------------------------------------------------------------------
Now the plot will be saved as 'plot.png' into working directory.
You can open the image from terminal using  eog (eye of gnome)
$ eog plot.png

2) To label the X and Y and plot grid:
add set ylabel "RMS", set xlabel "Time" and set grid
-----------------------------------------------------------------------------
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" with lines
-----------------------------------------------------------------------------

3)  If you want to plot 1st and 5th column in your data_input.dat:
add 'using 1:5' in plot command
 

-----------------------------------------------------------------------------
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:5 with lines
-----------------------------------------------------------------------------

4) To plot two data series in the same plot and label each line:
add next series after a comma


-----------------------------------------------------------------------------
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1',  "data_input.dat" using 1:5 with lines title 'data-5'
-----------------------------------------------------------------------------

 To plot many series, it's convenient to use the line continuation character, "\" .
-----------------------------------------------------------------------------
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1', \
       "data_input.dat" using 1:3 with lines title 'data-3'  \
       "data_input.dat" using 1:5 with lines title 'data-5'  \
-----------------------------------------------------------------------------

5) Running it from a script

Put all these commands into a script and run if you have to run them several times

-----------------------------------------------------------------------------
#!/usr/bin/gnuplot
reset
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1', \
       "data_input.dat" using 1:3 with lines title 'data-3'  \
       "data_input.dat" using 1:5 with lines title 'data-5'  \
-----------------------------------------------------------------------------

matplotlib is another even better option for advanced graph creation

More examples:
Gnuplot 4.2 Tutorial
http://www.duke.edu/~hpgavin/gnuplot.html

Plot your graphs with command line gnuplot » Linux by Examples
http://linux.byexamples.com/archives/487/plot-your-graphs-with-command-line-gnuplot/

Data visualization tools for Linux
http://www.ibm.com/developerworks/linux/library/l-datavistools/

Thursday, August 23, 2012

Log BASH command error and write the output to a file along with the STDOUT

BASH shell error (STDERR) is displayed on the screen by default.  For the following find command, all the output, including error is displayed on screen

find /var/lib/. -name “*.py”

bash$ find /var/lib/. -name "*.py*"
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied


If the following command is used, it will only write out the ‘find’ result to the log file, not any error.

find /var/lib/. -name “*.py” > find_py.log

How can you log the error along with the output to a file so that you can read it later or from a remote session?


Follow the commands and output below


find /var/lib/. -name “*.py” > find_py.log 


[Only STDOUT written to a log file; (STDERR output to screen only) ]

bash$ find /var/lib/. -name "*.py*" > find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

bash$ cat find_py.log
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc



find /var/lib/. -name “*.py” 2> find_py.log


[Only STDERR written to a log file; (No STDERR output to screen; Only STDOUT output on screen)]

bash$ find /var/lib/. -name "*.py*" 2> find_py.log
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc

bash$ cat find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

find /var/lib/. -name “*.py” 2> find_py.log 1>&2 


STDOUT and STDERR written to a log file; (Nothing output to screen)

bash$ find /var/lib/. -name "*.py*" 2> find_py.log 1>&2

bash$ cat find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied



find /var/lib/. -name “*.py” 2>&1 | tee find_py_tee.log


STDOUT and STDERR written to a log file; (Also displayed on screen live while writing the log)

bash$ find /var/lib/. -name "*.py*" 2>&1 | tee find_py_tee.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

bash$ cat find_py_tee.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied



The 2>&1 redirect STDERR to STDOUT.
This will record any errors to the logfile along with STDOUT.

Saturday, May 12, 2012

Dell Streak 5: USSD code problem fix for Gingerbread 2.3.3

hunderteins of XDA form has done an excellent job to fix the USSD code problem in Dell Streak 5 Gingerbread Android 2.3.3. TheManii put it easy for us to update the fix comfortably using StreakMod.  It's working perfect for me and you can try it if you want. If you want to fix, here's the detailed instruction on how you can fix it.


This tutorial assume you have Gingerbread installed in your DS. If you have already flashed streakmod, skip the first part. If you have rooted following my previous post, you may already have flashed StreakMod.


Requirements and downloads




  • Unzip to a folder; say C:\Fastboot+ADB



Process overview:
A) Enter fastboot mode and flash the streakmod custom recovery
B) Reboot to the streakmod recovery and select option 2 and then ‘update from update.zip’ to select update-USSDfix-2.zip





A) Flash the streakmod custom recovery
  • Connect  your DS to PC (You already installed drivers to it) and copy update-USSDfix-2.zip to the DS SD card.
  • Stop USB connection and power down DS (DS is still physically connected to the PC through the cable)
  • Press and hold down the camera button and then press the power button. Release the button when you see a white screen
  • Select Fast boot mode on the top right on your mobile (DS display will show FASTBOOT_MODE)
  • Now it’s time to do some DOS commands from your PC to communicate with DS through the connected USB cable.
  • On your PC, navigate to the path where you unzipped the fastboot tools.(C:\Fastboot+ADB). You have already copied the streakmod recovery (C:\Fastboot+ADB\Win32\recovery.img) to this folder. (see requirements)
  • Press Shift key and from right click menu open a DOS command window on that folder
  • Type  'fastboot -i 0x413c flash recovery recovery.img' without the quotes and hit enter. You can see that your DS screen shows the response.(By the way, you can copy paste the commands to the DOS prompt. Right click on DOS command and paste.)
  • Type 'fastboot -i 0x413c reboot' without the quotes and hit enter.  
B) Reboot to the streakmod recovery, select option 2 (update) and select ‘update from update.zip’ to select update-USSDfix-2.zip file.

  • On reboot, immediately go in recovery mode (hold both volume buttons while powering on). Don’t let it go to full system boot yet.
  • Select option 2: Update from update.pkg on sdcard. Now this would go to be the custom streakmod recovery. (See version number at lower bottom in yellow font. If not, you are not on StreakMod and you can't proceed) 
  • Select
  • update-USSDfix-2.zip
  • and proceed instructions to patch
  • Now the patching process will start and finish. On rebooting, your DS will regain the USSD power! Try your USSD code and see if it works. 
  • [Optional] Post your experience here if you feel like. :)
Thanks again to XDA geeks hunderteins, TheManii, DJ_Steve and the rest 
Reference

Tuesday, February 14, 2012

XPS15z: USB 3.0 incompatibility and problem with external hard disks


Dell XPS 15z laptop's USB 3.0 ports does not work with at least one USB 3.0 external hard disks out there; Toshiba Canvio 1 TB USB 3.0 portable external HDD.

Check the Dell forum for the details of the problem.
XPS 15z laptop USB 3.0 problem

The hard disk works fine with the USB 2.0/eSATA combo port at USB 2.0 speed. (~30MB/s). The hard disk is not recognized at the USB 3.0 port. When I plugged it, the hard disk blinked with blue light continuously and nothing happened. The same HDD gives around 90 MB/s data transfer speed in my Desktop's USB 3.0 port indicating that the hard disk works fine.

So far, the mother board has been replaced and that didn't fix the problem. A newer laptop also had the same problem. It appears to me that the USB 3.0 port does not provide sufficient power to such external hard disks. To test this, I purchased a cheap USB split Y power adapter cable and plugged the external hard disk to both of the USB 3.0 ports at the same time; the additional plug is expected to provide the extra power to the hard disk. My suspicion was right; now the hard disk is recognized by Windows. Since the split cable I bought supported only USB 2.0, I get only about 30 MB/s speed. 

Now one option for me is to get a USB 3.0 power adapter split Y cable if I need the super speed with this hard disk, which is about three times of the USB 2.0 speed in real life. Three times speed is useful if you have huge data to transfer; say you'll be done in 20 minutes instead of 1 hr.

Is it a design flaw from Intel in manufacturing such a motherboard? Is it Dell's fault in not disclosing this potential incompatibility to the customers when advertising USB 3.0 as a specification of the laptop? Or is it a problem from Toshiba in making a power hungry external hard drive? Who sets the standards for USB 3.0 power specification and requirements? (if there is such a standard).

I've no idea.
__________________
Update on April 18th 2012

Previously, I reported that the drive works with USB 2.0 Y split cable. It could transfer files in USB 2.0 high-speed (~30 MB/s) from that connection. But to get the USB 3.0 super-speed (~90 MB/s), I purchased a USB 3.0 split Y cable from Amazon.com. As I expected, the drive did work this time with USB 3.0 transfer rate. The problem is solved. But two of my USB ports are gonna be occupied if I want USB 3.0 speed. Well, at least it works. So finally, the problem seems that either the Dell XPS 15z doesn't provide sufficient power to the USB Hard disk or this specific USB hard disk is under powered from a single USB port. 

Hey, Dell, Intel, Toshiba....who is ready to take the responsibility?

 

Thursday, February 2, 2012

XPS 15z: Why you should not buy a premium Dell laptop

UPDATE: Please scroll down to the bottom for updates on my issue. Probably, I should change the title since Dell offered a satisfactory solution to me.

I recently purchased a USB 3.0 external HDD (Toshiba Canvio 1 TB USB 3.0 portable external HDD) and found that my Dell XPS 15z laptop does not recognize the HDD on the USB 3.0 port.  I called the technical support and they sent a technician. He came to my apartment to fix this issues along with a couple of other issues which included manufacturing defects of the laptop hinge part and the bottom casing. Well, yesterday I saw how poorly this laptop components are manufactured/assembled and how poorly the Dell technicians are trained. Unfortunately, the attempted repair did much more damage than any issues I previously had. See the pictures of my laptop after an attempted repair by a Dell approved technician.








Well, I thought Dell will take the responsibility to resolve the unfortunate situation and step up to support it's customer for the inconvenience caused; especially since I've purchased premium support from Dell and since I'm a Dell Preferred Account holder. But Dell telephone technical support in India has totally let me down today. It's quite disappointing especially since I considered myself loyal to the company products. If you read my older posts, you'll realize how much I liked my Dell XPS 15z. I've also posted helpful hints for fellow XPS 15z users since Dell Inc was incompetent to provide user friendly manuals for it's customers. In fact, some of my pages are on top ten hits for Dell XPS 15z related Google search for a reason; simply there is no other online resources available to the XPS 15z customers. 


My observations:
  • The XPS 15z casing components are very flimsy. It'll deform easily if not delicately handled. (Don't attempt to replace the battery or RAM memory or internal hard disk yourself unless you are skillful; it is such a mess to open the case)
  • When the technician opened the casing, I saw that many of the internal components were made by Foxconn, which makes parts for Apple MacBooks, iPhones etc. (Probably, that's why Dell chose to contract them for XPS 15z parts?)
  • The contract based technicians are probably not trained to open and handle XPS 15z
  •  The Dell telephone tech support teams were not friendly. They appears to me as adamant and unhelpful adhering to rules rather than trying to provide a good solution to the frustrated customer.
  •  I would really like to have a support team and shop in my city, so that I can drive there and get a solution from the experts rather than untrained contract technicians. But I believe I don't have a choice with Windows PC manufactures. I have to compromise on that.
 I'm awaiting for the solution by Dell and let me see how Dell will handle the situation. One thing is sure, I will not recommend a Dell product to anyone looking to purchase a premium laptop. I'm willing to pay more money for a better customer experience and product support. Dell is simply not the company that can provide you that. 


UPDATE:
I wrote a clear e-mail stating my problems, my service tag, customer number, my contact number etc to Dell CEO Micheal Dell attaching the above pictures. Within 24 hrs, I got a call from Dell corporate office. They have acknowledged the issue and offered me a full refund or a brand new one at the earliest they can configure and ship. I opted for a new one. I think I'm satisfied now since they took effort to reach me and offer a satisfactory solution. I would still buy another Dell product if I find the product is worth my hard earned money. I'll update the story as it unravels.

I also want to know whether these USB 3.0 external hard drive configs match for the stated devices. I'm not sure at this moment whether it's a specification mismatch problem with my laptop or it's the external HDD. I would suggest you not to buy  Toshiba Canvio 1 TB USB 3.0 portable external HDD if you are a XPS 15z user. I'll update the issue as I have some.

Sunday, January 29, 2012

Dell Datasafe: setup recovery partition with customized ‘factory’ image after a clean Windows 7 install

Here’s a summary of my experience in setting up a customized non-factory image of already installed Windows 7 into the recovery partition of a Dell laptop. This image can be accessed with Dell Datasafe local backup software on boot time F8 key (Windows Recovery environment).
You can probably use many of the steps in the post modified to do the following:
  • Your internal HDD died and you want to restore your factory state from recovery DVD to a new HDD
  • You want to replace the internal Dell laptop hard disc with a new HDD or SSD and want to move your OS and recovery partitions to the new HDD/SSD
  • You want to create a recovery partition and image for your custom built PC
The premise:
I have an old Dell Inspiron laptop that I bought 5 years back with Windows Vista Homepremium installed as factory OS. I was so frustrated with vista that I purchased Windows 7 Prof upgrade on the day it was released in 2009. Although it was upgrade, I couldn't install it as upgrade since it was Prof version and Microsoft allowed a way to clean install it. I have formatted the HDD and did the full clean install of the Windows 7 Prof. Now, I don’t have a recovery partition or factory state image or anything. So on a system disaster, I can’t restore to a factory state. 

This is an attempt to put back the Dell Datasafe recovery software tools from one of my other laptops; the donor laptop  (XPS15z), and replace the donor factory image with the Inspiron Win7 prof customized system image. It is like a transplant of Dell Datasafe software and partition content from a working PC to the new PC, except for the actual factory image.
Now I can use F8 key to go to recovery, use Dell Datasafe recovery and restore to a system image state that I have customized. This system image is now on the recovery partition. Recovery partition is now the active partition containing bootmgr and BCD. Hence it is convenient to format the C- drive at any time without losing the recovery environment, ‘bootmgr missing’ or ‘no bootable device’ errors.

The Windows installed may be
  • A clean install from a Windows 7 disc or
  • An image of your official Dell factory installation + your software already installed on top of the factory Windows 7. This is especially useful when you do a factory reset. Now the obvious advantage is that you don’t need to install all your software and Windows updates again after the restore saving considerable amount of time. Also you can remove all the bloatwares in the official Dell factory image and keep in lean and clean. This means, you get the customized, efficient and productive version of Windows 7 for your need by a simple 30min factory restore from F8 key.

Basic tools needed:
  • Intact Dell Datasafe recovery partition of a donor Dell laptop.(Should match 32/64bit OS). If you lost the recovery partition, the recovery DVD contents would be sufficient
  • Hirens BootCD (HBCD)
  • An external NTFS formatted USB hard disk with space to store big size files (~20GB single file)
  • A Windows 7 installation/recovery disk

Step1) Copy recovery partition from donor laptop (XPS15z) to a folder in external USB HDD
  1. Plug your USB hard disk to the donor laptop
  2. Power on your laptop and boot with HBCD (Make your CD drive as the first boot device by changing the setting in your BIOS)
  3. Load mini Windows XP (Your partition letters may be changed. Recognize correct partition by looking at the contents of the partition)
  4. Copy all the content of the recovery partition to a folder in your external USB HDD
  5. Once done, power down donor laptop and eject the CD and external HDD. You don’t need the donor laptop anymore.
Step2) Image the C drive OS of the recipient laptop
  1. Plug your USB hard disk to the recipient laptop
  2. Power on your recipient laptop and boot with HBCD (Make your CD drive as the first boot device by changing the setting in your BIOS)
  3. Now OS partition imaging: From HBCD menu, open GUI for ImageX (GImageX)
    1. In the capture tab select source (your OS installed partiton)
    2. Select destination to your external HDD and give a file name.
    3. You may leave other in default settings. Optionally, you have choice to select the compression level etc.
    4. Let it run. It’ll take some time to complete. 1 or 2 hrs depending on your CPU speed, compression level and size of your Windows installation. This will create a .wim file which contains all the required installation of your OS.
  4. In this step, you have created backup of your OS partition on your external HDD and now you have everything in your laptop saved. (Assuming, you had only C partition) You are safe to format the entire laptop HDD. Continue to the next stage...
Step3) Recipient HDD repartitioning: Format and repartition your HDD according to your need
  1. Run Partition Wizard Home Edition (Available on Hiren’s BootCD menu).
  2. Format your hard disk/partitions and re-partition as below. Make them as primary partitions. Or else you cant make the partition as active.
    1. Recovery partition: 20-25 GB depending on how much software you expect to install. Assign a letter ‘R’ for convenience. (20GB is the minimum I would suggest; You may use higher compression if you are crammed for space)
    2. OS partition: 60 GB seems to be sufficient for Win7. Make it bigger if you want to install a ton of heavy software and want to keep more system restore points of C: drive for Windows System recovery and restore.
    3. Make rest of the space to D: partition or whatever way you want. This can be logical, I guess.
    4. Make recovery partition as the active partition
    5. Apply the changes and make sure it’s all done successfully
Step4) Copy the recovery partition contents and replace the factory image
  1. Now copy the donor recovery partition contents from your external HDD to the newly created recovery partition in your recipient laptop.
  2. Go to R:\preload and replace the base.wim file with the .wim image you captured in the first step
  3. There is a file named 'CSP.DAT' in the same directory. Open it with notepad++ and change the ‘Disk_Size’ value to the total size of your recipient HDD in bytes. If you don’t change this, Dell Datasafe will give error saying that you don’t have sufficient space on your hard disk. “Your hard drive size is not supported for this process. Please use a hard drive at least 689 GB in size”. This size is the size of your donor HDD. I used Partition Wizard Home Edition, looked up the HDD size in GB and put that in an online GB to Bytes conversion tool to calculate the size in bytes.
  4. Now check whether these files are present on the proper locations in your recovery partition.
R:\Recovery\WinRE\Winre.wim
R:\Recovery\WinRE\boot.sdi
R:\Boot\BCD
R:\bootmgr
  1. Now put your OS image back to the C: drive using imageX GUI. From HBCD menu, open GUI for ImageX (GImageX)
    1. In the ‘Apply’ tab select source (either the .wim file in your recovery partition or in the external HDD)
    2. Select destination to C drive (Select proper partition, not based on drive letter) and run it
    3. This will re-image the Windows OS into C drive. Let it run. It’ll take some time to complete. 1 or 2 hrs depending on your CPU speed, compression level and size of your Windows installation.
    4. Now the recovery partition is ready and OS is ready, but the boot configuration data may not be proper. Fix it in the next step
Step5) Recreate the BCD for the new laptop: The BCD from your donor could be pointing to different volume. We need to fix it
  1. Boot the OS with any windows recovery disk.
  2. Select repair to fix the BCD. It’ll scan an try ti fix it. If it didn’t work the first time, try again
  3. Remove the recovery DVD and reboot
  4. If everything worked fine, you’ll boot to the old Windows installation at the exact point you left
  5. Now we need to fix the Dell Datasafe Recovery environment on F8. Go to next step.
Step6) F8 key setup and fix the Dell Datasafe backup recovery environment
  1. On your Windows 7, install a free software Visual BCD editor. (http://www.boyans.net/)
  2. Run the software and edit as below.
‘Windows Recovery environment’ element paths to
R:\Recovery\WinRE\Winre.wim
R:\Recovery\WinRE\boot.sdi
Ramdisk Devise options path to
R:\Recovery\WinRE\boot.sdi

(BCD editing is not simple for a novice. I had to spent a couple of days learning about BCD and how to edit them. I’ll probably put a nice tutorial for that some day)

Now when rebooting, if you press F8, you should see a ‘Repair Windows’ option. If you chose that ‘Windows is loading files..’ progress bar will be shown followed with ‘Starting Windows’ animation. Then you select the keyboard, login with the username/password and at the end you should see the Windows advanced repair options. At the bottom, you can see the Dell Datasafe Backup. Click that and you’ll enter into the software options. You can see a factory image there. It’ll be actually the image you created in the beginning, your custom Windows 7 OS image! You can test whether the recovery works by going ahead and doing a factory format again, but now using the Dell Datasafe software insted of ImageX.

You may hide the recovery partition using Disk Management Utility (Just remove the drive letter) or Partition Wizard software.

This was a fun DIY project I did it over a couple of weeks when I had some free time. It was a very good learning and also quite fun to tweak the software settings to get what I wanted. Hopefully this will help someone. Let me know your feedback.

Some Tips:
  • You can open the factory image or any .wim fies with 7-zip free software. So you can extract any specific driver or files from the image.
  • Recovery partition contain 'bootmgr' and BCD file. It's safe to be that way. The active partition should be the recovery partition for this to work. In the boot sequence when you power-on laptop, the BIOS looks for a bootable device, finds HDD, looks at MBR, looks for active partition and 'bootmgr' contained in it. Now bootmgr gets BCD entries, BCD points to C drive and finally the OS loads with winload.exe.
  • Apparently, this method should work for any Windows PC... it need not be a Dell PC.


    Disclaimer: 
    This is an outline of my experience with a single laptop. YMMV. There may be many other ways to do it. And may be some of these steps are done in an easier way. Do your home work and know what you are doing. As always, use Google wisely to gather more information before you do anything drastic. Have all your data baked up and have plenty of time to do the exercise. I don’t guarantee that this would work in all situations. Take this post as an outline for your needs. You may get some hints from the work-flow I followed.