Sunday, January 3, 2010

Setting up an Isolated Driver Domain in Xen

Disclaimer : This article assumes that you have some experience in compiling kernels and are familiar with installing and using Xen.

Xen has a very useful feature of Driver Domains. This post will not talk about the theory, but instead focus on setting up a Driver Domain.
Information about driver domains can be found on the Xen-wiki .

So, as mentioned on the wiki page, we basically need 3 things to setup a driver domain :
1. PCI Passthrough
2. Backend Driver
3. Hotplug scripts

One of the easiest ways to create a Driver Domain is the boot the Dom0 kernel as a DomU.
This article talks about setting up a driver domain for a PCI device. The process described below does not apply for creating a driver domain for block devices.

There are some config options that have to be taken care of.

1. Backend Driver :

The back-end driver for the device should be compiled. In this post, we will be creating a driver domain for a PCI device. Hence the PCI backend driver should be present in the DomU that is to be used as the driver domain.
Since we will be using the same kernel for Dom0 and DomU, we compile the PCI backend driver in the kernel configuration. "pciback" is the PCI backend driver. It can be compiled either as a module or built into the kernel.
I have compiled pciback into the kernel. This makes the process of passthrough extremely easy.




2. PCI Passthrough :
PCI passthrough is a feature that allows DomU to gain direct access to the physical device.
The first thing that has to be done is to compile the Dom0 kernel with PCI Passthrough enabled. This step is optional.

Compile and install the Dom0 kernel.

The first step for acheiving PCI passthrough is to find the PCI ID of the device.
The PCI ID can be found using "lspci". Once the PCI ID has been found out, follow these steps :


If pciback is built into the kernel, then add the following options to the Dom0 kernel command line, in the bootloader's config file :

pciback.permissive pciback.hide=(03:00.0)

Here, 03:00.0 is the PCI ID of the device. ( A NIC on my machine). This hides the device from Dom0. If the device is not hidden from Dom0, then Dom0 initialises the PCI device...which we do not want.

The next step is to modify the DomU's configuration file. Add the following line to expose the PCI device to the DomU that is to e used as the driver domain.

pci = [ '03:00.0' ].



Now, start the DomU. Remember to use the same Dom0 kernel for this DomU.

Once the DomU is booted, issue "lspci" from within the DomU. The PCI device should appear.

If lscpi shows the PCI device, then it has been successfully pass-throughed !

3. Hotplug scripts :

Now, to use the DomU containing the PCI device as a driver domain, we need hotplug scripts. Hotplug scripts allow other DomUs' frontend drivers to attach themselves with the backend.

The easiest way to get the hotplug scripts in the Driver Domain is to get the xen source code and do a "make install-tools" within the Driver Domain.
This should install the required hotplug scripts in the Driver Domain.

This completes the process of setting up a driver domain ! :-)

For a NIC, run the network-bridge script from /etc/xen/scripts to bring up Xen's virtual bridge in the Driver Domain.

Now, to let the other DomUs know about the driver domain, edit the configuration file of the DomU.

vif = [ 'mac=some_mac_id, backend=id_of_the_driver_domain' ]
the "backend" option identifies the Driver Domain for the DomU.
Now boot the other DomUs.
It can be verified that the vifs from the DomUs are connected to the bridge in the Driver domain,
run
$brctl show

in the driver domain.

Sunday, October 18, 2009

Xen-tools and ubuntu Dom0

Installing Xen as described here does not install the xen-tools properly. Even if the hypervisor and Dom0 are up perfectly, there is nothing more that can be done without xen-tools.

$ sudo xm list

Traceback (most recent call last):
File "/usr/sbin/xm", line 5, in
from xen.xm import main
ImportError: No module named xen.xm

Thanks to Shriniket and Hormazd for reproducing the error :-)

As described here, the solution to this problem involves editing the
Config.mk file.

The Config.mk file is in the source root directory.

The following lines (line no. 38 and 39) have to be changed from :

PYTHON      ?= python
PYTHON_PREFIX_ARG ?= --prefix="$(PREFIX)"

to :

PYTHON = python
PYTHON_PREFIX_ARG =

Save the changes. Then,

# make clean

# make install-xen

# make install-tools

# make install-stubdom


Doing
# make clean and # make install-tools might be sufficient.
Haven't tried it.


Everything should be working fine now.

Tuning Config.mk results Xen packages to be placed
into /usr/local/lib/python2.6/dist-packages due to
Changeset 19594 in xen-3.4-testing.hg.
Otherwise, Xen packages would go to
/usr/lib/python2.6/site-packages,
which is not default location for python 2.6 on Ubuntu 9.04
( as opposed to Fedora 11 ).
Thus you won’t be able to start xend in Dom0.

Cheers !

Monday, October 5, 2009

Problems with getting Xen working ...

IF you are looking for how to install Xen, you can find it here.

Trying to get Xen working , ran into some problems ...

1. There is this peculiar problem that I faced with all the kernels that I tried as Dom0.

Gave up waiting for root device. Common problems:
-Boot args (cat /proc/cmdline)
-Check root delay = (did the system wait long enough?)
-Check root=(did the system wait for the right device?)
-Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/disk/by-uuid/xxxxx-xxxx-xxxxxxxxxxxx does not exist. Dropping to shell!

Busybox v1.10.2 (Ubuntu 1:1.10.2-2ubuntu7) built-in shell (ash)
Enter 'help' for a list of built-in commands.


The hypervisor was booting fine, but the Dom0 refused to recognise my root device and would drop me into busybox.

The solution to this problem is to pass an extra parameter to the kernel, indicating that it should wait longer for the root device. (SCSI disks have this problem).
So now, you need to edit your /boot/grub/menu.lst. The parameter to be passed is "rootdelay". rootdelay=90 has worked for me. You may experiment with lower/higer values.

$sudo gedit /boot/grub/menu.lst


#######Snippet - menu.lst ###########

title Xen 3.4.0 / Ubuntu 9.04, kernel 2.6.18.8
uuid fe8adb1a-7b82-40c4-b7d9-e35921c1155f
kernel /boot/xen-3.4.0.gz
module /boot/vmlinuz-2.6.26-2-xen-686 root=LABEL=root ro console=tty0 rootdelay=90
module /boot/initrd.img-2.6.26-2-xen-686



2. The second problem that I faced was with the 2.6.18 xenified kernel. The kernel boots into busybox and the keyboard becomes totally unusable. None of the keys works.
Although I did notice that the quickplay buttons do generate an interrupt ( it shows a message on the screen when I press a quickplay button), the rest of the keys are useless.

Could not fix this :-(

3. The 3rd problem that I faced was with the 2.6.26 Debian xenified kernel, along with the first one.

ata1.00: qc timeout (cmd 0xec)
ata1.00: failed to IDENTIFY (i/o error, err_mask= 0x4)


A little googling led me to think this was an ACPI problem. So I tried passing acpi=off in the kernel cmdline, but did not work out.
Some more googling led me in various directions. Tried atleast 5 different parameters.

The one parameter that finally worked was pci=nomsi . Found it here, and oddly enough as a solution to a different problem !

Apparently this is occurs due to problem of the Debian kernel on some motherboards and is consistently reproducable.

So, the final kernel command line that works perfectly is :

/boot/vmlinuz-2.6.26-2-xen-686 root=LABEL=root ro console=tty0 rootdelay=90 pci=nomsi


Hope this helps !

Cheers ! :-)

Sunday, October 4, 2009

Installing Xen 3.4.1

Recently, there was need to install Xen on my laptop for project work.

Xen 3.3 is present in the ubuntu repositories and installation is very straight forward.

If you plan to use Xen 3.3, then the task is extremly easy.

Steps :

1.Installing the Xen hypervisor.

sudo apt-get install ubuntu-xen-desktop

2. Installing a Dom0 kernel. There are various options available.
i) You can either use the 2.6.18.8 xenified kernel available on the official website. Get it here.
ii) You can download Debian xenified kernel from here and the modules for the kernel from here.
iii) You can use download a vanilla kernel from here and patch it to work as a Dom0. You can get the patches here. Patches for version 2.6.29-6 are stable.
iv) You can download a vanilla kernel and configure it as a Dom0 using PVOPS. (There are still quite a few issues with this.)

3. Done.

Installing Xen 3.4.1 :

Detailed steps :

I am describing how to install Xen 3.4.1 from source and using the Debian xenified kernel (2.6.26) as Dom0. I compiled the 2.6.18.8 xenified kernel, but my keyboard would become unusable. I also tried patching the vanilla kernel, but ran into some problems. So I settled for the Debian xenified kernel.

Step 1: Satisfying the dependencies.

Special thanks to Furquan Shaikh, my senior, for providing me a comprehensive list of all the dependencies.

$ sudo apt-get install gcc make binutils zlib1g-dev pyhton-dev python2.6-dev python-opnessl libncurses5-dev libssl-dev xorg-dev bridge-utils iproute udev tetex-base tetex-bin latex-make texi2html texinfo texlive texlive-base gawk gettext-kde


Alternatively, you can automate the process using :
$ sudo apt-get build-dep package-anme


For more info on this, click here and here
Thanks to CDK :-)

will install all the required dependencies.



Step 2 : Downloading the latest Xen source. You can download the source from here.

Step 3 : Extract the source into a suitable directory. Then
i) # make install-xen
ii) # make install-tools
iii)# make install-stubdom

If all the dependencies were satisfied, step 3 should not give any problems at all.

Step 4 : The packages for Dom0 Debian kernel can be obtained from here and here.

Once downloaded, install the kernel using :

$ sudo dpkg -i linux-image-2.6.26-2-xen-686_2.6.26-19_i386.deb linux-modules-2.6.26-2-xen-686_2.6.26-19_i386.deb

This installs the Dom0 kernel and also updates the grub entries.

This completes installation of the hypervisor and the Dom0. Since the Dom0 kernel is 2.6.26, make sure that your root partition is not ext4. ext4 support was included since kernel 2.6.28.

Now, reboot your computer, you should boot into the Dom0 kernel if everything went right. :-)

I ran into some problems while booting the Dom0 kernel. I am posting them here.

Saturday, August 15, 2009

Adding system calls to the Linux kernel

Adding new system calls to the Linux kernel

This article talks about adding new system calls to the Linux kernel on an x86 machine , version 2.6.XX

Disclaimer : This is by no means a complete and/or definitive guide. It is based purely on whatever little experience I have.

In this article , we will implement a linked-list in the kernel space which stores one integer value per node and write new system calls to add new items to the list, delete existing items and to display the contents of the list.

Adding new system calls to the kernel involves editing some kernel files, the files that have to be edited are :

So, first of all, download a kernel source from http://kernel.org and extract in into a suitable location.

(The pathnames are relative to the source base directory)

1. /arch/x86/kernel/syscall_table_32.S

2. /arch/x86/include/asm/unistd_32.h

3. /include/linux/syscalls.h

4. /Makefile

Next, we are going to put all the new files that we create into a separate directory.

Let's call that directory as "lister" . Note that this is not at all necessary, we can simply add our system calls in the kernel/sys.c file

So, in the source base directory, we will create a directory named "lister" which will hold all the new files that we create.

The new files that we will be creating are :

5. lister/lister.c

6. lister/lister.h

7. lister/Makefile

Finally, we'll create some user-space files to test the system calls. We'll see more about these files later.

Now, lets get started !!

1. The first file to be changed is the arch/x86/kernel/syscall_table_32.S file.

This file contains the names of all the system calls, prefixed with "sys_"

Since, we will be adding 3 new system calls to the kernel, which we will be naming as listadd, listdel and listshow, we will have to append 3 lines to this file as :

.long sys_listadd

.long sys_listdel

.long sys_listshow

2. Next, we'll modify the arch/x86/include/asm/unistd_32.h file.

This file contains an unique number associated with the system call that is passed to the kernel through the EAX register (specific to x86) when a system call is invoked.

Again, we will have to append 3 lines to the file as follows :

The general structure of the line is

" #define __NR_<system_call_name><last_system_call_number +1>"

so, after adding the relevant lines to the files,the file will look somewhat like this :

----------------------- snippet ----------------------------

#define __NR_preadv 333

#define __NR_pwritev 334

#define __NR_listadd 335 /* newly */

#define __NR_listdel 336 /* added */

#define __NR_listshow 337 /* lines */

#ifdef __KERNEL__

#define __ARCH_WANT_IPC_PARSE_VERSION

----------------------- snippet ----------------------------

3. Next, we will edit the file include/linux/syscalls.h that holds the declarations of all the system calls.

We will add the declarations of our 3 system calls to this file.

For the listadd system call ,

asmlinkage long sys_listadd(int __user *);

Now the above declaration says that the listadd system call takes 1 parameter, which is a pointer, in the user-space, to an integer.

Similarly, we add the declarations of the other two system calls.

asmlinkage long sys_listdel(int __user *);

asmlinkage long sys_listshow();

4. Next, we modify the /Makefile so that the files that we will be creating in our "lister" folder get complied.

Add lister/ to core-y (Search for regex: core-y ).The "lister" directory will contain the source file, header file and the Makefile for our system call.

So, the line would look something like this :

core-y := usr/ lister/

5. Now we create a directory in the source base directory, that will hold our files that contain the code of our system calls.

Let's call that directory as "lister"

Now, we will write the actual implementation of the system calls.

It consists of making 2 files, in our case, we call those files, lister.c and lister.h

6. Create a file called lister.h .

The contents of the header file can be something like this :

------------------ LISTER.H ------------------------------

#ifndef LISTER_H

#define LISTER_H

#include<linux/list.h>

struct linked_list{

struct list_head list;

int data;

};

struct list_head linked_list;

int no_of_elements = 0;

#endif

------------------- END ------------------------------------

This header file defines the node structure of our linked-list.

It also declares the head of the linked-list (named linked_list) and a variable that holds the number of elements in the list.

7. Now, we will write the actual system calls.

We create a file called lister.c  The indentations in the code are eaten up by Blogger...

----------------------------- LISTER.C -------------------------------

#include<linux/syscalls.h>

#include<linux/list.h>

#include<linux/slab.h>

#include<linux/kernel.h>

#include<asm/uaccess.h>

#include<linux/linkage.h>

#include "lister.h"

SYSCALL_DEFINE1(listadd,int __user*,buffer)

{

int data;

struct linked_list *new = (struct linked_list*) \

kmalloc(sizeof(struct linked_list),GFP_KERNEL);

if(no_of_elements == 0){

INIT_LIST_HEAD(&linked_list);

}

get_user(data,buffer);

new->data = data;

list_add_tail(&new->list,&linked_list);

no_of_elements++;

return 0;

}

SYSCALL_DEFINE1(listdel,int __user*,buffer)

{

int data;

struct list_head *ptr;

struct linked_list *entry;

get_user(data,buffer);

if(no_of_elements > 0){

list_for_each(ptr,&linked_list){

entry = list_entry(ptr,struct linked_list,list);

if(entry->data == data){

list_del(ptr);

return 0;

}

}

}

return -1;

}

SYSCALL_DEFINE0(listshow)

{

struct list_head *ptr;

struct linked_list *entry;

if(no_of_elements > 0){

list_for_each(ptr,&linked_list){

entry = list_entry(ptr,struct linked_list,list);

printk(KERN_ALERT "%d\n",entry->data);

}

}

}

---------------------------- END -------------------------------------

The SYSCALL_DEFINEx macro is defined in the syscalls.h file. It is, as the name suggests, used to define a system call.

Here, "x" is the number of parameters that the system call takes.

So the line :

SYSCALL_DEFINE1(listdel,int __user*,buffer)

says that : define a system call with the name "listdel", which takes 1 parameter and the parameter is a pointer, in user-space, to an integer.

The name of the pointer is the third argument.

so in general,

SYSCALL_DEFINE0(<name_of_system_call>)

SYSCALL_DEFINEx(<name_of_system_call>, <type_of_arg_1>, <name_of_arg_1>, ... , \ <type_of_arg_x>, <name_of_arg_x>)

The rest of the code is fairly straight-forward.

The get_user() macro copies the data from the user-space to the kernel-space.

The list_for_each() macro is used for iterating through the list.

The list_entry() macro returns a pointer to the linked-list node, given a pointer to the list_head struct within that node as the argument .

8. Now, we write a simple Makefile to compile our files

----------------------- Makefile -------------------------------------

obj-y += lister.o

----------------------- END -------------------------------------

This completes our kernel-space code.

Now, to test this code, we need to write some user-space code.

For this, we write 2 files, test.c and tester.h

9. Now, we will write wrapper functions for the system calls and put then together in a header file. Let's call that file as "tester.h"

Writing wrapper functions is not necessary, but it improves the readability of the code.

----------------------- TESTER.H ----------------------------

#include<linux/unistd.h>

#include<sys/syscall.h>

#define __NR_listadd 335

#define __NR_listdel 336

#define __NR_listshow 337

static long add_in_list(int * buff)

{

return syscall(__NR_listadd,buff);

}

static long del_from_list(int * buff)

{

return syscall(__NR_listdel,buff);

}

static long show_list(void)

{

return syscall(__NR_listshow);

}

------------------------- END --------------------------------

Note here that the numbers in the #define s have to be exactly the same as those in the unistd.h file

Here, in this header file, we wrote 3 wrapper functions for each of the system calls.

The _syscall() macro is the actual invocation of the system call.

Here, the arguments to the wrapper functions are simple integer pointers, instead of the int __user * that we used earlier. This is because this code is in the user-space, while the earlier code was in the kernel-space.

10. Now, we'll write a simple program to test the system calls. Let's call that file "test.c"

----------------------- TEST.C ----------------------------

#include<stdio.h>

#include "tester.h"

int main()

{

int data;

int i;

for(i=0;i<4;i++){

printf("\nEnter the number : ");

scanf("%d",&data);

add_in_list(&data);

show_list();

}

printf("\nDelete : ");

scanf("%d",&data);

del_from_list(&data);

}

---------------------- END ---------------------------------

The code is very simple, nothing really to explain.

Just compile and install the kernel so that system calls become available.

Then compile and execute "test.c" to test out the system calls.

Any kind of criticism is welcome ! :-)

Wednesday, August 12, 2009

Random

It's been quite a while since the last post. I've been kinda busy ( read LAZY) in the last 3 months.

A lot has happened since the last post was published. Okay, as you might have guessed, this is _not_ a technical post. :-)

College in the Final year has really been fun. It's been less about attending lectures and more about playing Table Tennis and Carom !!
We now have a week long off as a measure to control the swine flu epidemic in the city. I hate swine flu, but I like the holidays :-) :P

One of the best things that has happened since then is that now i have a job ! [:D]

Yeah, we had campus recruitment in our college and I was one of the lucky few to have been recruited to ThoughtWorks.
The recruitment process for ThoughtWorks was rather gruelling...spanning over 3 days and 6 rounds, 7 actually, if you count the aptitude/logic test that i had to give before being handed over the offer letter !
So, after a logic test, group activity round, coding round, 1st technical interview, 2nd technical interview, HR interview and a logic test to test my speed & accuracy...here I am !
But having survived so many rounds makes my selection feel all the more satisfying :-)

We also got our results in the last week. I've done pretty well this time around. For the first time, a girl didn't top the class :P

We also have to do an year long project in the final year. My project group ( 4 of us) have been working really hard in the last couple of months, reading lots research papers / blogs / TO-DO lists to find a good project idea. We're hoping to zero down on a good idea soon ( Its been like this for the last month :P ). Really looking forward to working with the group.

I wont say the customary "Look forward to more posts in the near future" stuff , coz i know that its not gonna happen. I'm not a regular blogger and I'm too lazy to become one :P

This post came purely out of the guilt of seeing most of my friends blog in the last couple of days :P
Special inspiration from Aruna, who has been blogging furiously in the last 15 days :-)

So, until the next post, Cya !
Take care. Be safe. Bunk college !
--Cheers !

Saturday, May 2, 2009

HP remote control in ubuntu ....how to get it working ....

Got a new laptop couple of months ago :D
HP Pavilion dv5 1104TU and it completely rocks ! :D

Well, it also came with a neat little remote control with lots of media buttons to make life easy. It worked perfectly under Vista, but refused to work with ubuntu (tried on 8.10 and 9.04). Now, I've finally come up with a way to get it working on Ubuntu.

Just follow this procedure and nothing can go wrong !

Firstly, you'll need to get lirc .
To install lirc, click here
Note : Select "none" and "none" when it asks for configuration during isntallation.

After that, download the configuration file for the Remote from here .This is the configuration file for the remote that comes with the DV6 series, but it works just fine with DV5 series too.

Now save this file as lircd.conf in /etc/lirc/

After this , edit the hardware.conf file to match this :

# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES="lirc_dev lirc_serial"
REMOTE_DRIVER="default"
REMOTE_DEVICE=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

#Enable lircd
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""


Save it

Go to the terminal and ..

 sudo /etc/init.d/lirc start 


and Voila ! if you have done everything correctly, the remote should be working now.
You can try it out from System->Preferences->Keyboard Shortcuts
Hope that helps ! :-)
Cheers !

Wednesday, December 17, 2008

Of Flash drives and Windows XP...Part II

Part I can be found here.

This part contains the workarounds !

How to fool Windows into thinking that the removable drive is a local disk :

This solution has been copied from here

I am posting the solution here too, just because its difficult to find the solution on that page :P.

Nearly all USB flash drives pretend to have a removable media (even it's a lie), so Windows detects them as 'removable'. On drives with a removable media Windows 2000 and higher supports only one partition.
Finally it's a single bit in the device's device descriptor, the removable media bit (RMB). If you take away the RMB then Windows sees the drive as 'local disk' and multiple partitions work.
The Removable Media Bit can be changed either in the drive's hardware or by a Windows filter driver.
Changing in the hardware works with some flash drives by means of the tool Lexar BootIt.

But this works only with some pen-drvies. It DID NOT work for me.

The second way to do this ...

A filter driver for removing the RMB has been made by Hitachi for their Microdrives (Compatct Flash cards with a mini harddrive):

xpfildrvr1224_320.zip

By modifying the included INF file the filter driver can be used with any other 'removable' drive.
For the device detection there are the lines in section [cfadisk_device]:

[cfadisk_device]
%Microdrive_devdesc% = cfadisk_install,IDE\DiskIBM-DSCM-11000__________________________SC2IC801

"IDE\DiskIBM-DSCM-11000__________________________SC2IC801" is the device ID of one of the supported Microdrives.

In analogy to these lines we add one line for each 'removable' USB drive we want to turn into an USB hard drive. The ID is found in the Windows device management: Expand 'Disk drives', right click your USB drive, select Properties. On the tab "Details" under XP the item "Device instance ID" is already selected. Click on the ID in the List and press Ctrl+C, this copies the ID into the Windows Clipboard and can be pasted somewhere else with Ctrl+V.
XP shows the tab "Details" only when the environment variable DEVMGR_SHOW_DETAILS=1 is set:
DevMgr_Show_1.reg download and doubleclick the file, then relogon to take effect.

Sample:
USBSTOR\DISK&VEN_LEXAR&PROD_JUMPDRIVE&REV_1.30\K326441127040&0
We need the fat part:

[cfadisk_device]
%Microdrive_devdesc% = cfadisk_install,USBSTOR\DISK&VEN_LEXAR&PROD_JUMPDRIVE&REV_1.30

In the last line of the INF file we change "Hitachi Microdrive" into something nice as "RemovableToFixed".

In the device manager again right-click the USB drive, "Update driver...", then "No, not this time" -> Next -> "Install from a list or..." -> Next -> "Don't search." -> Next -> "Have Disk" -> browse to the INF file here. Now "RemovableToFixed" should be in the list -> Next -> Confirm the two warnings -> Finish.
Now the drive is re-detected, actually as USB hard drive. The drive can be partitioned, and all the existing partitions are visible and usable.

Now, this solution works with all the USB flash drives. But the problem is that since this method requires installing a custom driver, the pen-drive is detected as a local disk only on the machine that uses that driver. All the other machines detect it as a removable drive. This essentially defeats the purpose of using a pen-drive !!

Re-arrangement of partitions :

This hasn't been copied from anywhere :P.

What i realized was that only the 1st physical partition was being assigned a letter. So i re-arranged the partitions within the flash drive as follows :

1) 2111 MB NTFS (for general use)
2)1024 MB ext2 ( for persistence)
3)700 MB FAT32, bootable.

This made the NTFS partition visible from Windows and i could use my flash drive as if it were a ~2 GB pen-drive.

Looking back, I actually liked this solution, since, whenever I use my pen-drive in the college, the viruses wont be able to mess up the FAT32 bootable partition ! and when I use Linux, all 3 partitions are being mounted anyway. The flip side was that sharing data between the partitions was impossible with Windows XP.....

So as it turned out, there is no concrete solution to using Flash drives with multiple partitions with Windows XP....just some workarounds, each with its pros and cons....

So what do you do if you wanna use a Flash drive with multiple partitions ? .....Use Linux :-)

Of Flash drives and Windows XP...Part I

As mentioned here, I faced quite an annoying problem when i created multiple partitions on my USB flash drive.

The layout of the Flash drive was as follows :

1)720 MB partition, FAT32, bootable
2)1024 MB partition ext2 (for persistence)
3)2111 MB parition, NTFS (for general use)

Now, the problem was that when the Flash drive was inserted when Windows XP was running, only 1 partition was being assigned a letter by Windows. The remaining partitions were visible from the Disk Management Tool, but were not being assigned a letter and as a result were rendered useless.
Any attempt to assign a letter to the drives resulted in the following error :
"The partition is not enabled. To enable the partition re-start the computer."

Restarting the computer does not help and the same error is displayed.
Now this was annoying, because the partition that was being assigned a letter was the 720 MB one, which was already filled up.

This problem is absent in Ubuntu. All the 3 partitions are detected and are usable. This problem is confirmed by Microsoft as a feature (lol :P).Only the first partition on the USB Flash drive is assigned a letter and is usable.

There are a couple of workarounds for this ....one is to fool Windows into thinking that the removable drive is a local disk. The other one involves rearrangement of partitions.

Workarounds can be found here.

Of Live USBs and MBRs

Determined to put my 4 GB flash drive to good use, i decided to create a Live USB disk of the Interpid Ibex on it.

Now, Ubuntu 8.10 comes with this neat "Live USB disk creator" tool, which makes it extremely easy to create a live disk.But on my friend Chinmay's blog, i read that this tool doesn't make the USB stick persistent. So, without trying it out myself, i headed here. Now this page describes how to install Ubuntu 8.10 on the USB stick.

After following all the steps mentioned there, i was unable to boot through my USB stick. It displayed some garbage on the screen and i was forced to restart the computer.

So now, I tried the Live USB creator tool, which led to the same problem as well !. One probable source of this kind of error can be a corrupted MBR. So i tried writing a MBR to the disk using lilo.

#lilo -M /dev/sdX

where, X is the letter assigned to the drive, which can be found out by doing a #fdisk -l .

And, as it turned out, this was the problem. Now, I was able to boot through my USB stick and everything seemed just fine. All the settings and documents were persistent. I again, formatted the USB stick and used the tool provided with the Intrepid, and surprisingly the settings and documents were persistent here too !. So Chinmay's might be an isolated problem....or mine an isolated success :P .

The major difference that i found out between the two methods was that the creator tool does not create separate physical partitions on the stick. It instead creates a file on the stick and uses it for persistent settings. On the other hand, the manual method creates a separate partition for keeping the settings persistent.

Now, my USB stick was ready ! ....well not exactly.....i faced quite an annoying problem in Windows while using this USB stick.

Since I'm running out of time, I will post the problem and some workarounds that I found out later.

Stay tuned :-D


Saturday, December 13, 2008

Problem with user Privileges and Roles in OpenSolaris

Had tried out Open Solaris a few months ago...and straightaway faced a numerous problems :P ...

The most annoying was that the user privileges were getting reset on every login.
So here i am posting how i worked around this problem.

As I said,

The user privileges of my user were getting reset on every login and now, the GUI had started throwing a strange error...when i started the user admin tool ( Users and Groups ), it asked me for authorization, when i provided the root password, it simply rejected it.

The funny part is, that i can "su" root using the same password through the terminal !! (This is ofcourse after i "su" the Primary Administrator) .

So, i was forced to work with the CLI, i tried using the "usermod" command, but I did not understand clearly the way it is supposed to be used, so gave up on that too.


Next, i opened the /etc/user_attr file .

/****************
/etc/user_attr snippet :

root::::type=role;auths=solaris.*,solaris.grant;profiles=All;lock_afte r_retries=no;min_label=admin_low;clearance=admin_high
aditya::::profiles=Prim ary Administrator;roles=root

#amod::::profiles=Apache 22 Administration,Application Server Management,Audit Control,Audit Review,Basic Actions,Console #User,Contract Observer,Cron Management,Crypto Management,DAT Administration,D-BUS Management,Desktop Configuration,Device #Management,Device Security,DHCP Management,dtwm,File System Management,File System Security,FTP Management,HAL #Management,Idmap Name Mapping Management,Idmap Service Management,Inetd Management,Information Security,IP Filter #Management,ISCSI Target Administration,ISCSI Target Management,ISNS Server Management,Kerberos Client Management,Kerberos #Server Management,Log Management,Mail Management,Maintenance and Repair,Media Backup,Media Restore,MySQL #Administration,Name Service Management,Name Service Security,NDMP Management,Network IPsec Management,Network Link #Security,Network Management,Network Security,Network Wifi Management,Network Wifi Security,Object Access #Management,Object Label Management,Operator,Outside Accred,Postgres Administration,Primary Administrator,Printer #Management,Process Management,Project Management,Rights Delegation,Rmvolmgr Management,Service Management,Service #Operator,shutdown,SMBFS Management,SMB Management,Software Installation,System Administrator,System Event Management,User #Management,User Security,VSCAN Management,Web Console Management,ZFS File System Management,ZFS Storage Management,Zone #Management;

amod::::auths=solaris.*,solaris.grant;profiles=All;roles=root

/***** ***************end of snippet

(all the lines of amod (second from last) have been commented, they might not show up properly...formatting problems)

so as u can see, my user (amod) had all the privileges, but they weren't showing up in the GUI ! (bug ?). And now i understood why i couldn't "su" root... i had no "roles" defined. I have no idea of how to set roles through the GUI or the CLI, so instead i just copied "root's" line and made some changes :P

So now, my problem is solved, i can su root directly from amod and do everything i want (heck ! im _almost_ root now :D ).

But, the problem of the GUI not showing the privileges still persists.

I had posted this workaround on the Pune Open Solaris User Group's forums and was suggested that I post it on the Open Solaris desktop-discuss forums. The post on the desktop-discuss forums can be found here. The same problem has been confirmed by 3 users there.
So, until an update for the GUI, which allows roles to be defined is released, the above workaround works just fine :-)

EDIT:
You can also assign roles to a user using the "usermod" command with a "-r" option. I did not know this then. This, again, can be done only by the Primary Admin, if no other users have "root" role defined.

Thursday, October 23, 2008

Err....

Saw the dates for practical exam yesterday and i made a choice between Fifa '09 and Proakis...

I opened my Proakis and five minutes later....closed it.......WTH !! i can't understand a word !!!

Wondering wats gonna happen, i had a vision ...(a la Vincent Kennedy McMohan moment )...

Follow these steps and 80% is guaranteed. Read on.

Before we start, here's one instruction -> Be slow, don't rush through it. Read each word carefully and follow each step !!
All set.

Now, firstly,

look down and look up .......good u r a in a state of mind where u'll do/believe everything i say :P

1) Clap your hands 3 times on a desk, 2 times with the right hand, once with the left. If you're a leftie, reverse it. If you're ambidextrous, clap 2 times with both the hands.

2) Jump 7 times without bending your knees.

3) Look down and look up. If u did it again....man u're really desparate :P...if not, see !! u're already getting smarter ...Read on....

4) Spin around 3 and a half times.

5) Say "asjdhfasdklfwmasiuwehjawergydaszmxbczxjhg" BACKWARDS !

Now, the last step....laugh at urself for being such a dumba** to read thru this crap....hehehe...

And Lo ! u're there...if u could do all the things said above, 80% is guaranteed !!

Well, i cudn't do all the steps ......so i made a choice ....between Fifa '09 and my Proakis......

AC Milan v/s Chelsea ...6-0. Peace !! :-)

PS : This is purely a work of imagination. Any resemblance to living or dead is just a result of ur twisted perception :-)

Saturday, August 9, 2008

Owned !!

ROTFLMAO !!

Check this out - >Game Over !!

Friday, August 8, 2008

WTH just happened ?

I turned on my computer and it popped a message "BIOS Checksum Error. Starting recovery ...".
It started searching my floppy drive( non-existent :P ) and the Cd-Drive for the BIOS ROM.
Fortunately, I had the support CD at hand and quickly pushed it into the CD-Drive.

Up came the message :

"M2N-MX.ROM detected
Starting Erasing...|
Starting programming ....| "


Then the mobo beeped twice-thrice and the computer restarted. And, the BIOS checksum error message popped again !! WTH !! i just saw it getting flashed !!

Happened 2 times in a row....frustrated, i decided to take out the mobo manual (dunno why i didn't take it out earlier ... :P)

It had 2 full pages regarding BIOS recovery... one way was to press Alt+ F2 before POST to start ASUS' "EZ Flash Utility " that would apparently help me flash my BIOS.

Computer restarted. I pressed Alt+F2.
The utility started and searched my Cd-Drive for a BIOS file.
Up came the message "M2N-MX.ROM detected"
and immedialtely followed by "Error ! the ROM file is outdated and cannot work with the hardware "
WTF !! This is the BIOS that came in the manufacturer's CD !!

I was starting to freak out... Fired up my old machine and downloaded the LATEST BIOS for my mobo, bought a CD and burned it onto the disk.

Computer restarted.
Up came the message:
"M2N-MX.ROM not detected !"


huh?...Sigh, the file i had downloaded had a different name ....fine, i'll just have to rename it and burn it again....I removed the Cd from the drive and instead of pushing the "power-off" button, accidentally, pushed the "restart button"...

My BIOS was detected !!

"There is a CMOS checksum error :
Press F1 to start recovery
Press F2 to reset to default settings and continue "
?_?

F2 pressed.
The screen went blank and up came the familiar message
"GRUB Loading stage 1.5. "


Wheeeee !! problem solved !!
But WTH just happened ??? The computer was running fine until yesterday ...
My guess is a faulty SMPS which isn't providing the required current at the required voltage to the mobo....
Any pointers ?

Tuesday, June 17, 2008

TrackManiac !!




Ahh ! Writing after many days...this post is guaranteed to be scratchy :P

After playing TrackMania Nations , I just had to try this newest version of TrackMania, The TrackMania Forever !!
For those who don't know what TrackMania is, here's the wiki topic link : http://en.wikipedia.org/wiki/Trackmania

The official website is : http://www.trackmania.com
The setup can be downloaded from the their site. This game is free to download and free to play :D

TrackMania Forever was released on 17-18 April, 2008 ( when the PL had just started :D ) and it has around 1 million ( 980k , to be precise) registered online players.The Indian community is not-so-strong with just around 2,500 odd players....i'm currently ranked 254th among the 2.5k players :D
TMForever lets you choose between online and offline play...i just love games which have both online and offline modes :).
TrackMania in the offline (Solo) mode offers campaigns.The campaigns have been changed significantly. Their difficulty is now reflected by colors (White - easiest, Green, Blue, Red, Black - hardest), and progression to harder tracks is limited by requiring you to finish the previous track(s) with some medal first: You need bronze medal to proceed to next track in Green difficulty, silver for Blue, and gold medal in Red. The black tracks only unlock after you gain gold on ALL the previous tracks.Nice practice before you jump onto the online community :-)

There are basically 2 types of tracks...Dirt tracks and Stadium tracks.There are more stadium tracks than dirt ones, but both the types are equally engaging.
A stadium track :


Dirt track :




Online Action :



Online mode lets you choose different servers from around the world. What I liked most is that it also provides a list of recommended servers, where the average player ranking is close to yours...
Winning races or finishing in the top 5 ,gives LP points, which is the basis for the rankings.
Online mode is madly addictive ( though MMORPGs are more addictive :P).
The only downside to the Online play is that, in India, where bandwidth is metered, online play can cost quite a lot of "MBs" ( thats the reason why i love MMORPGs :P).


The more thing that I haven't touched yet is the track editor ....which as the name suggests lets you edit tracks or create new ones !

If you haven't played Trackmania yet, then this the game to start with.If you have been playing since the United version, this version really doesn't add much ( I read this on some other review :P).

For : Good graphics, Addictive gameplay, Offline and Online modes, Track editor ,Its FREE !!
Against : May cost you lots of "MBs" during online play.
Rating : 9.5/10
(- 0.5 less coz it really uses up too much "MBs" :-( )

Friday, April 25, 2008

Hardy Heron is finally out !!

The Heron is finally out, and i can't wait to install it on my box.
Wait, why haven't i installed it yet ? Because i have an earlier installation of Gutsy, and I downloaded the Live CD instead of the Alternate CD (sad)...so i'll have to wait one more day and my exams are around the corner so I won't be able to tinker much...

Anyway, I did run the Live CD for about 10-15 minutes and though i didn't look around much, the first thing that came to my notice was the booting time....it booted in around a minute from the Live CD ,thats fast compared to the Gutsy Gibbon.
The next thing that pleased me instantly was the native resolution of my monitor was detected flawlessly....something that didn't happen in either Gutsy Gibbon or Fedora 8...
also,
Internet was configured within 60 seconds...typical of Ubuntu...
and the wallpaper is awesome.

But one thing was amiss, I remember reading that Ubuntu was going to do away with the human theme in the Hardy Heron, but the default theme still happens to be the human theme.......whether the idea was dropped, i know not....but i was really excited to see a new theme.

Overall the first impression was that the Heron does seem to be an improvement over 7.10,

More later.

Cheers !

Monday, March 24, 2008

The Real reason why we use linux....

the REAL reason why we use Linux....

Why we use Linux

I found the article and the subsequent comments really interesting....

Dev-C++ under Vista

For those having trouble using Dev-C++ under vista, follow THIS

It fixed my " source file not compiled " error ...

-cheers

Sunday, March 23, 2008

graphics.h without Turbo C/C++

hmm.........this first post took a long time coming..... :-D

I personally hate using the Turbo C/C++ compiler, no, its not a bad compiler, but its well past its sell-by date. It was one the best compilers earlier, not anymore....

When using Linux I obviously use the gcc.
When using Windows, i use the Dev-C ++ IDE.

Many people ( mostly 2nd year comp. engg. students from Pune University :P) complain that one cannot use the "graphics.h" with any other IDE, well, u can..just follow these steps..

1. Get Dev-C ++

2. Install Dev-C++ ( i usually prefer following the default install path in case of compilers ).

3. Get the "graphics.h" and the "libbgi.a" files from Here ....credit for these files goes to Michael Serrano.

Note: Copying the files from the Turbo C directory may not work ( i haven't tried it ..).

4. Copy the "grahpics.h" files to : C:\Dev-Cpp\include
and the "libbgi.a" file to : C:\Dev-Cpp\lib

Note : Your paths might be different, please check where Dev-C++ is installed on your system.

5.Start Dev-C++ . now Tools-->Compiler Options

6.Tick the "Add these commands to the linker...." and within the box , paste the following line :

-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

This tells your linker what all extra libraries it should link....

Now its all done, enjoy the Turbo C++ graphics library on Dev- C++


Note: This is not the only place where you will find such a tutorial...i haven't devised this method, only the linker part is mine :-)

Saturday, March 22, 2008

Coming soon :)

More coming soon .....