Roshan Book

My Tech Notebook

Monthly Archives: September 2011

To all those who wants to repost my articles

I have been getting requests from some readers, asking for permission to repost my articles to there blogs. I want to clarify few things before answering this .

1. The purpose I creates roshanbook, was to put all my research, solutions i came across while solving problems faced by me in my day to day activities. So that when i have to redo anything, i don’t have to refer to google again and again.

2. Thus contents here is aggregate of solutions, which i found working . So many a times posts like this are direct rip from different websites and forums and many a times post like this are direct solution from my side.

3. I don’t claim any copyright of any of my content and obviously neither on the rip off articles.

Thus to answer your request, Yes you can surely use any of the content from my posts as you like untill the original poster of the articles(in case of rip off articles) don’t mind.

Thanks for your love.

How to Choose a Partition Scheme for Your Linux PC

Afraid of the dreaded “p” word?  You’re not alone.  Partitions can get complicated, so here’s an explanation of what they are, how they’re used, and a simple template to use for your own Linux installation.

Image by dmyhung

What Are Partitions?

Partitions are divisions in the formatting of the hard disk.  It’s a logical – as opposed to a physical – division, so you can edit and manipulate them for various purposes.  Think breaking a disk into two configuration parts.  Partitions are really handy because they act as a sandbox.  If you have a 1 TB hard drive partitioned into a 250 GB partition and a 750 GB partition, what you have on the latter will not affect the other, and vice versa.  You can share one of those partitions on the network and never worry about people accessing information on the other.  One could have Windows installed, riddled with viruses and trojans.  The other could be running a very obsolete, security-hole addled Linux installation.  Never shall the two interfere, unless either you make them or the hard drive itself physically dies.

The other useful thing is that you can have multiple partitions, each formatted with a different “file system.”  A file system is a formatting of the disk into a table that the operating system can read, interpret, and write to.  Only have one hard drive?  That’s okay, because you can still install multiple operating systems on it without actually having another physical disk.

While there are tons of file system types, there are only three kinds of partitions: primary, extended, and logical.  Any given hard disk can only have a maximum of four primary partitions.  This limitation is due to something called the Master Boot Record which tells the computer which partitions it can boot from, and so primary partitions are usually reserved for operating systems.  But what if we want more than four?  That’s where the extended partition comes into play.  It serves as a hollow container for any number of smaller, logical partitions.  You can make as many as you like there, as well as make it home to your non-OS sections.

If extended partitions are so great, why not just use them?  That’s because you can’t directly boot from anywhere inside an extended partition.  There are ways to get around this, but the best thing to do is to plan properly beforehand with primary partitions.  In addition, the way partitions are numbered by the system depends on these types.  First, the machine will number based on all primary partitions, and then by logical ones.  This can cause changing drive letters if you switch between OSs or add or delete partitions later.

Mount Points in Linux

partition scheme (methoddan)

Image by MethodDan

On Windows, things are pretty clearly cut: it lives on your disk, usually on one partition, and that’s that.  If you have other drives, and they have a compatible file system, then it’ll read them as well.  If not, it’ll usually ignore them, or offer you the ability to reformat.  Linux – and anything resembling Unix, really – doesn’t quite work that way.

The way Linux works is that it puts everything onto a tree.  If you have another partition or disk, it gets “mounted” as a branch in a specific folder, usually /media or /mnt.  The directory that a partition gets mounted to is called a “mount point.”  This method works better with Linux’s tree structure, and you can mount partitions as folders nearly anywhere.  In Windows, this is not so easily done; new partitions generally show up as separate drives.  In addition, Linux can work with many more types of file systems natively than Windows.

Remember how there could only be four primary partitions?  If you want to boot 145 OSs like someone on the JustLinux forums did, you can set up a primary partition for /boot, which houses a boot-loader, like GRUB or LiLo, which handles initial functions and then continues booting into the extended partitions.

What Scheme Should I Use?

The standard partitions scheme for most home Linux installs is as follows:

  • A 12-20 GB partition for the OS, which gets mounted as / (called “root”)
  • A smaller partition used to augment your RAM, mounted and referred to as swap
  • A larger partition for personal use, mounted as /home

The exact size requirements change based on your needs, but in general you start with swap.  If you do a lot of multimedia editing, and/or have a smaller amount of RAM, you should use a larger amount of swap.  If you have plenty of memory, you can skimp on it, although some distributions of Linux have a problem going into standby or hibernating without much swap.  The rule of thumb is that you choose between 1.5 to 2 times the amount of RAM as the swap space, and you put this partition in a place that is quick to reach, like at the beginning or end of the disk.

Even if you install a ton software, a maximum of 20 GB for your root partition should be enough.  Most distributions of Linux use either ext3 or ext4 as their file system nowadays, which has a built-in “self-cleaning” mechanism so you don’t have to defrag.  In order for this to work best, though, there should be free space for between 25-35% of the partition.

Finally, whatever else you have should go to your /home partition.  This is where your personal stuff is stored. It is functionally the equivalent of the “Users” directory in Windows, housing your application settings, music, downloads, documents, etc, and those of any other users you have on your system.  It’s useful to have /home in a separate partition because when you upgrade or reinstall your OS, you don’t have to backup anything in this folder!  Isn’t that convenient?  To top it off, most of your program- and UI-related settings are saved as well!


If you’re running a server with a lot of users and/or a lot of media, you could optimize performance by using two hard drives.  A small solid state drive would be perfect for the OS to live on, maybe 32 GB at most, and you could throw the swap partition on the beginning of a 1 or 2 TB “green” drive that’s mounted on /home.

If you’re into more tinkering, you can even set up different partitions for things like the temporary directory (/tmp), for your web server’s content (/var/www), for programs (/usr), or for log files (/var/log).

Specifying Mount Points During Installation

In our example, we’ll be using showing the partition setup during an Ubuntu Maverick Meerkat installation.  When you get to where it says “Allocate drive space,” choose “Specify partitions manually (advanced).”

installation manual

Don’t panic just because you see “advanced”; it’s really not that difficult and you’ll be getting some real rewards from the process.  Click forward and you’ll see the partition table.

new partition

Click on the free space row in the table and then click on “Add…”  If you don’t have free space, click on your Windows partition, hit “Change…” and shrink it to a more palatable size.  This will give you some free space to work with.

Create partition

Here, you can see that I’ve created a Primary partition of about 11.5-odd GB at the beginning of the disk and I’ve specified it to use root as the mount point.  You will have to use a Linux-compatible file system, so I used the default ext4, although you can use ext2, ext3, ReiserFS, or whatever else.  Do some research online and you’ll be able to choose the best, but if you’re in doubt, stick to the default.  You can adjust yours to more space if you have it, but again, you probably won’t ever need more than 20 GB unless you’re installing/compiling a lot of software.  Click “OK” and you’re set to create another partition.


This time, as you can see, I’ve chosen a logical partition (the partitioning program automatically creates an extended partition for this).  Since this machine has a 512 MB of RAM, I’ve approximated 1.5 times that, and designated it as “swap area.”  Also note that I’ve stuck this at the end of the disk, which will help keep disk seeking times at a minimum.  Click “OK,” and let’s create another partition.


I’ve selected all of the rest of the space in the middle to be my /home partition.  The compatible file system I’ve chosen is again ext4.  Now here is the gray area: should it be primary or logical?  I went with primary because I know that I won’t be installing another OS on here, otherwise I would have gone with logical.  If you don’t plan on installing more than three OSs, you can just make it primary for simplicity’s sake.

When you’re all finished, you can resume installation.  Here’s my resulting partition table:


If you get cold feet, you can quit the installation at this point without fearing any data loss.  Nothing is actually done to your disk until you hit “Install Now,” so you can go back and edit things as you wish.

Use the Windows Bootloader to dual-boot Windows Vista and Ubuntu


You find GRUB ugly right? Everyone does. It’s supposed to be better and cleaner, but it is so restricted and hard to edit. I am here to the rescue! You can easily use the Windows bootloader to boot into Windows or Ubuntu, with no hassle.

I am using Windows Vista Home Premium, and I am sure it works with 7 as well. But still, I can’t think why it won’t work in Windows XP as well. In my case, I have Ubuntu 10.04 installed on a second partition, and both the operating systems are running properly.

The fix is pretty easy. You just go to this website when running Windows and download EasyBCD. It’s a very small and useful app. When this article was written, the latest version was 2.0.2. Now, when the installation is done, run it the program. Now click the button on the left that says ‘Bootloader Setup’. Here, under MBR Configuration Options, choose the relevant radio box, depending on which version of Windows you are using. Now click ‘Write MBR’. After a few seconds, you’re done.

Now, go to Add New Entry. Here, under Operating Systems, select the Linux/BSD tab. Now in the drop-down menu, choose ‘GRUB 2′ (don’t worry, this will cause the GRUB menu to appear when you select this option, but we’ll fix that in a minute) and name the option appropriately. Click ‘Add Entry’.

Click the top button on the left, that says ‘View Settings’ and check if the two OSs are in the list. You may now close down EasyBCD and reboot your machine.

Now, if everything went well, you must get the Windows bootloader when you start the computer. You must see the two operating systems, as you named. But, the problem? When you choose your Linux option, you get the GRUB boot menu. You don’t want that to happen. So let’s change a little setting in Linux, so that the menu is not displayed at all and you boot directly to Linux when GRUB starts.

So, the effect will be this: You start the PC, you see the little splash screen (maybe not), and you see the Windows bootloader. You may choose Ubuntu or Windows and directly boot into it.

For this, we need to change the waiting countdown to 0 seconds for GRUB, so that you can boot directly into Ubuntu, when you choose it from the Windows bootloader.

In Ubuntu (10.04 in my case, as I mentioned earlier), first start Terminal (if you’re a beginner, you can find it in Applications -> Accessories -> Terminal. Now, you need to run it as a ‘root’ user (which is similar to having an elevated window in Windows, except that this is a super elevated user). For this, type in the Terminal window:

sudo -i

Now, it will ask you your password. Type it in (don’t worry, nothing’s wrong, you won’t see anything getting entered into the window and that’s normal). Press Enter. Now you’ll see ‘root@[computer name]:~#’ Type in:

cd /etc/default

Then, key in:

gedit grub

What we’ve done now is that you changed the directory in the Terminal to the folder ‘/etc/default’ and you’re now opening the text file ‘grub’ located there in the app called Gedit at root level. Now, when the text file is open in Gedit, change the line‘GRUB_TIMEOUT=10′ to ‘GRUB_TIMEOUT=0′.

This will cause the 10 seconds countdown in GRUB to become zero, and you’ll boot into Linux as soon as GRUB starts.

Close the file, saving it. Now, in Terminal (open it again and get to ‘root’ level if you have closed it), type the command:


In a few seconds, the settings will be applied. Now, reboot the computer and see if everything works. You should be able to get into Windows or Ubuntu from the Windows bootloader, and change the settings for the default OS, countdown and other things from EasyBCD, which is installed in Windows.

Installing Linux mint in E drive

Reverting back to windows boot loader

1. Remove the Ubuntu partitions (EXT3 and SWAP) and resize the Windows partition (NTFS) to use that space.

To do this, you can follow the blog post I made which uses the Gparted LiveCD. The NTFS partition is Windows, and the EXT3 and SWAP partitions were created by Ubuntu.

2. Fix the MBR (Master Boot Record) so that Windows will boot, instead of GRUB.

Boot from the Windows XP CD.
Rress the “R” key in the setup to start the restoration console.
Select your windows XP installation from the list, and enter the administrator password.
Enter the command: “FIXMBR” (without the quotes) at the input prompt and confirm the next question with a “Y” (without the quotes).
Use exit to restore the computer.

If you do not have your Windows XP cd, then you can use the SuperGrub LiveCD to fix your MBR.

Another option is to boot to a floppy and use “FDISK.EXE /MBR”, but the first two options are much better. Good luck!

Python Tutorial 1 Strings

Programming is just writing in a language which computer understands and through that giving computer instructions to perform certain tasks

escape operator to escape a quote. E.g. “don”t” will escape double quote before t.

n are used to print text in multiple lines

t for tab

“”” is used to write multiple lines of text

Concatenation – “jhon”+”rambo”  or “jhon” “rambo”

format specifier “John %s%s” % (“Every” , “man”)

John everyman

>  >  >  “%s %s %10s” % (“John” , “Every”, “Man”)
‘John Every          Man’
>  >  >  “%-5s %s %10s” % (“John” , “Every”, “Man”)
John     Every          Man
How It Works
In the first line of code, the word  Man  appears far away from the other words; this is because in your
last format specifier, you added a 10, so it is expecting a string with ten characters. When it does not
find ten (it only finds three . . .   M – a – n) it pads space in between with seven spaces.
In the second line of code you entered, you will notice that the word  Every  is spaced differently. This
occurs for the same reason as before — only this time, it occurred to the left, instead of the right.
Whenever you right a negative ( – ) in your format specifier, the format occurs to the left of the word. If
there is just a number with no negative, it occurs to the right.

How to install firefox 6 on ubuntu

Python tutorial 1 strings

This program has

a) input method

b) convert to int method

c) if else syntac



g= input(“enter your guess”); # input is in string format
guess=int(g); # This converts input into integer

if guess==5:
    print(“You win”)
else :
    print(“You loose”)

%d bloggers like this: