|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Saturday, 7 August 1999||Author: Mark Nielsen|
|Published to: featured_articles/Featured Articles||Page: 1/1 - [Std View]|
How to Use Fdisk in Linux to Remap a Hard Drive
This is a technical article showing how fdisk, a partitioning tool for Linux, can remap a hard drive. Topics include links to resources on the Web, an introduction to fdisk, and the use of fdisk to initialize a new hard disk. This article was written by Stefan Dimitrov and Mark Nielsen from 800linux.com....
The latest version of this article, and future updates, will be located at the Computer Underground.
The purpose of this article is to explain how we use fdisk manually to initialize IDE hard drives instead of using Disk Druid that comes with Red Hat 6.0. Why do you want to do this? Well, it can be one way of many ways to solve the problem where you need to have your bootable files for Linux before the 1024th cylinder. There are many ways to solve this problem, but for this article, we are only going to concentrate on redoing the number of heads and cylinders for your IDE hard drive. For further information about why you can do this, read the file "/usr/src/linux/Documentation/ide.txt" on your RedHat 6.0 computer (assuming you have the source code for the kernel installed).
Fdisk is a tool that allows you to change the partitioning of your hard disks. For example, you can make DOS, Linux, FreeBSD, and many other types of partitions.
Disk Druid is a tool, used by Red Hat 6.0, to set up partitions and to initialize hard drives when you install Red Hat 6.0. The problem is, I never found out how to use Disk Druid to initialize a second hard drive after RedHat 6.0 is installed.
There are also extra functions in fdisk. Some of them can be used to initialize your new hard drive for use with linux, which requires you to have 1024 or less cylinders. For most of the people these functions will never be needed, but let's say that you have your computer with Linux on it and decide to add an extra hard disk. The easiest and fastest way to initialize it is to use fdisk.
Having 1024 cylinders or less is not an issue before you start using very large hard disks. The brief reason is, you can remap the heads and cylinders using LBA to make it so you reduce the number of cylinders and maximize the number of heads. In general up to 10G bytes there shouldn't be any problem, but with the fairly low prices of large hard disks today, more and more people go past the 10G bytes size and this is when having 1024 or less sectors becomes an issue. Also, there are other simple ways to get around the 1024 cylinder problem without remapping your hard drive (like using a partition for /boot) but we won't get into that here.
There are two steps you need to do. First, find out the number of heads, cylinders, and sectors your hard drive has in the LBA setting in your BIOS. Then, use fdisk to you remap the hard drive.
First, turn off your computer, install the second hard drive, turn your computer on, and before it boots your operating system, get into your computers BIOS. Usually pressing the delete key, the F1 key, or perhaps some other key, gets you into the BIOS of your computer before it gets ready to start booting your operating system. It is recommended that you get professional help when your install another hard drive.
Then, in your BIOS you should be able to find the LBA settings for the hard drive. Sometimes if you have a feature in your BIOS which lets you auto-detect your IDE devices, it will let you know what the LBA settings for your hard drives should be. Get the LBA settings for the cylinders for your new hard drive. The LBA settings for the sectors and heads should be: heads=255, sectors=63.
Second, you want to start fdisk with one of the following commands after booting your Linux operating system:
fdisk /dev/hdb # for your second hard drive, slave on primary controller fdisk /dev/hdc # for your third hard drive, master on secondary controller fdisk /dev/hdd # for your fourth hard drive, slave on secondary controllerAfter you choose which command is appropriate, you will have the following prompt:
Command (m for help):Pressing 'm' will result in the following help 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) Command (m for help):At this point you have to enter 'x', which will lead you to the extra functionality menu:
Expert command (m for help):Pressing 'm' again will show you the options in this menu:
Command action b move beginning of data in a partition c change number of cylinders d print the raw data in the partition table e list extended partitions g create an IRIX partition table h change number of heads m print this menu p print the partition table q quit without saving changes r return to main menu s change number of sectors v verify the partition table w write table to disk and exit Expert command (m for help):Notice that you have 'c' for changing the number of cylinders, and 'h' for changing the number of heads. These are the options we are going to use. The idea is to maximize the number of cylinders and minimize the number of heads. In order to do this, enter 'c' at the Expert menu and you will get the following prompt:
Number of cylinders (1-65535, default 789):At this prompt you should enter the number that the LBA shows for cylinders in the BIOS. After you enter the number of cylinders, you will be back at the expert menu. Press 'h' and this prompt will ask you for the number of heads:
Number of heads (1-256, default 64):You can leave the number of heads at 64, since this is the lowest you can go. After you enter 64, you are back at the Expert prompt. At this point you need to save the changes by entering 'w'. After that the fdisk will exit and you are done.
Actually, before typing "w", I might enter "r" or return you to the main menu, and then enter "p" just to see what you have done. If the number of heads is 255 and the sectors are 63, and the number of cylinders is correct, then you are done and you can enter "w".
Stefan Dimitrov works for 800linux.com as a Technical Supervisor. Mark Nielsen works as a receptionist at The Computer Underground, as Vice President of Technology at 800linux.com, and as some sort of volunteer at linux.com. This document was edited using Vi text editor, emacs, and ispell.