Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
The ONE Campaign to make poverty history

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents
Up to --> Installing and Upgrading

· Getting Your Own Copy
· Preparing for the Installation
· Installation Checklist
· Hardware Requirements
· Partitioning
· Swap Space
· Installation Problems
· Preparing for the Worst

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Recommend Us
Surveys

Features
HOWTOs
News
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 191 guest(s) and 5 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  
Linux Tutorial - Installing and Upgrading - Preparing for the Installation - Partitioning
  Hardware Requirements ---- Swap Space  


Partitioning

If you have an existing system that takes up the whole disk, you will have to backup and reinstall the existing system to make room for Linux. You need to be careful because you may make partition too small for all the files that were there before!

A couple of tools are available on the Internet that will reformat a DOS partition with an existing system (assuming there is enough free space). I have never used such a tool, although I have read messages on the Internet from people who have done it successfully.

During the installation, you will have a chance to either install on an existing partition or repartition the drive. As with other PC-based OSs, use the fdisk tool to partition the drive. Some distributions have full-screen, menu-driven versions, but they all perform the same functions, such as creating, deleting, and making partitions active.

However, the Linux fdisk can do much more than that. For example, it can change the partition type, which is helpful when you need to have a system with several different OSs. DOS can only create a single primary and a single extended partition. I have used Linux to create all of the necessary partitions and then used DOS to recognize them correctly.

Another useful thing is that the Linux fdisk will do what you tell it. I have wanted to delete an entire extended partition but couldn't because logical partitions were there. Linux will do that for you.

As with other operating systems, Linux fdisk will see that other partitions are there, even though it may not know what type they really are. Linux is very good at recognizing the type, although there are a few cases in which I have seen it off the mark (but not by much). The reason is that all fdisk versions just read the partition table, which is in a common format.

Warning: I have seen a number of Linux certification prep books that claim you can only have four primary partitions or three primary partition and one extended partition which is further broken down into four logical partitions for a total of seven (7) partitions. He is the partition layout of one hard disk my current system:

/dev/hda1 * 1 222 1783183+ 7 HPFS/NTFS /dev/hda2 223 229 56227+ 83 Linux /dev/hda3 230 882 5245222+ 83 Linux /dev/hda4 883 9963 72943132+ f Win95 Ext'd (LBA) /dev/hda5 883 1078 1574338+ 82 Linux swap /dev/hda6 1079 2384 10490413+ 83 Linux /dev/hda7 2385 3037 5245191 c Win95 FAT32 (LBA) /dev/hda8 3038 3168 1052226 83 Linux /dev/hda9 3169 6811 29262366 83 Linux /dev/hda10 6812 7072 2096451 83 Linux /dev/hda11 7073 7725 5245191 83 Linux

The first three partitions (hda1, hda2, and hda3) are all primary partitions. The extended partition (hda4) is devided into eight (8) or twice the number these books claim. This is very outdated information, but it may appear on the Linux certification like this.

Note also that depending on how old the book is, it might tell you that there is a limit of 128 MB of swap. This is no longer true with Linux 2.2.x and later and later kernels. The current limits are approximately 2 GB on x86,MC680x0 and PowerPC, 512 MB on MIPS, 128 GB on Alpha, and 3 Terabytes on UltraSparc.

Note also that depending on how old the book is, it might tell you that there is a limit of 128 MB of swap. This is no longer true with Linux 2.2.x and later and later kernels. The current limits are approximately 2 GB on x86,MC680x0 and PowerPC, 512 MB on MIPS, 128 GB on Alpha, and 3 Terabytes on UltraSparc.

As you can see in the example above, the logical partitions start number at 5. This is true whether or not you are using up all of the primary partitions and is the same for IDE as well as SCSI drives.

During the installation of Linux, you will typically have a choice of doing an automatic or manual installation, and in some cases a combination of the two. If you chose a manual installation you will probably be allowed to defined the partition layout of your hard disks. On SUSE linux you have an "expert" mode which looks something like this:

SUSE Linux YAST - Hard disk partitioning

Note that this what is displayed here is what you get when you start YAST after the system is installed, so what you see during the installation might look different. You can see that the start cylinder of the first partition is 0. However in the text output above, the starting cylinder is 1. In fact, if you compare the two they are essentially identical except that the values differ by 1. So, you need to be careful if you are using values taking from fdisk (as above) and want to input them into YAST.

When you select the Create button, you reach the following screen:

SUSE Linux YAST - Partition and file system configuration

Here you are defining various parameters for this partition and the associated filesystem. In some cases, it is logical not to format the partition (i.e. create a filesystem). For example, if you are recovering from a crash where the partition table was destroyed, you can usually recover the filesystem fully if you simply input the appropriate values for the starting cylinder, ending cylinder and mount point.

Be careful not to specify the size of the partition but always specify the ending cylinder. This is because the size is not an exact value. You might think that the correct value is (for example) 4.3 GB, but because of the technical aspects of the hard disk it is closer to 4.26 GB. Inputting 4.3 GB might round down to only 4.28 GB, which is larger than you want. However, if you specify the ending cylinder, you always have the correct value.

The options that are provided will differ depending on the filesystem type you choose. For example, if you choose a type swap there are no options. If you choose and EXT3 filesystem, you can choose (for example); the block size, such as 1024, 2048, or 4096 bytes per block. If you select auto then the block size is determined by the file system size. Other filesystem have different options which appear in the left-hand frame when you choose the respective file system type.

Partitioning by hand using the fdisk command uses the same basic concepts. However, instead of showing all of the partitions on all of you hard disks, you need to specify the device node for the hard disk you which to partition (assuming you have more than one). For example, to partition the first IDE hard disk, the command might look like this:

fdisk /dev/hda

Be careful that this is the device node of the entire hard disk and not an individual partition like /dev/hda1. If you do, you will end up with a message like this:

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

If you decided to write the partition table, it will not do what you expect and you probably have lost all the data on the partition.

If you specify the correct device node, you end up with something like this:

The number of cylinders for this disk is set to 9964. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help):

Notice the warning about the number of cylinders. This is usually only an issue when booting the system and loading the kernel. Typically, I have by /boot directory on a separate file system that is one of the first two partitions. I make sure that the this partition ends below cylinder 1024 to ensure that there are no problems when booting. As with the GUI version (shown above), you can specify the ending cylinder so you don't have to do any calculations yourself in figuring out how big the partition is.

If you press m at this point, you get the following "menu":

Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)

To look at the existing partition partitions you input p, which gives you something like this:

Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 222 1783183+ 7 HPFS/NTFS /dev/hda2 223 229 56227+ 83 Linux /dev/hda3 230 882 5245222+ 83 Linux /dev/hda4 883 9963 72943132+ f Win95 Ext'd (LBA) /dev/hda5 883 1078 1574338+ 82 Linux swap /dev/hda6 1079 2384 10490413+ 83 Linux /dev/hda7 2385 3037 5245191 c Win95 FAT32 (LBA) /dev/hda8 3038 3168 1052226 83 Linux /dev/hda9 3169 6811 29262366 83 Linux /dev/hda10 6812 7072 2096451 83 Linux /dev/hda11 7073 7725 5245191 83 Linux

(Note that this is the same table as above)

If you take a close look, you will see that the extended partition (/dev/hda4) goes up to cylinder 9963. However, the last partition only goes up to cylinder 7725, thus there is a fair bit of free, unpartitioned space on this drive. If I want to create a new partition, I input n, which then prompts me for a start cylinder:

First cylinder (7726-9963, default 7726):

Since there is already three primary partition and one extended partition, you can only create a new logical partition. If some of these partitions were missing, you would be prompted to select the kind of partion with a prompt like this:

Command action e extended p primary partition (1-4)

Note that the start (first) cylinder is always 1 more than the last cylinder of the previous cylinder. If you then input 7726 (or simply press return) you are prompted to input either the size of the partition or the end/last cylinder. The default is the last available cylinder. Note that the calculate of the partition is not exact if your specify the size. The fdisk command will fit the size to cylinder boundary and thus you usually get a little less than you expect.

By default, fdisk will create a standard linux partition (as you can see in the last two columns). If you want to create a diffent kind of partion, you would input the t option to specify the type. Next you would input the number of the partition (so we might input 12 if we were adding a new partition) and then the hex code of the desired type. If you are not sure, you can input L and you will be shown a table of possible partition types:

0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wizard hid 1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris boot 2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT- 3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT- 4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/sec (FAT- 5 Extended 40 Venix 80286 83 Linux c7 Syrinx 6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data 7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / . 8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility 9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs f Win95 Ext'd (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT 10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/ 11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b 12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor 14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedStor 16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary 17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto 18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep 1b Hidden Win95 FA 65 Novell Netware b8 BSDI swap ff BBT

Most of the partition types listed are once that you probably never have heard of, let alone need. Looking at the fdisk output above, I only use a small fraction of these and have only ever needed a couple of others. Still, there are valid reasons to use any of the them.

At this point the partition table has not yet been changed. The changes are only in memory. It not until you input w to write the partition table and quit.

Unlike when you use the GUI, you are still not done. Unless you created a swap or other type of "administrative" partition, you cannot use the partition as it because it needs as file system. Creating a filesystem is comparable to formating a partition under DOS, the details of which can be found here.

 Previous Page
Hardware Requirements
  Back to Top
Table of Contents
Next Page 
Swap Space


MoreInfo

Test Your Knowledge

User Comments:


You can only add comments if you are logged in.

Copyright 2002-2009 by James Mohr. Licensed under modified GNU Free Documentation License (Portions of this material originally published by Prentice Hall, Pearson Education, Inc). See here for details. All rights reserved.
  
Help us cut cost by not downloading the whole site!
Use of automated download sofware ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and therefore is expressedly prohibited. For more details on this, take a look here

Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.06 Seconds