Friday, December 24, 2010

Backup a Windows system

1. Create a Fedora LiveCD on USB flash driver
2. Reboot the machine to Fedora
3. Backup partition information

# sfdisk -d /dev/sda | ssh serverip 'cat > /folder/sda.ptb'

4. Backup MBR or MBR+Bootloader

# dd if=/dev/sda bs=512 count=1 | ssh serverip 'cat > /folder/sda.mbr'
# dd if=/dev/sda bs=512 count=63 | ssh serverip 'cat > /folder/sda.vbr'

5. Backup the restore image (count is set to the value from sfdisk output for /dev/sda1)

# dd if=/dev/sda bs=512 skip=63 count=20980827 | ssh serverip 'cat > /folder/sda1.img'

6. Check NTFS system size and if it needs run 'chkdsk /f /r'

# ntfsresize --info /dev/sda2

7. Backup Windows NTFS system

# ntfsclone -s -o - /dev/sda2 | ssh serverip 'cat > /folder/sda2.ntfs.img'

8. Run sha256sum to verify if the hashes match

# dd if=/dev/sda bs=512 skip=63 count=20980827 | sha256sum | ssh 'cat > /tmp/sda.sum'

Monday, December 20, 2010

Install ibm_db gem on Cygwin 1.7 on Windows 7

Just got a brand new Windows 7 laptop. Had troubles in installation of ibm_db gem.

Here is the configuration

* Windows 7 64bit
* Cygwin 1.7.7-1
* DB2 Express-C 64bit v9.72 (db2exc_972_WIN_x86_64.exe)
* Cygwin Ruby 1.8.6
* Bash

Here are the steps how to install ibm_db:

* copy c:\Program Files\IBM\SQLLIB\lib\Win32\db2cli.lib to db2.lib
* export IBM_DB_LIB=/cygdrive/c/Program\ Files/IBM/SQLLIB/lib/Win32
* export IBM_DB_INCLUDE=/cygdrive/c/Program\ Files/IBM/SQLLIB/include
* gem install ibm_db

NOTEs:
* Because the ruby of Cygwin is still 32bit, you have to link to 32bit library.
* the native extension build uses "-ldb2", which means db2cli.lib is not recognized.
* w32api package in Cygwin (not sure if it is needed, may be not)