A little help on installing Linux on a PC running MS Windows by C,R. Jayanth
Submitted by c_r_jayanth on Sunday, November 2, 2003 - 09:26
 

A little help on installing Linux on a PC running MS Windows.

Complexity level: Novice/Beginner

All around the world today, many business corporations, governments and universities are switching over to the Linux operating system (OS) for their network servers and workstations. At the same time, many (adventurous?) PC owners have tried to install it on home PCs, usually already running fine on Windows, with varying degrees of success. Perhaps they just got sick of Windows. Or they are fascinated by the philosophy of Linux. Or its just plain curiosity that drives them. If you are reading this, you probably belong to this group.

Sure, for Unix/Linux illiterates, it is usually a daunting task to switch to Linux. I, for one, had a lot of problems initially: from learning to operate a new (and very different) OS to getting my video card to work; and had to spend a little money on buying books and downloading 'drivers'. But at the end of it all, I have a virus-free OS, an excellent C compiler, internet and mail programs, an image manipulator comparable to Adobe Photoshop, better memory management (I don’t really know why, but it takes about 9 minutes to copy the contents of a CD (~650 MB) to the hard drive in Windows while it takes only about 2 minutes in Linux on my PC.) and a lot more for (almost) free. Besides, if a program runs only on Windows, I still have my old Windows OS for back-up. So, if you have decided to install Linux, you don’t really have to lose Windows. Maybe this article will be of a little help.

Which brings us to the actual topic of this article: How to install Linux (whatever distribution) on a system which already has Windows (whatever version) installed, without losing Windows or the stored files? Some Linux distributions such as Desktop Dragon actually require Windows to be running to be setup. However, most distributions must be installed on separate partitions. The actual installation is quite pain-free, so don’t grumble to take a few simple precautions before installation to ensure that you have a PC that can run two operating systems (albeit not simultaneously!).

First, for a few basics. You probably know all of this, but skim through it anyway.
1. Operating System (OS): It is the software that lets you control and use your computer. Windows, UNIX, Linux, OS/2 are all OSs, while Winamp, Netscape Navigator and all others are mere programs that run on the OS.
2. The hard disk (or hard drive): It is the part of your computer which stores your program, data and other files permanently, i.e., the contents of the hard drive will not get erased when the power is turned off, but you can add or remove data from the hard drive using your OS.
3. Disk formatting: To read/write the information on a hard disk, the disk should be organized into identifiable parts so that the computer would know where to look or write. The basic form of this organization is formatting. Hard disks must be formatted in 2 ways: (i) Physical formatting, which is done by the manufacturer. (ii) Logical formatting, which should be done after the physical formatting. Logical formatting creates a file system on the disk. Different OSs require different file systems and hence different types of logical formatting.
4. File system: The file system is an arrangement for managing data. Different OSs use and recognize different file systems. DOS uses FAT file system, while Windows 98 uses FAT32. Windows 2000 use NTFS system. Linux uses ext2 or ext3 and swap file systems. Windows XP can recognize FAT, FAT32 and NTFS file systems while Linux can recognize all these and also its own file systems. Newer versions of Linux support many more file systems.
5. Partitions: A partition is a separate physical section of the hard disk. It is created after the physical formatting and before the logical formatting. If your hard disk has more than one partition (which is usually true), each partition functions as an individual unit, and can be logically formatted with any desired file system. So you can have more than one file system on your hard disk, which means you can have more than one OS. But there are certain restrictions.

There are 3 types of partitions: Primary, Extended and Logical. A primary partition is a main disk division. Most OSs can be installed and booted from only primary partitions. One hard disk may contain up to four primary partitions, or three primary partitions and one extended partition. At a time only one primary partition may be visible and active, all others are hidden. An extended partition cannot hold any data by itself but you can further physically divide the disk space in it by creating an unlimited number of logical partitions, each with a different file system. The extended partition is meant to overcome the 4 partition limit. Logical partitions and are meant to contain only data files and OSs that can be booted from a logical partition such as Linux and Windows XP.

If you already have Windows installed, it is almost certainly on a primary partition. Also, most home PCs have just one primary partition. I recommend that you install Linux on a logical partition.

Now, all you have to do before installing Linux is to create additional partitions that can hold Linux. The idea of this article is to help you in doing just that (Without damaging Windows).Of course, we are presuming that Linux can actually run on your hardware and that you have already verified this with the hardware compatibility list of the Linux distribution. Also, you must be familiar with the setup process before beginning.

Let’s follow step-by-step, what I actually did and what you probably should do.

Step 1. I first got hold of the bootable setup CDs of RHL 7.2. I then started up my PC, while repeatedly pressing the DEL key, to enter the BIOS settings. Then, I changed the first boot device to CDROM drive, second boot device to FDD A(Floppy Disk Drive A) and third boot device to HDD 0 (Boot sector of Hard Disk Drive). Comments: Obviously, the first step would be to get your hands on the Linux setup files. You have a choice of several distributions including Debian, Mandrake, RedHat etc. If you want support and service, you have the option of either buying a boxed set from a company or depending on the large number of open-minded individuals on the internet who are dedicated to solving the problems of the Linux community out of the goodness of their hearts. If you opt for the latter, you can get the setup files by downloading them from the internet and burning them onto CDs, or you can get free CDs with some magazines, or you can borrow them from a friend etc.

You can setup Linux from CDs, DVDs, the hard drive or over a network. I would recommend CD based install which is quite hassle free. If your first installation CD is bootable, great! Otherwise you have to create a boot floppy. For RHL, you can do this in Windows or DOS using rawrite.exe or rawritewin.exe in the dosutils folder on the 1st disk. If you are using a boot floppy, you need not change the boot priority as I did.

Step 2. Next I inserted the first setup disk into the CDROM drive and restarted the computer.
Comments: Wrong move! Once you insert the CD and restart, the setup process begins. And before the setup begins, you are supposed to know and expect what happens during setup and what input you should give during the setup. Although you can just quit setup, why waste the precious seconds of your life by being unprepared? Read as much as you can on the actual setup process so that you know and expect. Even if you have memorized the setup procedure, keep a hard copy of the setup manual at hand, just to be on the safer side.

Step 3. The graphical setup program starts. I select English as the language for setup. The program detects my keyboard and mouse (But my scroll mouse is detected as a 3 button mouse. Newer distributions have fixed the problem.) It now asks for the partitions to install Linux on. I am given 3 options: One to partition automatically and the other two to partition manually with Disk Druid or Linux FDISK. I choose to partition automatically, assuming that Linux will create the required partitions out of the available free space on the disk. Then, setup flashes a warning saying "All existing data will be wiped out! Do you want to continue?". D-oh! I cancel, go back and choose manual partitioning using Disk Druid. Now I am presented with a diagram showing my 2 precious partitions. I have the option of deleting either of them to make space for Linux. At this point, I realize that I goofed up by not being sufficiently prepared before starting setup. Its CTRL+ALT+DEL for restart.

Step 4. I remove the Linux CD from the drive before the setup program starts again, start Windows, log on to the internet and do some research. It turns out that to install (most flavors of) Linux, you need at least 2 partitions: One "root" partition (denoted by '/') and one "swap" partition. The root partition must be big enough to hold all your Linux programs and files (Please refer to your Linux documentation to find out the exact size. Mine is about 4 GB and about 2 GB of it is occupied by system files.) and the swap partition should be double the size of your RAM. Moreover, these partitions need not be primary partitions, unlike the requirement in Windows 9x. OK, so we now know what partitions are necessary. So how do we create them? There are programs specifically written to facilitate safe partitioning, such as Powerquest Partition Magic. There were a few demo-version partitioning programs for free download on the net. But to download at my connection speed would take hours. Waitaminute!! Isn’t there a program called fdisk in DOS that can manipulate partitions?

Step 5. I start an MSDOS console and hit fdisk /? .It gives a message "Configures a hard disk for use with MS-DOS....” But I want to configure the disk for use with the Linux ext2 file system. Have I come to the wrong program? I now key in fdisk .It asks "Do you want to enable large disk support?” I answer Yes. Next I am given a menu:
1. Create DOS partition or Logical DOS Drive
2. Set active partition
3. Delete partition or Logical DOS Drive
4. Display partition information

Hmmm. If I now create DOS partitions of the size required for Linux, I can later format the partitions in the ext2 format during Linux setup. The important thing is to create the partitions, not whether they are DOS or Linux partitions.

I first check out the partition information. There are 2 partitions with no free (unallocated) space. I exit fdisk and check the available free space on the partitions. D drive has 5 GB free space out of about 19 GB. If I could somehow split this partition into 3 partitions: 3-4 GB for root partition, 256 MB for swap partition and the remaining for D drive, everything would be just nice. To do so using fdisk, I would have to:
1. Remove all data from D drive and store it elsewhere.
2. Delete D drive using option 3 of fdisk menu.
3. Create the 3 required partitions by using option 1 of fdisk menu three times.
4. Return the data to D drive (ie the largest of the 3 partitions.)

Step 6. Now all the data from D drive cannot be moved into C drive, there is just not enough space. So I run to my friend's place, get his hard drive, plug it into my computer in the slave configuration, and transfer some of the data into it. The rest of the data, I transfer to the C drive. So D drive is finally empty! Next, I start fdisk again, and choose to "Delete partition or Logical DOS Drive". Next, I choose to delete logical DOS drive(s) in the Extended Partition. Then I choose to delete D drive. Now, from the first menu, I select "Create DOS partition or Logical DOS Drive". In the following menu, I choose "Create Logical DOS Drive(s) in the Extended DOS Partition". Next, I specify the size of the partition, about 3 GB. Similarly, I create the other 2 partitions. It’s time to restart again. Comments: You probably don’t need to connect another hard disk to empty the contents of a partition. You can probably store the contents somewhere safe on your network or to a laptop via a LAN card or to a storage device via USB port. If you have no other option, take the help of an expert. Of course, it is a simple procedure, and you can probably get it right without anyone's help.

Step 7. Now we're ready to try installation again. This time around, when the setup asks me to specify the partitioning method, I confidently choose to partition manually using Disk Druid. Next, I choose to format the 3 GB partition as root (/) with ext3 file system. Since I am installing Linux on a logical partition, I am warned that the partition may not meet boot requirements and strongly recommended to create a boot diskette. No problem. The 256 MB partition is formatted as swap.

Step 8. When installing Linux, its best that LiLo (the boot loader) is installed to the root superblock (boot sector equivalent) of the Linux partition, not the Master Boot Record (MBR). You can let the setup modify the MBR, but if you reinstall Windows, Linux will be rendered inaccessible. Don’t forget to create a boot diskette!

That’s about it! The rest of the setup should proceed without any glitches and you will have a dual boot computer. You will be presented a convenient menu by the bootloader (GRUB or LiLo or a commercial bootloader that you have installed) every time your computer starts. From this menu, you can choose the OS to boot: either Linux or DOS (Windows).

IMPORTANT! I repeat, do not set up partitions with Linux FDISK or Disk Druid; they may render partition tables unreadable to other operating systems. You can use them to change partition types and set partition mount points, but that is all.


Copyright © 2003, C.R. Jayanth. Copying license http://www.linuxgazette.com/copying.html
Published in Issue 96 of Linux Gazette, November 2003