July 30th, 2010 — GNU/Linux
In most cases when I’m working with the shell, I send my applications to background, mostly my emacs. Nonetheless I forget quickly, and I open too many times the same file.
Due to my lack of memory I decided to make a function that shows me how many programs I have in background, here is the function:
function get_njobs {
njobs=$(jobs | wc -l)
if [ $njobs -gt "0" ];
then
echo $njobs | sed -e 's/\([0-9]*\)/(\1)/g'
fi
}
function prompt {
# Shell into Emacs
if [ $TERM != "dumb" ];
then
alias ls='ls --color=auto'
PS1="${purpple}\u@${close}${YELLOW}\h${close}:{\W}\$(get_njobs)"
else
PS1="[\u@\h:\w]"
fi
}
user@host:{~} emacs &
user@host:{~}(1)
As you may notice, the number inside the brackets remembers me if there is some program running in background. Do not forget to add the function at the end of your bashrc.
April 27th, 2010 — GNU/Linux
Last day I ran into a trouble with my subversion repositories, somebody changed the port I was using, somehow my repositories were not able of finding the original url, and here is the way how sorted it out:
user@host:/myrepo/svn switch –relocate http://mysite.com/myrepo http://mysite.com:7777/myrepo
Now you can do commits.
March 16th, 2010 — GNU/Linux, Virtualization
This entry will explain two troubles that I found while I was using
Vmware Server 2 :
- Initialized monitor device
If you see an image like shown below,

you had better check if you have “kvm” modules loaded
# lsmod | grep kvm
kvm_intel 31168 0
kvm 106620 1 kvm_intel
Now yo have to unload the modules, first “kvm_intel”, if you try to unload kvm you will not be able due to dependency between them.
At this point it turns out that you can start your virtual machine, but maybe you can not open the virtual console, so let’s go next point.
- Remote console plug-in error
If you are trying out to get a console and it shows up a window like this one, you only need to get an earlier version, for me worked out with Firefox 3.5.7. I even tried an upper version, but it did not work out. I guess there are some troubles
with the last version of Firefox and the plugin.

That’s all, hopefully it will not take long to solve the problem.
March 5th, 2010 — GNU/Linux
If you want to be able of exporting your X system in another computer, you should keep an eye on this:
vi /etc/gdm/custom.conf
[xdmcp]
Enable=true
[security]
DisallowTCP=true
AllowRemoteRoot=true
After adding up the above lines:
# gdm-restart
Now in your client:
X -query :1
Somehow it can be unsafe to leave available the root access , so I won’t make that decision for you. : )
February 4th, 2010 — Networking
Sometimes I go to visit my parents ( I’m a good son ), so that they have their own wireless network and I have mine. Whether you want to connect both just doing one
configuration keep an eye on the following steps:
/etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid=”MyParentsNet”
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk=”passowrd_parents”
id_str=”work” # Tha’ts an ID.
}
network={
ssid=”Home”
key_mgmt=WPA-PSK
proto=WPA2
pairwise=TKIP
group=TKIP
psk=”password_home”
id_str=”home” # And that’s another ID
}
Adding a few lines to the next file:
/etc/network/interfaces
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface home inet dhcp
iface work inet dhcp
It’s important to set the interface to manual, don’t forget to give an “id_str” for each network, you can add a static configuration instead of dhcp :
iface work inet static
address 10.10.20.2
gateway 10.10.20.1
netmask 255.255.255.0
If you get some problem, please take a look in /usr/share/doc/, it’s really useful because it’s always there, you do not need memorize almost anything.
August 6th, 2009 — LVM
I usually have my home directory in a different partition.Last week I had to reinstall my Debian, so I decided to add a little bit of security for data losing. I used two disks and afterwards I migrated the data from the old home to the mirror.
I encourage recommend people do this, because is easier than it seems, and will not take more than ten minutes.
Before doing anything , it is needed download lvm2 package, and that is easy with Debian:
hlab:# aptitude install lvm2
Now it should be prepared two hard drives with exactly the same partition table, so here is the way :
hlab:# sfdisk -d /dev/sda | sfdisk /dev/sdb
This will make the second disk’s partition table /dev/sdb identical to the the first hard drive /dev/sdb.
hlab:/mnt/vdata# sfdisk -d /dev/sda
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
# partition table of /dev/sda
unit: sectors
/dev/sda1 : start= 63, size=976768002, Id= 5
/dev/sda2 : start= 0, size= 0, Id= 0
/dev/sda3 : start= 0, size= 0, Id= 0
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start= 126, size=238275954, Id=83
/dev/sda6 : start=238276143, size=738491922, Id=83
- Physical volumes
The first thing is to add physical volumes , and by physical I mean, either partitions or whole disks, here is the way:
hlab:# pvcreate /dev/sda5 /dev/sdb6
It’s suitable to check the results:
hlab:#pvdisplay
— Physical volume —
PV Name /dev/sda5
VG Name volhome
PV Size 113.62 GB / not usable 1.68 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 29086
Free PE 926
Allocated PE 28160
PV UUID 1ZPA7A-gXwn-O0G6-my3b-PUVt-mk9o-0A4sW1
— Physical volume —
PV Name /dev/sdc5
VG Name volhome
PV Size 113.62 GB / not usable 1.68 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 29086
Free PE 926
Allocated PE 28160
PV UUID 0DfPHc-tXBn-dcYR-yKag-EL7j-RI4A-K9Eo0j
- Volumes groups
The above step is just a conventionality ( I see it like that) for telling that you have available some partitions or disks. Now you can create some volumes, which will appear in /dev/volname, just take a look to the command:
hlab:# vgcreate -A y vols /dev/sda5 /dev/sdb5
-A y indicates we want to use autobackup functionality.
As usual in the above examples , you can list the result with vgdisplay
If you are familiarized with ZFS, at this point we have like zfs pool.
- Logical volumes
Now is the time for setting the mirror. Here is the command
hlab:# lvcreate -m1 (–nosync) -L 110G –mirror-log core -n home vols
-m1: indicates mirror
–nosyn: if there is data, no sync.
-L: size of partition
–mirror-log core:But default you need a third partition for keeping the logs, so instead of creating another partition, I decide to do not do it.
-n: name of the the logical volume.
vols: name of the volume group.
At this point is possible to show the created mirror, so here is the command:
hlab:# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
home vols mwi-ao 110.00G 100.00 home_mimage_0(0),home_mimage_1(0)
[home_mimage_0] vols iwi-ao 110.00G /dev/sda5(0)
[home_mimage_1] vols iwi-ao 110.00G /dev/sdc5(0)
The interesting part here, is the meaning of the attributes, you can make it out by means of “man”:
m: mirror, if the letter was capitalized it would mean that was used the option –nosync. In this case I had not any data.
w: indicates the volume is writable. If it appears a “r” the volume is read-only.
ao: Partition is actived(a). Device is open(o).
- Data migration
Well, this is the last point, and know only is needed to copy the home data and add a line to /etc/fstab for getting the mirror working out. Instead of using a command such as cp -R I prefer using tar, because is cleaner and will copy absolutely all the files, here is the command:
First move your old home
hlab:# mv /home /home_tmp
Second mount the partition
/etc/fstab
/dev/vols/home /home auto rw
hlab:# mount -a; cd /home_tmp
hlab:# tar cvf – . (cd /home; tar xvf -)
In resume, having a mirror with LVM is cheap and pretty straightforward. Besides you never know when Murphy’s law can act, so it is better being one step ahead.