Tuesday, July 16, 2013

Mount Encrypted LVM Partition - RHEL

I  accidentally delete  RHEL6.4 libc.so.6 link file. The system don't work anymore.
Here is the command I use to mount that partition using ubuntu 12.04 live CD.

0. open terminal
1. sudo su -
2. fdisk -lu
   a. for finding /dev/sda2
3. cd /mnt
4. mkdir enc
5. cryptsetup luksOpen /dev/sda2 encrypted
    a. typing password
6. apt-get install lvm2
7. lvscan
    a. it will show lv inactive
8.vgchange -ay
   a. change lv to active
9.mount /dev/VolGroup00/LogVol101 /mnt/enc

Now you could workin on the /mnt/enc folder

Here is the source.
http://wiki.sabayon.org/index.php?title=HOWTO:_Mount_Encrypted_Partition
http://www.nixetra.com/mount-unknown-filesystem-type-lvm2-member/



Wednesday, July 3, 2013

WARNING: Remote desktop does not support colour depth 16; falling back to 8

I suddenly got this warning when I use rdesktop. It turn out I use full-screen mode and I just add  one more display.  So maybe my display card or X-Windows setting don't have enough RAM. Anyway, just change it not to use full-screen fixed this issue.

Wednesday, May 29, 2013

月亮沒有來

月亮沒有來
今天月亮沒有來
沒有來到我床前的窗沿
不是有霜雪的日子
不是有低頭思鄉的情結
今天月亮沒有來
平常她都是圓圓的臉
圓圓的眼
看著我入眠
月亮沒有來
我依然合著眼
靜靜的睡在沒有月亮的夜

Thursday, May 2, 2013

Rails , Angular and REST resource example.

I work on an rails application and trying to use angular with REST API.
Here I document what I do to make it work:
1. In layout view's head.

  <%= csrf_meta_tag %>
2. In javascript using ng-app module to update httpProvider add csrf token in the header.
var vmShowApp = angular.module('vmShowApp', ['ngResource']);
  vmShowApp.config([
    "$httpProvider", function($httpProvider) {
      $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
    }
  ]);
3.In html page to do the update , it will call update function using ng-click.
<a class="action" href="" ng-click="update('<%= Vm::STATUS[:VM_STATUS_AVAIL] %>')"><%= Vm::STATUS[:VM_STATUS_AVAIL] %></a>
4. In javascript it define update function, looks like angular will create vm object inside this put request, so I add the status inside this vm object.
$scope.update = function(status){
      $scope.vm['status'] = status;
      var vm = Vm.get({id:<%= @vm[:id] %>});
      vm.vm = {}
      vm.vm.status = status;
      vm.$update({id:<%= @vm[:id] %>});
      }; 

5. In config/route.rb define the REST rerouces.
namespace :api do
    namespace :v1 do
      resources  :vms
    end
  end

6.In app/controllers/api/v1/vms_controller.rb define the update function
def update
 respond_with Vm.update(params[:id],params[:vm])
end

Monday, April 29, 2013

DB2 Rails rake test:units


When I try to run rake test:units I got error.

rake aborted!
Task not supported by 'ibm_db'
....

Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)

So the ibm_db plugin didn't provide db:test:purge task.

I found there is a project http://rubyforge.org/projects/db2extended/
But it looks like not work with Rails 3. So I just copy the db2extended_tasks.rake into lib/tasks. It seems works.