cd //

Date June 9, 2011

Today @work, i typed the following command by mistake: cd // the funny thing it worked and gave me that i'm in // path!! 🙂 shaker-vm2 // $ cd // shaker-vm2 // $ pwd // i don't know if its normal thing, after all, good to know!

Installing Gentoo at Tilaa.nl VPS Hosting

Date December 14, 2010

UPDATE, Tilaa now have Native Gentoo Support starting from August, so no need to follow this method as updated in the comments. Last week, i ordered a VPS from Tilaa.nl for testing, they use KVM Virtualization, IPv6 support and prices are good, also traceroute to middle east seems to be better than other locations, so that pushed me to test.., but suddenly they didn't support Gentoo, after contacting the support, they seems will support Gentoo Next couple of months, anyway i like to use Gentoo, so i wrote the following steps to get Gentoo Installed and Running at your VPS @Tilaa.nl ... First, we need to resize the current disk to install gentoo in a new partition, i used to compile gentoo kernel with support for virtio modules to get network, after that, i add resize2fs, fdisk commands to initramfs with the modules need to get the disk and network, in this way, i just need to boot to this kernel and resize the current big root partition which i can't shrink while using it!, you can download them from the following links:
http://sqawasmi.com/files-mix/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 http://sqawasmi.com/files-mix/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
NOTE: This steps works for me, There is no guarantee that this steps will work with you, you may Lose all of your VPS Data, use this steps on your responsibility.. NOTE: IF you are not familiar with shrinking ext3, then i suggest to stop reading!, the following tutorial may help: http://www.howtoforge.com/linux_resizing_ext3_partitions * after downloading them to your VPS, follow the following steps.. * cp kernel/initramfs to current distro /boot/
cp kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6  /boot/ cp initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz /boot/
* then edit /boot/grub/menu.lst to add the following
title Gentoo Install root (hd0,0) kernel /boot/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 ro root=LABEL=/notexist console=tty0 console=ttyS0,115200 notsc divider=10 initrd /boot/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
* From tilaa Dashboard, browse to your VPS and open the VPS serial console, after that do a reboot for the VPS from CLI:
[root@m1 ~]# reboot Broadcast message from root (pts/0) (Tue Dec 14 19:12:39 2010): The system is going down for reboot NOW! [root@m1 ~]# Connection to 46.19.32.39 closed by remote host. Connection to 46.19.32.39 closed.
* Now, at the console window, choose Gentoo Install (or the name you wrote in grub as title for Gentoo Boot), after the kernel boot, you should get the following message:
!! Could not find the root block device in LABEL=/notexist. Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip... root block device(LABEL=/notexist) ::
* so just type shell and hit enter to use shell, here we will start the resizing (i resized root partition to 3G, leaving the rest for Gentoo):
!! Block device sh is not a valid root device... !! Could not find the root block device in . Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip... root block device() :: shell To leave and try again just press <Ctrl>+D BusyBox v1.7.4 (2010-12-09 17:35:51 EET) built-in shell (ash) Enter 'help' for a list of built-in commands. /bin/ash: can't access tty; job control turned off # # # fdisk -l Disk /dev/vda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000563f9 Device Boot Start End Blocks Id System /dev/vda1 * 1 2611 20971488+ 83 Linux Disk /dev/vdb: 1073 MB, 1073741824 bytes 139 heads, 8 sectors/track, 1885 cylinders Units = cylinders of 1112 * 512 = 569344 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00093111 Device Boot Start End Blocks Id System /dev/vdb1 1 1886 1048575+ 82 Linux swap / Solaris # resize2fs /dev/vda1 3G resize2fs 1.41.12 (17-May-2010) Please run 'e2fsck -f /dev/vda1' first. # e2fsck -f /dev/vda1 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /: 31369/5207040 files (1.0% non-contiguous), 406948/5242872 blocks # resize2fs /dev/vda1 3G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/vda1 to 786432 (4k) blocks. The filesystem on /dev/vda1 is now 786432 blocks long.
**** Note what i colored by red: 786432 (4k) blocks -- you will use this to do the correct fdisk or you will lose your system!, the output in your case should be different from mine, so copy the number of blocks  that you got because you will use them in calculating the new size later, if you didn't do that, then i suspect that you will lost the system.. * Now shutdown your VPS from tilaa website and start it again to boot into your old Distro.. (it may take a little of time to shutdown/start) * Ok, if you are lucky (seems i was) you will get your old distro, login to it through ssh, now you need to do the main part, fdisk:
[root@m1 ~]# fdisk -l Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1   *           1        2611    20971488+  83  Linux Disk /dev/vdb: 1073 MB, 1073741824 bytes 139 heads, 8 sectors/track, 1885 cylinders Units = cylinders of 1112 * 512 = 569344 bytes Device Boot      Start         End      Blocks   Id  System /dev/vdb1               1        1886     1048575+  82  Linux swap / Solaris [root@m1 ~]# fdisk /dev/vda The number of cylinders for this disk is set to 2610. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1   *           1        2611    20971488+  83  Linux Command (m for help): d Selected partition 1 Command (m for help): n Command action e   extended p   primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +3303014K
* as you can see i entered +3303014K as last Size, i calculated this from 786432 (4k) blocks (the output of previous resizefs command) as the following:
(786432 * 4096 * 1.05) /1024 = 3303014.4000000004
* SO USE THIS To calculate the expected Size (Change 786432 to the number of blocks you got from your resizefs command) * After that continue creating the new partition..
Command (m for help): p Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1               1         412     3309358+  83  Linux Command (m for help): n Command action e   extended p   primary partition (1-4) p Partition number (1-4): 2 First cylinder (413-2610, default 413): Using default value 413 Last cylinder or +size or +sizeM or +sizeK (413-2610, default 2610): Using default value 2610 Command (m for help): p Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1               1         412     3309358+  83  Linux /dev/vda2             413        2610    17655435   83  Linux Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1   *           1         412     3309358+  83  Linux /dev/vda2             413        2610    17655435   83  Linux Command (m for help): Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@m1 ~]# sync
* when you finish, reboot to get the new partition synced:
root@m1 ~]# reboot Broadcast message from root (pts/0) (Tue Dec 14 19:37:32 2010): The system is going down for reboot NOW! [root@m1 ~]# Connection to 46.19.32.39 closed by remote host.
* Ok, now after the reboot, login to your VPS through ssh and check the disks:
shaker ~ $ ssh root@46.19.32.39 Last login: Tue Dec 14 19:35:38 2010 from 79.134.143.45 [root@m1 ~]# fdisk -l Disk /dev/vda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot      Start         End      Blocks   Id  System /dev/vda1   *           1         412     3309358+  83  Linux /dev/vda2             413        2610    17655435   83  Linux Disk /dev/vdb: 1073 MB, 1073741824 bytes 139 heads, 8 sectors/track, 1885 cylinders Units = cylinders of 1112 * 512 = 569344 bytes Device Boot      Start         End      Blocks   Id  System /dev/vdb1               1        1886     1048575+  82  Linux swap / Solaris
* So, now you have vda1 and vda2 !, now you can do mkfs.ext3 /dev/vda2 and continue installing your Gentoo from Stage3, as documented, everything should be easy:
[root@m1 ~]# mkfs.ext3 /dev/vda2 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 2207520 inodes, 4413858 blocks 220692 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 135 block groups 32768 blocks per group, 32768 fragments per group 16352 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 26 mounts or 180 days, whichever comes first.  Use tune2fs -c or -i to override.
* I always follow the instructions documented in http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=5 * anyway, the following are the steps in general:
# mkdir /mnt/gentoo && mount -t ext3 /dev/vda2 /mnt/gentoo && cd /mnt/gentoo/ && wget http://mirror.leaseweb.com/gentoo/releases/amd64/current-stage3/stage3-amd64-20101211.tar.bz2 && wget http://mirror.leaseweb.com/gentoo/snapshots/portage-latest.tar.bz2 [root@m1 gentoo]# cd /mnt/gentoo/ && time tar xjf stage3-amd64-20101211.tar.bz2 && time tar xjf portage-latest.tar.bz2 -C user/ [root@m1 gentoo]# echo 'GENTOO_MIRRORS="http://mirror.leaseweb.com/gentoo/"' >> etc/make.conf [root@m1 gentoo]# cp /etc/resolv.conf etc/ [root@m1 gentoo]# mount -t proc none /mnt/gentoo/proc [root@m1 gentoo]# mount -o bind /dev /mnt/gentoo/dev [root@m1 gentoo]# chroot /mnt/gentoo/ /bin/bash m1 / # PS1='\[\033[01;31m\]\h - chroot\[\033[01;34m\] \W \$\[\033[00m\] ' m1 - chroot / # emerge --sync
* I use distcc, that will reduce the time used to compile packages by distributing compilation over other servers, at my VPS i allowed all 10.0.0.0/8 network to use my server as distcc to help them finish the compilation (btw, as of this writing, you should use gcc-4.4.X becuase that what i use at my distcc server), if you wanna use my VPS, then do the following or you can skip this if you don't need my VPS support..:
m1 - chroot / # USE='-*' emerge --nodeps sys-devel/distcc m1 - chroot / # distcc-config --set-hosts "10.0.0.252"
* Finally, i install vim and openssh and configure the network so it be accessible after reboot (i continue the installation of Gentoo from Gentoo itself!):
m1 - chroot / # emerge vim openssh
* Run openssh at boot:
m1 - chroot / # rc-update add sshd  default
* Uncomment s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100    in /etc/inittab   to get Console access. * Add Your IP and Gateway to /etc/conf.d/net ,, i have the following, change IPs to yours:
modules=( "ifconfig" ) config_eth0=( "46.19.32.39 netmask 255.255.255.0" ) routes_eth0=( "default via 46.19.32.1"           # IPv4 Default route "default via 2001:1af8:3100:b000::1" # IPv6 Default route )
* Add a root password.. * Add a correct /etc/fstab file, simply i used to copy it from my current Distro (CentOS) and changing LABEL=/ to /dev/vda2 , the following is mine:
[root@m1 ~]# cp /etc/fstab /mnt/gentoo/etc/fstab cp: overwrite `/mnt/gentoo/etc/fstab'? y [root@m1 ~]# perl -p -i -e 's|LABEL=/|/dev/vda2|' /mnt/gentoo/etc/fstab [root@m1 ~]# cat /mnt/gentoo/etc/fstab /dev/vda2                 /                       ext3    defaults        1 1 tmpfs                   /dev/shm                tmpfs   defaults        0 0 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0 sysfs                   /sys                    sysfs   defaults        0 0 proc                    /proc                   proc    defaults        0 0 UUID=358a1f7f-27bf-43f9-aefd-b3203669539b swap                    swap    defaults        0 0
*** Finally don't forget to edit Grub and have your Gentoo listed, i have the following:
title Gentoo root (hd0,0) kernel /boot/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 ro root=/dev/vda2 console=tty0 console=ttyS0,115200 notsc divider=10 initrd /boot/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
* Open the Console & Reboot.. * after logging to the server through ssh, activate eth1 by your private IP, i used the following command:
ifconfig eth1 10.0.0.252 netmask 255.0.0.0
* Continue Installation for gentoo just as the manual & Have Fun!

qemu/kvm tap networking

Date January 6, 2010

The following is the commands to create a virtual bridge and virtual interfaces so you can use it with kvm/qemu tap networking, Actually i think you can do all of this using a GUI interface via Virtual Machine Manager (virt-manager), but i don't know why i feel its difficult to use it, anyway. You will need a tun enabled kernel, also tunctl and bridge-utils packages are installed in your system, in Fedora 12 i used yum to install them:
yum install bridge-utils.`uname -m` tunctl.`uname -m` -y
For tun support in your kernel, you can modprobe tun and see the result, or checking the config file under /boot/ for CONFIG_TUN, for example in fedora:
[root@shaker-testing ~]# egrep '^CONFIG_TUN' /boot/config-2.6.31.9-174.fc12.x86_64 CONFIG_TUN=m
anyway you do it, just make sure exist and probed (lsmod | grep tun) Finally here is the commands to create the virtual interface and virtual switch:
[root@shaker-testing ~]# tunctl -b -u root -t tap0 tap0 [root@shaker-testing ~]# brctl addbr testing-br [root@shaker-testing ~]# brctl addif testing-br tap0 [root@shaker-testing ~]# brctl addif testing-br eth0 [root@shaker-testing ~]# ifconfig tap0 0.0.0.0 promisc up [root@shaker-testing ~]# ifconfig eth0 0.0.0.0 promisc up [root@shaker-testing ~]# ifconfig testing-br 192.168.0.1 netmask 255.255.255.0 [root@shaker-testing ~]# brctl show bridge name    bridge id        STP enabled    interfaces testing-br        8000.0019d13401c0    no        eth0 tap0
thats all, btw, 192.168.0.1 was my eth0  IP Address, you have to give it to your virtual bridge. now run your machine, i usually run it as followes:
qemu -hda /storage/testing1.img -m 256 -net nic,macaddr=00:1d:92:ab:3f:80 -net tap,ifname=tap0,script=no -alt-grab -vga std -name Testing1 -boot c -vnc :0
and then i login to it using vncviewer (i used -vnc :0 in the options) to configure its IP Address.. for example, if you are connecting/using it in localhost then i use:
vncviewer localhost:5900
or you can delete '-vnc:0' so you don't use vnc at all..

ping tip: CTRL + \ (backslash)

Date September 28, 2009

I were checking one of the servers connectivity using ping, usually i use CTRL + \ (backslash) to send a quit signal for applications i run in terminal, but ping responded to the signal by showing ping status:
64 bytes from x.x.x.x: icmp_seq=1253 ttl=47 time=433 ms 64 bytes from x.x.x.x: icmp_seq=1254 ttl=47 time=239 ms 64 bytes from x.x.x.x: icmp_seq=1255 ttl=47 time=359 ms 1255/1216 packets, 3% loss, min/avg/ewma/max = 221.050/393.449/357.675/977.157 ms 64 bytes from x.x.x.x: icmp_seq=1256 ttl=47 time=325 ms 64 bytes from x.x.x.x: icmp_seq=1257 ttl=47 time=411 ms 64 bytes from x.x.x.x: icmp_seq=1258 ttl=47 time=260 ms 64 bytes from x.x.x.x: icmp_seq=1259 ttl=47 time=275 ms
Pressing CTRL + \ while using ping will show ping status.

Installing PPTP Client in Fedora 11

Date September 27, 2009

Usually, When i wanna connect to online servers for checking them or whatever, I ssh to my work PC then to them, unfortunately our main gateway is down today. So i tried another solution which is trying our work VPN connection, Network Manager didn't help me or maybe i didn't know how to configure it (i don't like it!), the other solution was PPTPConfig, i tried it before and it worked perfectly, To install it in Fedora just follow the following steps as root:
[root@localhost ~]# rpm -Uhv http://pptpclient.sourceforge.net/yum/stable/fc11/pptp-release-current.noarch.rpm [root@localhost ~]# yum install pptpconfig
now just run pptpconfig as root and configure your VPN connection..

Tornado, the real-time web server that powers FriendFeed, now open source.

Date September 11, 2009

Facebook announced Tornado as new open source web server framework, it can be used to serve thousands of simultaneous connections, its high performance is really interesting, i think ill test it in the coming days. checkout the following links: http://developers.facebook.com/news.php?blog=1&story=301 http://bret.appspot.com/entry/tornado-web-server friendfeed website: http://friendfeed.com some details: Tornado is a non-blocking Web server framework written in Python, designed to handle thousands of simultaneous connections, making it ideal for real-time Web services. Some of the distinctive features of Tornado:
  • All the basic site building blocks - Tornado comes with built-in support for a lot of the most difficult and tedious aspects of web development, including templates, signed cookies, user authentication, localization, aggressive static file caching, cross-site request forgery protection, and third party authentication like Facebook Connect. You only need to use the features you want, and it is easy to mix and match Tornado with other frameworks.
  • Real-time services - Tornado supports large numbers of concurrent connections. It is easy to write real-time services via long polling or HTTP streaming with Tornado. Every active user of FriendFeed maintains an open connection to FriendFeed's servers.
  • High performance - Tornado is pretty fast relative to most Python web frameworks. We ran some simple load tests against some other popular Python frameworks, and Tornado's baseline throughput was over four times higher than the other frameworks: 

not enough B12

Date June 20, 2009

Two days ago i checked my B12 Vitamin, and as expected it wasn't enough so the Dr suggested to take one injected and then i have to take drugs course, so as suggested i started by taking the injected and here we go; it really did effect, and i started to be more active, feel in power to live and accurate but the more stupid thing it did is i started to remember things i tried to forget 🙁 , anyway ... feeling great 😉

back

Date May 15, 2009

whoops finally i feel am free,, for more than 2 months, am recalculating everything in my mind, and how the work was so much heavy those two months,, maybe a lot of you noticed i deleted a lot of posts, anyway, finally i just feel like i never tired before. I just started to play with nextgen-gallery, the plugin for wordpress which i installed before a year ago, it really seems nice, i have uploaded  my Wadi-Ram and Aqaba trip that i did before 2 months ago,  the thing that i really like is [View with PicLens],, its really nice feature, to view the gallery just click on the above picture. i have 3 days holiday next week, what will be next in this gallery 😀 .

Linux examination machine

Date March 4, 2009

Two days ago i did a nice interview, it was interactive exam, someone ask you through the phone to troubleshoot/do many things and in the same time he see what you do and what is the output of your commands, in my company, when i was interviewing people, all what i do is oral questions.. its oral conversation, but after making that interview i decided to prepare a examination machine to use it for future interviews i do in the company i work in. the trick was using SCRIPT(1) and named pipe (fifo), simply like this: in the first session do this command: $ mkfifo foo; script -f foo in another session do cat for 'foo' $ cat foo and now you will see everything done in the first session, yup so nice. to use it when the user login (for ex/ through ssh), you can put it on .bashrc file for that user, for example put those at the end of .bashrc file: if [ ! -p /tmp/`whoami` ] then mkfifo /tmp/`whoami` ; fi exec script -f /tmp/`whoami` thats it, now after user login, do cat /tmp/UserLoginName in your session 😉

inittab to auto restart script

Date February 2, 2009

Do you have a script/application that you want it running all the time, if it crashed then it auto restrart, auto launch on reboot ?, I have a php script that must run all the time, it do telnet to a port on another server and do some commands on that port... anyway i want this to be running all the time, i did it easily using respawn in inttab, this is the steps: idlE ~ # vi /etc/inittab at the end of the file add the following:
ax:2345:respawn:/root/scripts/sendSMS.sh
change /root/scripts/sendSMS.sh to your script/application path, then save and quit. now you need to reread inittab file using the following command:
idlE ~ # init q
thats all, check the running process.