Monday, December 30, 2013

Expanding a disk with ubuntu and virtualbox

I have no more free space in my virtualbox disk.  And i created the disk as "static" which is an obstacle when you want to expand the disk:


 walter@walter-Lenovo-Z480:~/VirtualBox VMs/intraweb$ VBoxManage modifyhd Linux1.vdi --resize 20000  
 0%...  
 Progress state: VBOX_E_NOT_SUPPORTED  
 VBoxManage: error: Resize hard disk operation for this format is not implemented yet!  

The disk says "Format variant: fixed"


 walter@walter-Lenovo-Z480:~/VirtualBox VMs/intraweb$ VBoxManage showhdinfo Linux1.vdi  
 UUID:      3492e240-1589-479f-a6d7-f58586a7a671  
 Parent UUID:  base  
 State:     created  
 Type:      normal (base)  
 Location:    /home/walter/VirtualBox VMs/intraweb/Linux1.vdi  
 Storage format: VDI  
 Format variant: fixed default  
 Capacity:    4853 MBytes  
 Size on disk:  4854 MBytes  
 In use by VMs: intraweb (UUID: 76173fac-f9b3-4cf9-9daf-06e363eecd6d)  

The first thing you have to do, just clone the disk.  Once cloned, it will be dynamic:

 walter@walter-Lenovo-Z480:~/VirtualBox VMs/intraweb$ VBoxManage clonehd Linux1.vdi Linux1d.vdi  
 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%  
 Clone hard disk created in format 'VDI'. UUID: e8f06a57-805e-464f-8cbc-3e23d082a003  
 walter@walter-Lenovo-Z480:~/VirtualBox VMs/intraweb$ VBoxManage showhdinfo Linux1d.vdi  
 UUID:      e8f06a57-805e-464f-8cbc-3e23d082a003  
 Parent UUID:  base  
 State:     created  
 Type:      normal (base)  
 Location:    /home/walter/VirtualBox VMs/intraweb/Linux1d.vdi  
 Storage format: VDI  
 Format variant: dynamic default  
 Capacity:    4853 MBytes  
 Size on disk:  4475 MBytes  

Now, i changed the original disk with this new one in the Virtual Box GUI Management and everything was smooth.

Next, i just resized the disk to have 20 Gig instead of only 4 Gig
 walter@walter-Lenovo-Z480:~/VirtualBox VMs/intraweb$ VBoxManage modifyhd ~/VirtualBox\ VMs/intraweb/Linux1d.vdi --resize 20000  
 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%  

Now i started the ubuntu desktop to use gparted and resize the guest operating system:

Choose to "Try Ubuntu"

Make sure to choose the right disk, i can not take any responsibility if something of this goes wrong:


I was not able to move the swap disk, so i removed it with fdisk.

fdisk /dev/sda
d 5
d 2
w
And then i started gparted again. Now i was able to resize the partition.  Then, i rebooted the virtual machine and opened gparted again.  Added the swap partition and rebooted.






Tuesday, November 05, 2013

How to compress a file in linux. In parts

To compress a file in parts i use RAR.  There are many ways to do it.

rar a -v250000k /rar_file_name.rar /directory_or_file/

Tuesday, June 12, 2012

Creating a RAMFS

With the previous method i found it slow for being a ram disk, i read that ramfs does no swapping, i want to test it:

mount -t ramfs -o size=50m ramfs /ramcache
 

This is a good resource:
http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/ 

Linux RAM filesystem

I do datamining, and the first thing learned is that 80% of this wonderful science is datapreparation.  I am looking for cheap wais to manage large about of data, and today i want to try how a RAM disk in Linux performs to create a dataset for weka.

As root, i want a 10MB file (yes, even though it is far away from being big data, the data preparation was taking several minutes)

root@talento:~# mkfs -q /dev/ram1 10240
root@talento:~# mkdir -p /ramcache
root@talento:~# mount /dev/ram1 /ramcache
root@talento:~# df -H | grep ramcache
/dev/ram1               11M    95k   9.6M   1% /ramcache




Wednesday, June 06, 2012

How to normalize a variable

This is simple procedure, to normalize a variable and bring it from a scale to another, this is the procedure:



The minimum values of A and maximum values are obvious (i hope),
D and C are the new ranges.  Being D the maximum from the new range and C the minimum from the new range.

This is an example:


Tuesday, May 29, 2012

Perl Date manipulation as is

Today i had to program a little script, in perl, and had to manipulate some dates.  To convert the AM/PM part i used this previously written function (here).

But then i need to do some delta operation on the dates, for whom i new packages like Date::Calc.

The surprise was that i couldn't install new packages in the server, it is a remote server and the less problems one causes, the better... because the server is shared, there was no gcc, bla, bla..

I found this package:
use Date::Manip;

Which seems to be included with Perl.  I couldn't confirm it but it saved the day, here is an example:

my $ffin = &DateCalc("$startdate", "+8 days", \$err);
my ($y, $m, $d) = $ffin =~ m/([0-9]{4})([0-9]{2})([0-9]{2}).*/g;


More about it:
http://snowhare.com/utilities/perldoc2tree/example/Date/Manip.html

Tuesday, April 24, 2012

glib lotus notes java memory corruption



Today i updated some packets related to IBM lotus notes and a problem with libraries caused a great and long investigation process to have lotus notes back.


I tried lot of things: reinstalling, purging the packets, installing the same version again... nothing worked. Today i found the solution here.


It says:

[...] After some research I found the problem: libnuma. If this lib exists in the system the Notes Client loads data forever. [...]


the solution is:
apt-get remove libnuma1





Standard disclosure: this is my opinion and not necessarily that of my employer or anyone else.

Monday, February 27, 2012

Decision Trees with r project on Linux

Chaid Trees with R Project on Linux

Start R and install Partykit:
$ R
> install.packages("partykit")

On a command line download the chaid sources:
svn checkout svn://svn.r-forge.r-project.org/svnroot/chaid/

$ cd chaid
$ R CMD INSTALL pkg/

On R:
> library("CHAID")
Loading required package: partykit
Loading required package: grid



Chaid project:
http://r-forge.r-project.org/scm/?group_id=343