martedì 15 settembre 2009

Migrate Physical Linux Box to Virtual Image

In these days I need to migrate my BioInformatics server from a physical machine to a virtuale one.
I don't want to reinstall everything so the cloning is the better solution from my point of view.
Resuming the steps:
0) Download and burn an image of SystemRescueCd
1) Clone the original partitions using Partimage booting from SystemRescueCd
2) Create a virtual machine -I'm using VirtualBox.
2.1) Create a virtual disk. You can use a remote disk, I did so cause I haven't space on my notebook.
2.2) Enable network, NAT is enought
3) Using Gparted recreate the original structure
4) Restore data using Partimage
5) Fix Grub and Network

Step by step:
0) None, download and burn is a very basic operation.
1) Cloning original partitions:
1.1) Boot using SystemRescueCd with these parameters:
rescuecd setkmap=it docache dodhcp
setkmap is for setting my italian keyboard
docache is used to load in memory the sysresc cd, it requires about 400 MB of RAM
dodhcp request an ip if you need to mount remote disk or partitions.
Note: in my case I saved the partition on a network disk using mount.cifs (samba), you can use nfs too
1.2) mount.cifs //remote_machine_ip_better/remote_exported_directory /mnt/backup -o user=your_remote_user
Insert the password and it's done.
1.3) partimage save /dev/sdaX /mnt/backup/backup-sdaX-pimg
substitute X with the number of the partition you are going to backup.
1.4) Coffe... and repeat the procedure for every partition.

2) Creating a VirtualBox machine is very easy, create a dinamically virtual disk of appropriate max capacity. Keep in mind that partimage saves only the occupied data an not the whole partition so you'll get a backup file which is proably smaller than you original paritition ( without considering compression obviously). However I suggest to oversize a littel bit the dinamically disk, acqually I don't know why the system gets problems with the exact size.
NB: you can create a virtual disk on a remote location without problem. I mounted the remote location from Windows.
2.1) Give enought memory to load the cd in cache, so al least 512 of ram, it's not mandatory (remove docache parameter at boot).
2.2) Boot SystemRescueCd in the same wey you did at (1.1)
rescuecd setkmap=it docache dodhcp
2.3) mount the backup disk, in my case a remote one.
mount.cifs //remote_machine_ip_better/remote_exported_directory /mnt/backup -o user=your_remote_user
Insert the password and it's done.
3) type "wizard" in console and the graphic interface will start, I hope for you.
3.1) type "gparted" in the terminal and recreate the structure of the physical machine into the virtual disk.
4) then restore the images:
partimage restore /dev/sdaX /mnt/backup/backup-sdaX-pimg.000
4.1) Coffe...
5) at this point you need to create a startup partition on the virtual disk. I followed this guide

Ripristinare Grub da LiveCD con grub-install (e altre amenità)

mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mount --bind /dev/ /mnt/sda1/dev/
mount -t proc none /mnt/sda1/proc
chroot /mnt/sda1 /bin/bash
#check you grub configuration, if your distro uses UUID you need to update the menu.lst file and the device map too.
grub-install /dev/sda
6) shutdown the virtual machine, remove the booting from SystemRescueCd and restart the VirtualMachine.
7) If everything works, Beer.

Note: I got problems with the network in Ubuntu because it configures the macaddress in /etc/udev/rules.d/70-persistent-net.rules, I just deleted the content of the file and then rebooting the system can acquire the correct mac address assigned by VirtualBox. Actually I had this problem cloning a virtual machine using the above procedure.


EDIT: I have had seriuos problems handling data from remote -smb- filesystem. Don't know why.

giovedì 23 luglio 2009

[Solved] Ontologizer, ubuntu, swt 3.4

aptitude install libswt-gtk-3.4-java


java -cp /usr/share/java/swt-gtk-3.4.jar:ontologizer.jar ontologizer.gui.swt.Ontologizer
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-gtk-3448 or swt-gtk in swt.library.path, java.library.path or the jar file
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:233)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:151)
at org.eclipse.swt.internal.C.(C.java:21)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.(Display.java:130)
at ontologizer.gui.swt.Ontologizer.main(Ontologizer.java:201)

Solved with :
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jni java -cp /usr/share/java/swt-gtk-3.4.jar:ontologizer.jar ontologizer.gui.swt.Ontologizer

domenica 31 maggio 2009

Rails, form_remote_tag, method GET

This is not a bug, just a reminder for me on HowTo set up a form_remote_tag with method GET on Rails, I'm using version 2.2.2
The only things bugged here is the documentation bevause is not very intuitive. There are a lot of examples but none about setting the method to GET. This snippet sets the ajax request and the html request to GET. Don't forget to set both to get, otherwise you'll have a for with an ajax get and a html post, POST is the DEFAULT.

     form_remote_tag  :url => blasts_path,
                        :method => :get,
                        :html => {:method=> :get},
                        :update => { :success => "succeed", :failure => "fail"} do 

....YOUR CODE  HERE....

       select("sm","id", {"SeMe clusters"=>"1", "All clusters"=>"0"}) 
       submit_tag "Search", :name => nil 
    end 

      
    

mercoledì 20 maggio 2009

Rails and mixed models convetions

I wrote a library for BioRuby to store data into BioSQL.  Evertything is fine, I hope :-), using the lib inside the BioRuby world but going outside and meeting rails, there is a crash.
BioSQL' schema doesn't follow the Rails' rules, because ... long story but that's it. Active record needs to be tuned, removing pluralization and changing the primary key structure:

self.pluralize_table_names = false
self.primary_key_prefix_type = :table_name_with_underscore

wow cool it's I can read my schema but ...
Using biosql into a rails app there is a problems, If you have tables which are referring/referred to/by  BioSQL schema you must specify the :class=>"Bio::SQL::XXX".
Then your notBioSQL tables loose their active record default properties like default primary keys and name convention. I had to re-setup them in every new table/class model.
That is very strange; I can't find an explenation but after days of trouble I got it. 
link_to method was my black doom.


When your Boss became a Parrot

There is always a bug and it's quite stressing when you find it, why ?
Usually happends when you have no time or your boss is over your shoulder wating for your answer. You are the Tree and he is the Parrot.

Discovering and resolve bugs is very interesting, keep your bain young and imply a lot of work for Google.

I'm working with a lot of technologies, Ruby, Rails, DB Postgresql and MySQL,  JEE, Hibernate, bioinformatic tools. 
Everything is like a mine field. The Parrot in this case is flying over your head.