Cloning PCs with Clonezilla

Sun, January 25, 2009

Here is a problem I faced recently.

Given a bunch of networked PCs (20+) running Windows XP it is inevitable that they will get corrupted. Whether it is due to viruses, spyware or malware is immaterial as figuring that out and cleaning PCs individually takes a lot of time; even more so when there is no dedicated system admin and the person managing the cluster has little knowledge of system administration. The action most people take when faced with a messed up windows installation is to do a format followed by a reinstall. Now, this is time consuming even for a single PC given that you need to install Windows, update it, install your programs, set up your users and restore any essential data. Doing so for multiple PCs is just not practical.

To tackle this kind of issue there are a bunch of proprietary solutions out there including the popular Norton Ghost Suite from Symantec. However, there is a great free/open-source solution for this in the form of Clonezilla running on DRBL. What is great about this solution is that you can restore backups to multiple machines simultaneously from a single server using multicast.

DRBL on its own is an interesting tool. It allows the clients to boot into Linux from the server using PXE/etherboot. There is also a Windows tool (called WinRoll) for DRBL which allows Windows machines to interact with the server. I haven’t explored all the features of DRBL as I was more interested in getting Clonezilla up and running.

The first step to getting Clonezilla ready is to select a machine to be a server and install a Linux distro on it (I chose Ubuntu). It is advisable that the machine has two network cards but I was able to get by with a single NIC. It is better to check that the server has enough disk space for the images and a decent file system, simple advice but easy to overlook. Once that is done, setting up DRBL+Clonezilla should be a simple task. I found these (https://wiki.edubuntu.org/SettingUpClonezillaDRBLonUbuntu) excellent instructions which provide a step-by-step guide of the process. The server mentioned in the instructions might be slow for some. In that case it is better to use a different mirror. This forum post lists a few which I found were much faster.

Once the tools are installed and ready start up DBRL and go into Clonezilla mode. There will be an option here to create an image from a client. It is best to create an image for the entire hard disk rather than a partition. When all the settings are done at the server the client can then be booted via PXE and it will automatically start creating the image and transferring it to the server. As a guide for a 40 Gig harddisk (with 6Gig of data on it) it took me about ten minutes to create the image. If it is taking much longer than that make sure that all the partitions are properly formatted, else it is possible that Clonezilla confused free space as data and is making an image of it.

Restoring images is a simple task. It can either be done from the server itself or individually from the clients and takes about the same time as creating the image in the first place. All it requires is tinkering a little bit with the various Clonezilla modes and settings.


Heroes 3 WOG Campaign Tips

Sun, October 14, 2007

In the realm of turn based strategy/adventure games 3DO’s Heroes of Might and Magic Series has been a real gem. I have been a fan of the series since Heroes II (I tried the original Heroes 1 after I’d finished The Price of Loyalty). Recently being bored and in need of a break I decided to try out the community expansion pack (In the Wake of the Gods available from here) for Heroes 3. Being a fan of the Necromancer’s I started with the ‘Evil Way Home’ campaign. Being accustomed to the comfort of a normal Heroes game I found WOG slightly confusing. This changed into frustration after hours spent on the first level without a clue on how to proceed. This only increased when I was unable to locate a walkthrough for the campaign. Even the old and faithful gamefaqs turned up nothing. After spending some more time on the level and completing the tutorial, I was finally able to make some progress. So here I am posting some tips for anyone who might be struggling with the same problems as me.

Level 1:

– You have to destroy the first Castle you capture and convert it into a Necropolis before you can search at the statue. The tutorial explains how to destroy and rebuild towns. Oh and make sure you save enough gold to purchase the ghosts that will show up to haunt your scene of destruction :).

– You don’t need to visit a keymaster to go through the blue border gate. The statue gives you a key which allows you to cross the gate.

– Defeat the archangels before Edric(the super strong blue hero) gets to them.

– One of the structures gives your hero a transform ability. To make that work at the end of your move place the creatures you want to upgrade in the first slot and place the desired creatures in the last slot. The next move you can upgrade the creatures via your hero stat page.

– The final Necropolis is slightly hidden but it is at the top left of the map.

Level 2:

– This is a very long mission.

– To free Tamika you need a black dragon which can be recruited at the Dungeons located underground. In my game there was one in which the AI had already built a dragon cave so I just upgraded it to get the black dragons.

– You can get a blood dragon early on in the north-east of the map. Combined with the transform ability this can be of much help.

– The toughest part is completing the Seer’s quest. Actually finding the seer himself is pretty darn hard. He is located right at the bottom centre of the map in what the Walking Dead’s call Elven Country. He requires an Archangel before he passes you the winged boots. You can find Angels after visiting a Griffin Conservatory. To upgrade them you need to find the only hill fort on the map. It is in the south-west in Blue’s land.

I am still on the 3rd mission so might add tips for that and the rest later….


dot emacs

Sat, October 13, 2007

I am a heavy emacs user and while I can list many reasons why emacs is better than vi(m) or any other editor for that matter I’ll leave it at that ;). Using emacs without a dot emacs is like music with DRM, not all that great. While a dot emacs file is something very personal and should evolve with time looking at other people’s dot emacs can help you improve your own. Hence I am posting my dot-emacs file (with snippets copied shamelessly from all around the web) below. You might need some additional packages and/or .el files for some sections to work properly or you could just comment them out.

; used to higlight current line
; (global-hl-line-mode 1)

; used to enable the mouse wheel
(mouse-wheel-mode t)

(set-background-color "Black")
(set-foreground-color "Lime green")
(set-cursor-color "White")
(global-font-lock-mode 1)
;; (setq scroll-preserve-screen-position t)

(display-time)

;; The following line will change the colour of the variable
(set-face-foreground 'font-lock-function-name-face "Royalblue2")

;; This would change the way the strings appear
(set-face-foreground 'font-lock-string-face "white smoke")
(copy-face 'italic 'font-lock-comment-face)

;; Change how comments appear
(set-face-foreground 'font-lock-comment-face "wheat2")

;; Change the appearence of keywords
(set-face-foreground 'font-lock-keyword-face  "turquoise1")

; put as much syntax highlighting into documents as possible
(setq font-lock-maximum-decoration t)

;; Set a default font & a function to reset the default font
(setq *default-font* "-adobe-courier-medium-r-*-*-24-*-*-*-*-*-*-*")
(defun reset-font-to-default ()
(interactive)
(set-default-font *default-font*))
(reset-font-to-default)

;; Save all backup file in this directory.
(setq backup-directory-alist (quote (("." . "~/emacs_backups/"))))

;; Mode for Editing CG files
(setq load-path (cons "C:/Documents and Settings/Administrator/My Documents/HOME/Language Modes" load-path))
(require 'cg-mode)

;; lua mode
(require 'lua-mode)

;; C# mode loaded in a weird way
(autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
(setq auto-mode-alist
(append '(("\\\\.cs$" . csharp-mode)) auto-mode-alist))

;; Auto Completion!!
;; (require 'completion)

;; Highlight matching paranthesis
(show-paren-mode 1)

;convert a buffer from dos ^M end of lines to unix end of lines
(defun dos2unix ()
(interactive)
(goto-char (point-min))
(while (search-forward "\\r" nil t) (replace-match "")))

;vice versa
(defun unix2dos ()
(interactive)
(goto-char (point-min))
(while (search-forward "\\n" nil t) (replace-match "\\r\\n")))

;; Word Count tool, per sshteingold@cctrading.com
(defun wc (start end)
;; replacement for count-lines-region
"Count lines/words/characters from START to END"
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (min start end))
(message "Region (%d to %d) has: lines: %d; words: %d; characters: %d."
start end (count-lines start end)
(string-to-number (how-many "\\\\<")) (- end start)))))
(define-key esc-map "=" 'wc)

(w32-send-sys-command 61488) ;; Maximize the window in w32

(setq c-hungry-delete-key t) ;;will delete "hungrily" in C mode! Use it to see what it does -- very useful.

;;(setq c-auto-newline 1) ;;will let emacs put in a "carriage-return" for you automatically after left curly braces, right curly braces, and semi-colons in "C mode" -- very useful.

(global-set-key [f12]         'dabbrev-expand)
(define-key esc-map [f12]     'dabbrev-completion)

(defun time-stamp ()
"Insert Name and a time stamp."
(interactive "*")
(insert
(concat "NAME HERE\\n"
"[" (format-time-string "%b %d, %y" (current-time)) "] ")))

;; GNUSERV Stuff for Emacs integration into windows(credit http://giantbucket.com/blog/2006/05/how-to-integrate-emacs-with-windows.html)
(setenv "GNUSERV_SHOW_EMACS" "1")
(require 'gnuserv) ;; gnuserv.el should be in emacs path right now it is in the language modes folder
(gnuserv-start)
(setq gnuserv-frame (selected-frame))

;; TEMPO STUFF (credit http://infolab.stanford.edu/~manku/emacs.html)
;; This is a way to hook tempo into cc-mode
(defvar c-tempo-tags nil
"Tempo tags for C mode")
(defvar c++-tempo-tags nil
"Tempo tags for C++ mode")

;;; C-Mode Templates and C++-Mode Templates (uses C-Mode Templates also)
(require 'tempo)
(setq tempo-interactive t)

(add-hook 'c-mode-hook
'(lambda ()
(local-set-key [f11] 'tempo-complete-tag)
(tempo-use-tag-list 'c-tempo-tags)
))
(add-hook 'c++-mode-hook
'(lambda ()
(local-set-key [f11] 'tempo-complete-tag)
(tempo-use-tag-list 'c-tempo-tags)
(tempo-use-tag-list 'c++-tempo-tags)
))

;;; Preprocessor Templates (appended to c-tempo-tags)

(tempo-define-template "c-include"
'("include <" r ".h>" > n
)
"include"
"Insert a #include <> statement"
'c-tempo-tags)

(tempo-define-template "c-ifdef"
'("ifdef " (p "ifdef-clause: " clause) > n> p n
"#else /* !(" (s clause) ") */" n> p n
"#endif /* " (s clause)" */" n>
)
"ifdef"
"Insert a #ifdef #else #endif statement"
'c-tempo-tags)

(tempo-define-template "c-ifndef"
'("ifndef " (p "ifndef-clause: " clause) > n
"#define " (s clause) n> p n
"#endif /* " (s clause)" */" n>
)
"ifndef"
"Insert a #ifndef #define #endif statement"
'c-tempo-tags)
;;; C-Mode Templates

(tempo-define-template "c-if"
'(> "if (" (p "if-clause: " clause) ")" n>
"{" > n>
> r n
"}" > n>
)
"if"
"Insert a C if statement"
'c-tempo-tags)

(tempo-define-template "c-else"
'(> "else" n>
"{" > n>
> r n
"}" > n>
)
"else"
"Insert a C else statement"
'c-tempo-tags)

(tempo-define-template "c-if-else"
'(> "if (" (p "if-clause: " clause) ")"  n>
"{" > n
> r n
"}" > n
"else" > n
"{" > n>
> r n
"}" > n>
)
"ifelse"
"Insert a C if else statement"
'c-tempo-tags)

(tempo-define-template "c-while"
'(> "while (" (p "while-clause: " clause) ")" >  n>
"{" > n
> r n
"}" > n>
)
"while"
"Insert a C while statement"
'c-tempo-tags)

(tempo-define-template "c-for"
'(> "for (" (p "for-clause: " clause) ")" >  n>
"{" > n
> r n
"}" > n>
)
"for"
"Insert a C for statement"
'c-tempo-tags)

(tempo-define-template "c-for-i"
'(> "for (" (p "variable: " var) " = 0; " (s var)
" < "(p "upper bound: " ub)"; " (s var) "++)" >  n>
"{" > n
> r n
"}" > n>
)
"fori"
"Insert a C for loop: for(x = 0; x < ..; x++)"
'c-tempo-tags)

(tempo-define-template "c-main"
'(> "int main(int argc, char *argv[])" >  n>
"{" > n>
> r n
> "return 0 ;" n>
> "}" > n>
)
"main"
"Insert a C main statement"
'c-tempo-tags)

(tempo-define-template "c-if-malloc"
'(> (p "variable: " var) " = ("
(p "type: " type) " *) malloc (sizeof(" (s type)
") * " (p "nitems: " nitems) ") ;" n>
> "if (" (s var) " == NULL)" n>
> "error_exit (\\"" (buffer-name) ": " r ": Failed to malloc() " (s var) " \\") ;" n>
)
"ifmalloc"
"Insert a C if (malloc...) statement"
'c-tempo-tags)

(tempo-define-template "c-if-calloc"
'(> (p "variable: " var) " = ("
(p "type: " type) " *) calloc (sizeof(" (s type)
"), " (p "nitems: " nitems) ") ;" n>
> "if (" (s var) " == NULL)" n>
> "error_exit (\\"" (buffer-name) ": " r ": Failed to calloc() " (s var) " \\") ;" n>
)
"ifcalloc"
"Insert a C if (calloc...) statement"
'c-tempo-tags)

(tempo-define-template "c-switch"
'(> "switch (" (p "switch-condition: " clause) ")" n>
"{" >  n>
"case " (p "first value: ") ":" > n> p n
"break;" > n> p n
"default:" > n> p n
"break;" > n
"}" > n>
)
"switch"
"Insert a C switch statement"
'c-tempo-tags)

(tempo-define-template "c-case"
'(n "case " (p "value: ") ":" > n> p n
"break;" > n> p
)
"case"
"Insert a C case statement"
'c-tempo-tags)

(tempo-define-template "c++-class"
'("class " (p "classname: " class) p > n>
" {" > n
"private:" > n
"" > n
"protected:" > n
"" > n
"public:" > n
"" > n
"};" > n
)
"class"
"Insert a class skeleton"
'c++-tempo-tags)

Hello world!

Sat, October 13, 2007

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!