|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Tuesday, 11 January 2000||Author: James Andrews|
|Published to: learn_articles_support/Articles||Page: 1/1 - [Std View]|
How Do I Partition My Drive For Linux Use?
So you've decided to install Linux! Be aware, you'll need to partition your drive; check out this article for all the information you need before you jump in the deep end.
We will look at the worst case scenario first. No fancy programs like Partition Magic, no spare partitions, and you want to keep some data that is already on the disk. Let's say, for example, that you have a 1 GB disk with one partition on it containing an installation of Windows 95. You have tidied up and there is 500 MB of the disk space free which you hope to use for Linux. There are two things you should do next . First, run the Microsoft disk defragmenter. This should move all the used blocks to one end of the disk and all the unused blocks to the other end. Next you run fips and follow the on screen instructions to split 500 MB into its own partition.
Note that fips does not work easily with compressed partitions, or at all under MS Windows NT. It also has problems with the OSR2 FAT32 disk formatting scheme and some SCSI disk adapters. Check the fips documentation and the fips FAQ. If you have an unusual setup, it may be easier to back up all important data, use the MS-DOS or Windows fdisk program to partition the disk (thus wiping the data) and then reinstall MS Windows later.
The Meat: Partitioning
Primary, Extended and Logical
You are allowed up to four primary partitions, and one of these may be replaced by an 'extended' partition. Extended partitions can contain as many logical partitions as you like. In the simplest case for a machine that dual boots Linux and MS Windows you will need three primary partitions: the MS Windows partition, which must be first, a Linux root partition and a swap partition.
Suggested Disk Layout For Linux
Once you have partitioned some free space, you are ready to boot from a Linux installation disk. Among the first things that Linux installation does is drop you into a disk partitioning program like the Redhat 'disk druid' program or the screen-oriented cfdisk program. I have found that the most reliable disk partitioning system under Linux is the fdisk command line-driven program. Whatever system you choose, you should make a root partition and a swap partition. The root partition under Linux must be of type 'ext2' This is the native Linux disk type. It is a fast type of filesystem and efficient for storage. People often ask me what the best size is for the root partition. The short answer is between 500 MB and 1 GB. A long answer is that it depends what you plan to install. A very basic setup, with limited tools available, but perfectly usable, could fit in 70 MB. This would not leave enough spare room for the Linux graphical user interfaces that run under the (large) X Windows system, however. The baseline for X Windows and a few tools is about 170 MB. These days disks are large, and if you want to experiment with Linux to see just what is available, the best method is to assign about a thousand MB and install a big set of applications off the CD or Internet. However, bear in mind the wise words of Dennis Ritchie, one of the authors of C: "The steady state of disks is full". It doesn't matter how much disk space you have, it will always end up crammed!
Swap is an area of disk that Linux uses for 'swapping out' pages of unused RAM. This may seem odd, but the organization of swap is such that it is often more efficient to keep lots of programs loaded and let them swap out automatically. Around 64 MB is a good size to assign to swap space on a modern machine with 32-64 MB of memory. If you have a lot of memory and are planning to use a memory hungry program like the GIMP then you might want to assign more. The maximum size a single swap partition can be is 128 MB, but you can have as many as you like. One machine I am currently setting up as a high performance Web server has four 128 MB swap partitions. If you really cannot spare another partition for swap, then you can run without it, and even have swap as a temporary file. See the mkswap man (manual) page on Linux once you are up and running.
To use fdisk you simply make new partitions. With the command line version: press n and then give a partition number. Then give a type (primary or extended). Finally assign a size in 'cylinders' or MB. Cylinders are a low level measure of disk capacity. For efficiency reasons it is best to give your sizes in cylinders. This gives the underlying drivers a performance gain as the size of the partitions matches the physical characteristics of the disk. You can make a partition to approximately the right size by looking at how big a cylinder is in MB and multiplying it up. For instance the disk on the machine I am typing on now says:
Disk /dev/sda: 255 heads, 63 sectors, 275 cylinders
Units = cylinders of 16065 * 512 bytes
So each cylinder contains about 7.8 MB. To make a new partition of 500 MB that works out at roughly 63 cylinders. The easiest way to get a partition about right is to make it then press p to see what the actual size is. If you are wildly wrong then delete it with the d command and try again. Soon you will have made a root partition and a swap partition of a suitable size. To commit the changes to the disk 'for real' use the w command. If you totally screw up then exit the program and try again. It does not save unless you explicitly tell it to. If you have space left over, my recommendation would be to make a large 'extended' partition to hold the space for later use.
Summary Once the partitioning procedures are over, then you can get on with installing lots of exciting applications, and forget about partitions. But it is important to take care and plan ahead in order to get the best results.
James Andrews is a Support Staff member for Linux.com, this article originally was shown on linuxplanet.com