jueves, 18 de febrero de 2010

lunes, 15 de febrero de 2010

Copy MBR from one disk to another

This command will do the trick:
dd if=/dev/sda of=/dev/sdb bs=512 count=1



Getting Virtualized!!!

I had been looking for a process where you could take an existing physical machine, and convert it into a new virtual one.
There are a few steeps that are needed in order to achive this goal:
- Define a virtualized hardware: CPU, Memory, IO, Networking.
- Export the data: this is the most critical process.
In order to get an vmkd file or vdi of an existing physical instalation consists in a few steps that i will explain here:
- First, boot the operating system with a live linux cd.
- Second, identify the partition or partitions involved in the recovery. For instance hd3
- Third, make a good use of dd like this one:
dd if=/dev/hdc of=/mnt/USB/diskImage/win2k3.img bs=1024
the partition will be dumped into a file.
- Fourth: qemu-img convert -f raw /mnt/USB/diskImage/w2k3.img -O vmdk /mnt/external/diskImage/w2k3.vmdk

VMware: Using player to install yor VM's

VMware player is almost a complete virtualization platform, the only thing that is missing to achive the full functuality of its big brother Workstation is the "Configuration Wizard".
I had found a website that allows you to define a vmx file (the configuration file) but i have found also a procedure to create your own.

The basics.

virtualHW.version
This parameter defines the version used. Defaults to 4

displayName
This parameter will be used in order to identify the virtual machine.

memsize
This parameter is obvious. Configures the amount of memory reserved for the vm.
defaults to Megabytes. Example 512


ideX:X.fileName
This parameter will be used in order to identify the disk . An example could look like this: "FREEDOS.vmdk"

ideX:X.present
Enables the availability of the disk to the vm. TRUE/FALSE

guestOS
The id of the operating system. See bellow in the Guest OS section list.
example winXPPro

Network
This section is a little bit more complicated. Each nic can have 3 status:
- bridget.
- hostOnly
- Internal Network.
Example :

ethernet0.present = "TRUE"
ethernet0.vnet = "VMnet0"
ethernet0.virtualDev = "vlance"


cdrom.

ide1:0.fileName = "E:\2k3-sp1-pebuilder313\pebuilder.iso"
ide1:0.deviceType = "cdrom-image"
ide1:0.startConnected = "TRUE"
ide1.1.present = "FALSE"



A more complex vmx file.

This example has been extracted from http://sanbarrow.com/vmxbuilder.html

###### stupid-long-name .vmx #################
######
###### use copy and paste
###### to export this file
######
#######################################
####### generated by Ullis VM builder #

####### Identity ######################
displayName = "stupid-long-name"

# Devices
config.version = "8"
virtualHW.version = "4"
memsize = "512"
numvcpus = "2"
guestOS = "winNetEnterprise"

####### ide-disks #####################
ide0.0.present = "FALSE"
ide0.1.present = "FALSE"
ide1:0.present = "TRUE"
ide1:0.fileName = "E:\2k3-sp1-pebuilder313\pebuilder.iso"
ide1:0.deviceType = "cdrom-image"
ide1:0.startConnected = "TRUE"
ide1.1.present = "FALSE"

####### scsi-controllers ##################
scsi0.present = "TRUE"
scsi0.virtualDev = "buslogic"
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"

####### scsi-disks #####################
scsi0:0.present = "FALSE"
scsi0:1.present = "FALSE"
scsi0:2.present = "FALSE"
scsi0:3.present = "FALSE"
scsi0:4.present = "FALSE"
scsi0:5.present = "FALSE"
scsi0:6.present = "FALSE"
scsi1:0.present = "FALSE"
scsi1:1.present = "FALSE"
scsi1:2.present = "FALSE"
scsi1:3.present = "FALSE"
scsi1:4.present = "FALSE"
scsi1:5.present = "FALSE"
scsi1:6.present = "FALSE"

####### nics ##########################
ethernet0.present = "TRUE"
ethernet0.vnet = "VMnet0"
ethernet0.virtualDev = "vlance"
ethernet1.present = "TRUE"
ethernet1.vnet = "VMnet1"
ethernet1.virtualDev = "vmXnet"
ethernet2.present = "TRUE"
ethernet2.vnet = "VMnet2"
ethernet2.virtualDev = "vlance"
ethernet3.present = "TRUE"
ethernet3.vnet = "VMnet3"
ethernet3.virtualDev = "vmXnet"

####### sound #########################
sound.present = "FALSE"

####### usb ###########################
usb.present = "FALSE"

####### floppies #######################
floppy0.present = "FALSE"
floppy0.startConnected = "FALSE"
floppy1.present = "FALSE"
floppy1.startConnected = "FALSE"

####### ports #########################
parallel0.present = "FALSE"
serial0.present = "FALSE"
serial1.present = "FALSE"

####### cluster-options ##################
####### skipping Cluster-options ###########



The Guest Os supported.
Bellow is the list of operating systems supported and the Id
Microsoft Windows, 32-bit

winVista = Windows Vista (experimental)
longhorn = Windows Longhorn (experimental)
winNetBusiness = Windows 2003 Small Business Server
winNetEnterprise = Windows 2003 Enterprise Server
winNetStandard = Windows 2003 Server
winNetWeb = Windows 2003 Web Server Edition
winXPPro = Windows XP Professional Edition
winXPHome = Windows XP Home Edition
win2000AdvServ = Windows 2000 Advanced Server
win2000Serv = Windows 2000 Server
win2000Pro = Windows 2000 Professional
winNT = Windows NT
winMe = Windows Me
win98 = Windows 98
win95 = Windows 95
win31 = Windows 3.1 / Windows 3.11
windows = Other Windows
Microsoft Windows, 64-bit

winVista-64 = Windows Vista x64 Edition (experimental)
longhorn-64 = Windows Longhorn x64 Edition (experimental)
winNetEnterprise-64 = Windows 2003 Enterprise Server x64 Edition
winNetStandard-64 = Windows 2003 Server x64 Edition
winXPPro-64 = Windows XP Professional x64 Edition
Linux, 32-bit

ubuntu = Ubuntu Linux
redhat = Red Hat Linux
rhel4 = Red Hat Enterprise Linux 4
rhel3 = Red Hat Enterprise Linux 3
rhel2 = Red Hat Enterprise Linux 2
suse = SuSE Linux
sles = SuSE Linux Enterprise Server
mandrake = Mandrake Linux
nld9 = Novell Linux Desktop 9
sjds = Sun Java Desktop System
turbolinux = Turbo Linux
other26xlinux = Other Linux on a 2.6.x kernel
other24xlinux = Other Linux on a 2.4.x kernel
linux = Other Linux
Linux, 64-bit

ubuntu-64 = Ubuntu Linux 64-bit
rhel4-64 = Red Hat Enterprise Linux 4 64-bit
rhel3-64 = Red Hat Enterprise Linux 3 64-bit
sles-64 = SuSE Linux Enterprise Server 64-bit
suse-64 = SuSE Linux 64-bit
other26xlinux-64 = Other Linux 2.6.x 64-bit
other24xlinux-64 = Other Linux 2.4.x 64-bit
otherlinux-64 = Other Linux 64-bit
Sun Microsystems Solaris

solaris10-64 = Solaris 10 64-bit
solaris10 = Solaris 10
solaris9 = Solaris 9
solaris8 = Solaris 8
solaris7 = Solaris 7
solaris6 = Solaris 6
solaris = Other Solaris
Novell Netware

netware6 = Netware 6.x
netware5 = Netware 5.x
netware4 = Netware 4.x
netware = Other Netware
FreeBSD

freeBSD-64 = FreeBSD 64-bit
freeBSD = FreeBSD
Apple Darwin

darwin = Apple Darwin (unsupported)
Other

other = Other OS
other-64 = Other 64-bit OS

viernes, 12 de febrero de 2010

VMDK file creation with QEMU

In order to get a vmdk file for VirtualBox or VMWare download the latest release of Qemu
and execute the following command:
>qemu-img.exe create -f vmdk WindowsXPPro.vmdk 2G for windows
>qemu-img create -f vmdk WindowsXPPro.vmdk 2G for linux

jueves, 11 de febrero de 2010

Ldap timestamp search

Hi there!!!
I had to produce an incremental ldif file from an ldap server. This file had to have all ldap entries modified from a certain date (for example 1st of Febrary 2010). But the issue was not as easy as it sounds, mainly because i had to guess what was the search string that provided a valid filter in order to get the desired results.
The format is as follows:
YYYYMMDDhhmmssZ
4 digit Year
2 digits Month
2 digits Day
2 digits hour
2 digits minute
2 digits second
End with "Z" char
Example:

ldapsearch -x -H ldaps://A.B.C.D:636 -D "cn=admin,o=demo" -W -b "ou=users,o=kasa" "modifyTimestamp>=20100201000000Z" >tst.ldif

I hope that it will be usefull for you.

martes, 2 de febrero de 2010

Multiple CPU top report

Many times i wanted to know what was the status of the system in terms of CPU usage. In the interactive mode just press the "1" key and on the top side of the report you would be able to see the status of every core you have on your system.
Regards...

lunes, 25 de enero de 2010

Changing ip address with IP command

Hi there!!!
It's been a while since I don't practice my blogging skills , in part because I've been in holidays, and in part because i've been too lazy :D. No, seriously, i've been working on a project with a very tight deadline and i've been so exhausted that when i come back home i only wanted to have a break of computers.
Well, lets talk about our today's topic. Network configuration has been centralized with ip commands and today we will deal with network device management.
What we previously perform with ifconfig up and ifconfig down today can be run with:

ip link set dev up

ip link set dev eth0 up

or
ip link set dev down

ip link set dev eth0 down

I will try to improve this entry with many other options like ipaddress and things like that.

Cheers and have a Zen day!!!

jueves, 7 de enero de 2010

Changing the UUID of a disk for a virtual machine on Sun Virtual Box

Hello everyone!!!
First of all, I want to wish to every person who visits this site a happy new year.
2009 has been a very difficult year for a lot of people i know (even myself) , and i hope 2010 to be much better with a lot of new challenges, experiences, etc...
Back to our blog, i want to share a tip that will allow us to duplicate the UUID of a disk.
This is very helpful when you need to reuse a clean operating system installation on several vms on the same machine.
By default Virtual Box will complain with a message saying that
"hard disk with UUID {55b773b8-cbcb-42ea-9a44-1368b3XXXX} or with the same properties is already registered" failing to load the disk.
In order to avoid this, just type :
VBoxManage internalcommands setvdiuuid |diskname.vdi|
and a new UUID will be generated and assigned.
Ciaooo!

jueves, 19 de noviembre de 2009

Capturing tcp traffic with tcpdump

With the following recipe you will be able to snif the traffic between a client and a web server. Very helpful if you are in the dark without any clue of whats going on, and you need low level dump of the protocol:
tcpdump -vvv -n -s 65535 -A -p -w tcpdump.ok tcp src port 80

lunes, 16 de noviembre de 2009

What you still haven't found on a ldap server

Sometimes you need to perform a ldap search from the unix console, for that hard times i use the folling recipe (using ldapsearch from openldap) :
ldapsearch -b BASEDN -s sub -h HOSTNAME -p PORT-x -D FULLDNTOBIND -w PASSWORDTOBIND QUERY

Where
BASEDN = is the base for the search.
HOSTNAME = is the ldap server
PORT= is the ldap server port
FULLDNTOBIND = it's the dn of the user that you want to use to login to the ldap server-
Example
cn=rene the frog, ou=muppets,o=jim hensons,c=us

QUERY = the parameters for the query. For further information please visit this link which contains the definition for the ldap filters
Example
cn=rene*

jueves, 5 de noviembre de 2009

OpenSSL symmetric cyphers

Another brick on the wall.
I've cover several times how to use openssl. Nowadays, it's one of my favorite tools because it has take me out of the hole so much times, that i can't count them all.
But let's get on it and stop talking about it.

[XCV@gambit ~]$ echo "holamundo"|openssl enc -d -base64 -des -A
enter des-cbc decryption password:fulano123

[XCV@gambit ~]$ echo "U2FsdGVkX18431qpTMhtluUChBpqVDQ8ceUo5+XSXjY="|openssl enc -d -base64 -des -A
enter des-cbc decryption password:fulano123


that's it...

lunes, 2 de noviembre de 2009

Fixing "terminal too wide" error

Morning dudes!!!
I've been out of the scene for a while, mainly because of the summer, but also because I've been very busy in the first part of the Autum. Happily I am back with this short recipe.

More and more wide screens are being used at workstations in corporate environments and vi isn't aware of this. With this little command we will fix the "terminal too wide error" caused by the extra amount of columns in this type of screens.
stty columns 120