Howto switch from Ubuntu to Debian – My Experience – Part II

continued…

Once I get the base system installed, I tried to hang around pure commandline for sometime, I installed the following package to hang around,

$ su -c'apt-get install elinks'

Before going into aptitude for the final phase of my installation, I configured ‘contrib’ ‘nonfree’ and ‘multimedia’ repos by creating two more files in ‘/etc/apt/sources.list.d’ directory as below,

$ cat /etc/apt/sources.list.d/nonfree.sources.list 
deb http://ftp.iitm.ac.in/debian/ lenny contrib non-free
deb-src http://ftp.iitm.ac.in/debian/ lenny contrib non-free

deb http://security.debian.org/ lenny/updates contrib non-free
deb-src http://security.debian.org/ lenny/updates contrib non-free

deb http://volatile.debian.org/debian-volatile lenny/volatile contrib non-free
deb-src http://volatile.debian.org/debian-volatile lenny/volatile contrib non-free
$

and

$ cat /etc/apt/sources.list.d/multimedia.sources.list 
deb http://mirror.optus.net/debian-multimedia/ stable main
deb-src http://mirror.optus.net/debian-multimedia/ stable main
$

To use multimedia repo, we also need to install the gpg-key package using the following command,

$ wget http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2008.10.16_all.deb
$ su -c'dpkg -i debian-multimedia-keyring_2008.10.16_all.deb'

Debian multimedia website provides more details, check this link http://www.debian-multimedia.org

At the end, I started aptitude and installed all my must needed packages(Xfce,built-essential, gcc, vim-full, nvidia-glx, flash-10, mplayer, ffmpeg, w64codecs etc).

I don’t want to run any services in my laptop, so I disabled all the default services in lenny(like exim4, avahi, gdm etc.,). The base system run with just ~34MB, Once I ‘startx’, it goes to ~140MB, If I start ‘icewesel’, it goes to ~314MB. I never thought I can run a full fledged system with this kind of less memory. No pause on Boot(just taking 10-12 sec to print login prompt)

Now, I’m really happy. I never expected the switch is this much smooth. Thanks to Debian.

Advertisements

Howto switch from Ubuntu to Debian – My Experience – Part I

Hi,

After long time I’m posting this. In this time, I got a fantastic experience of switching myself from ubuntu to debian. Reasons? may be silly but here they are,

1. From 8.10, I had a tough time with all the kernel’s ubuntu shipped and updated into my laptop, I was hit by a kernel acpi bug (http://bugzilla.kernel.org/show_bug.cgi?id=11727) which still exists(in i686, not in x86_64). It pauses boot process when my laptop runs in battery and I need to press until init starts.

2. Nowadays, I hate the idea of ‘linux for everyone’. because ‘*nix’ systems are not for everyone. its for the one who like to learn computing.

3. My laptop lost DVD drive.

So I was in a mood to switch myself to something else. While surfing, I came to the debian website, their Installation guide explains howto install debian from a USB drive. Mine is Athlon64, so this time I went for x86_64. First I prepared my pendrive. For that we need to partition it using ‘fdisk’

$ sudo fdisk /dev/sdb

You can do this by running system->administration->partition-editor in Ubuntu. Once you created a new partition in your pendrive(/dev/sdb1), you need to format the partition as FAT32 using the following command

$ sudo mkfs -t vfat /dev/sdb1

Once you formatted, the next step is to install ‘syslinux’ into it, If your Ubuntu don’t have ‘syslinux’ command, install ‘syslinux’ package

$ sudo apt-get install syslinux
$ sudo syslinux /dev/sdb1

Now its time to download the installation files, I copied all the files from the following location and copied into /dev/sdb1. Finally the drive will look like this,

$ find /media/disk
.
./gtk
./gtk/vmlinuz
./gtk/initrd.gz
./syslinux.cfg
./vmlinuz
./initrd.gz
./ldlinux.sys
./MANIFEST
./boot.img.gz
$

And it is capable of booting using ‘syslinux’ bootloader. To use Graphical Installer, we need to modify ‘syslinux.cfg’ to look like this

default gtk/vmlinuz
append initrd=gtk/initrd.gz video=vesa:ywrap,mtrr vga=788

Once your pendrive is ready, unmount it and reboot the system, change the Boot order(In Compaq, press F9) and select the USB drive. The debian-installer will start asking questions, there on, its an easy ride. I didn’t install Gnome/Kde when the installer asked to choose one. I was interested in Xfce, so I postponed it.

In next post, I’ll tell you how I installed the 3rd layer(desktop).

will continue..

Starting Another X Server with Different Locale – Ubuntu

Hi,

While playing with quemu+lfslivecd under ubuntu, I came to know about the following commands which sets the locale environment for a linux system(atleast for lfslivecd). Using the following steps, I’ll share the commands and start a new X server with the modified environment.

1. Press ‘ctrl+alt+F1’ to go to virtual terminal 1 or ‘tty1′(To switch back to current gnome session, use ‘ctrl+alt+f7’). Login to that terminal with different userid then the current userid who already logged into current gnome session.

2. type the following command to set the timezone. you can see the timezone data file in /usr/share/zoneinfo/posix/{continent}/{country} where {continent} is the name of your continent like ‘Europe’, ‘Asia’ etc., and {country} is your country name. This file should be pointed by TZ environment variable. The below command will change Timezone to ‘Europe/Spain’.

$ export TZ="Europe/Spain"
$ date

The date command will show the date according to the new timezone.

3. ‘localedef’ command is used to create binary definitions in /usr/lib/locale directory from /usr/share/i18n/ directory, the ‘i18n’ directory contains ‘charmaps’ directory which contains encodings(like ‘UTF-8’ etc). ‘i18n’ also contains ‘locales’ directory which contains definitions for locales. ‘localedef’ will use these two directories to generate a definiton for particular language termed in ‘{LANG}_{COUNTRY}.{ENCODING}'(eg: es_ES.utf8 – means language code ‘es'(spanish), country ‘ES'(spain) and encoding in ‘utf8’). The following command will compile language definition for spanish language in ‘utf8’ encoding.

$ sudo localedef -f UTF-8 -i es_ES --no-archive es_ES.utf8'
$ locale -a | grep 'es_ES.utf8'

‘locale -a’ will show whether language definition added or not.

4. Now we are ready to change the LANG variable, this variable is used by all ‘glibc’s language aware’ applications to switch their output to a particular language, the ourput strings for a particular application for a particular language should be available in ‘{application}.mo’ file inside /usr/share/locale/{LANG}/LC_MESSAGES directory(Distros provide ‘.mo’ files through language specific packages). Now switch the glibc applications to spanish using the following command,

$ export LANG="es_ES.utf8"
$ locale

‘locale’ command will tell the current language.

5. Finally start a new X server using the following command with modified locale. You can switch back to old X server using ‘ctrl+alt+F7’. To switch to new X server, use ‘ctrl+alt+F9′(or ‘ctrl+alt+F10’ if it started in ‘tty10’ virtual terminal)

$ startx -- :1 -br -audit 0 -nolisten tcp 

At first, it will ask to change the name of the directories to suite the new language, don’t rename unless you always going to work in the new locale environment.

6. Once you done, ‘Logout’ from the New X server(new gnome session), it will stop the newly started ‘X server’ and put you in ‘tty1’ virtual terminal. ‘exit’ command will exit you from the tty1 terminal. Finally, switch back to old X server’s gnome session using ‘ctrl+alt+F7’.

Thats all.

Xml2Line – Tag to line converter

Hi all,

Here is a simple converter I was able to write using libexpat library,

http://github.com/mohan43u/Xml2Line

Whenever I’m playing with ‘identi.ca’ with its API’s I’m thinking about a good converter which will convert the XML data to a reliable format which other unix tools(grep, sed, awk) can work on. And here is my first step towards that one.

After a further research I came to know about YAML, need to learn further about it, let see how it goes.

Till I find a better one, my ‘grep’ will depend on ‘Xml2Line’. If you know a better tool to help the unix tools, kindly post here.

Qemu Networking (Tun/Tap)

Hi friends,

Setting up networking in Qemu instance is very simple if you are using ‘user mode’ networking stack. And most of us don’t care about Full fledged networking while using Qemu Guests. But configuring Network in Qemu with full access requires TUN/TAP configuration.

Here is some simple steps which I did to configure TUN/TAP in Ubuntu 9.04,

Inside Ubuntu(Host), type the following commands:

$ sudo apt-get install qemu kqemu-common kqemu-source
$ wget ftp://ftp.osuosl.org/pub/lfs-livecd/lfslivecd-x86-6.3-r2145-min.iso
$ sudo qemu -cdrom lfslivecd-x86-6.3-r2145-min.iso -boot d -kernel-kqemu -m 512 -net nic -net tap &
$ sudo ifconfig tap0 192.168.10.1
$ sudo sysctl -w net.ipv4.ip_forward=1
$ sudo iptables -t nat -A POSTROUTING -j MASQUERADE
$ sudo iptables -t filter -P FORWARD ACCEPT

Inside lfslivecd(Guest) type the following commands:

$ ifconfig eth0 192.168.10.2
$ route add default gw 192.168.10.1
$ cat > /etc/resolv.conf <<EOF
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF
$

Ofcourse, you can use any distro as a guest in qemu. Enjoy Qemuing.

Share your Qemu Guest with your Friends

Hi friends,

Don’t know about the how useful it will be, but I found some way to enable my friends to access my Qemu Guest Instance running LFSLiveCD in Ubuntu Host using ‘ssh’. Here is the steps I did,

1. Download Qemu Packages

$ sudo apt-get install qemu kqemu-common kqemu-source

2. Download LFSLiveCD from here

3. Now start the LFSLiveCD guest using the following command

$ qemu -cdrom lfslivecd-x86-6.3-r2145-min.iso -boot d -m 512 -net nic -net user -redir tcp:35000::22

4. Now Qemu will start ‘LFSLiveCD’ with user mode network stack, that is, from LFSLiveCD, ip 10.0.2.2 will be the Default gateway and DHCP server. ip 10.0.2.3 will be the DNS server and the LFSLiveCD will get 10.0.2 15. If you look ‘netstat’ output in Host(here Ubuntu), there will be a line which tells port ‘35000’ is listening. Qemu process is listening in that port, it will redirect connections from Host(Ubuntu’s) 35000 port to Guest(LFSLiveCD’s) 22(ssh) port. All we need to do is, start ‘ssh’ service in LFSLiveCD Guest. Type the following command in Qemu.

[root:]# cd /etc/rc.d/init.d
[root:]# ./sysklogd start
[root:]# ./sshd start
[root:]# passwd
New Password: [newrootpassword]
Retype New Password: [newrootpassword]
[root:]# tail -f /var/log/*.log

Now you have ‘sshd’ running in the guest, and you also changed the ‘root’ password to a known password. All you need to do is, ask your friends to ‘ssh’ to your Host’s(Ubuntu) ip address but with ‘35000’ port instead of default ’22’ port. And ask them to login as ‘root’ as userid and ‘[newrootpassword]’ as password. Your friends will be so much happy to see thay are became ‘root’. In the mean while you can also login to your guest with ‘ssh root@127.0.0.1 -p 35000’. If you want, add a new user and share that userid and password to your friends, so that they can have less power.

Instead of Ubuntu Host, We can do this in Windows XP, as a Normal powerless user. The below thing you need to do,

1. Download QemuManager Zipfile Edition from here.
2. Download LFSLiveCD from here.
3. Configure LFSLiveCD inside QemuManager(follow this Guide).
4. While configuring Network, DoubleClick ‘NetWork Card 1’, GoTo Port Redirectors tab, type ‘35000’ in ‘Port Visible to Host’ and ’22’ in ‘Port Visible On Guest’ and click ‘Add’ button.
5. Start ‘LFSLiveCD’ Qemu Guest. and Do all changes I explained above to start ‘sshd’ inside LFSLiveCD.
6. Download ‘Putty.exe’ from here.
7. Start ‘Putty.exe’ with Host as ‘127.0.0.1’ and Port as ‘35000’ and Connection Type as ‘ssh’.
8. Login with ‘root’ as username and ‘[newrootpassword]’ as your password.
9. If you want to share your Qemu Guest, with your windows friends who’s machines and your’s machine are in same subnet, then ask them to start ‘putty.exe’ with host as your machine’s ip address, port as ‘35000’, username as ‘root’ and password as ‘[newrootpassword]’. You can also create seperate ‘user’ in your Guest(LFSLiveCD) and share with your friends.
10. Enjoy Virtualization.

I also tried this method in my friend’s Vista laptop, but it failed!! First, it is not allowing to run QemuManager.exe as a normal user, Second, it is giving warning while opening ‘35000’ as listening port, Finally, ‘putty.exe’ is not at all connecting to Guest Instance, even though ‘sshd’ is running in the LFSLiveCD Guest. If anyone have success story, kindly share.

Finally Thanks to my company for blocking access to the linux learning server, which make me to go for alternate methods and finally endup in the Windows XP method.

Upstart, update-identica and my blog

Hi friends,

‘Curl’ is one of the fantastic tool I’m using day to day. and Upstart is one good upgrade to the long standing ‘rc.*’ method to start and stop services. While learning TwitterAPI to interact with ‘identi.ca’, I got an idea to update my laptop’s CPU usage to the ‘identi.ca’ feed whenever my system starts and attach that feed into my blog. Well, It developed into something usable now. here is the script

#!/bin/bash
# update-identica - script to update my identi.ca feed

USERID=""
PASSWORD=""
BASEURL="http://identi.ca/api"
UPDATEAPIURL="/statuses/update.xml"
UPDATEURL="${BASEURL}${UPDATEAPIURL}"
MAXMESSAGES="10"
LOGFILE="/var/log/update-identica.log"
LOGFILESIZE=$(du -sb "${LOGFILE}" | awk '{print $1;}')
MAXLOGFILESIZE=$((1024 * 1024))
test "${LOGFILESIZE}" -gt "${MAXLOGFILESIZE}" && rm "${LOGFILE}"
INTERVAL=$((5 * 60))

destroymessages()
{
	EXTRAMESSAGES=$((MESSAGECOUNT - MAXMESSAGES))
	EXTRAMESSAGEIDS=$(curl -u "${USERID}:${PASSWORD}" "${BASEURL}/statuses/user_timeline.xml" 2>/dev/null |
	grep '[0-9]\{7\}' | cut -d'>' -f2 | cut -d'/dev/null |
		tee -a "${LOGFILE}"
	done
}

while true
do
	MESSAGE="status="
	MESSAGE="${MESSAGE}[cpu:$(vmstat 1 2 | tail -1 | awk '{print $13+$14;}')%]"
	MESSAGE="${MESSAGE} [uptime:$(uptime | cut -d',' -f1 | tr -d ' ')]"

	curl -u "${USERID}:${PASSWORD}" -d "${MESSAGE}" "${UPDATEURL}" 2>/dev/null | tee -a "${LOGFILE}"
	MESSAGECOUNT=$(grep '' -f2 | cut -d'<' -f1)
	test "${MESSAGECOUNT}" -gt "${MAXMESSAGES}" && destroymessages
	sleep "${INTERVAL}"
done

Also call this script automatically by creating a event file /etc/events.d/update-identica

# update-identica
# a small program to update this laptop's feed in
# http://identi.ca

start on update-identica-event
start on runlevel 2
stop on runlevel [!2]
exec /usr/bin/update-identica

Download: update-identica

Take a look at the feed titled ‘My laptop’s health’ in this blog, it is the feed which my laptop is updating every 5 minutes.

If you are interested in WebAPIs and accessing through ‘curl’, then here is link, ‘lucanica(identi.ca’s software)’ also using the same REST methods to give web services.

http://apiwiki.twitter.com/Twitter-API-Documentation