linuxnewbie.org.gif
Tuesday, 12-Dec-2000 10:32:08 EST
Newbized Help Files articles discussion board bookshelf sensei's log advertising info

Using fdisk

by Danny "Strike" DiPaolo

In spite of its mostly spartan interface, fdisk is actually a very powerful, easy-to-use tool. To run fdisk, su to root and run "fdisk <device>", or perhaps (if /sbin is not in your path) "/sbin/fdisk <device>" - where <device> is something like /dev/hda or /dev/sda, the device we will be partitioning. For a good primer on partitions and filesystems, go see the NHF on them by 7DS: http://linuxnewbie.internet.com/nhf/intel/filesys/filesysintro.html

For my personal example, I've got Linux on my second IDE hard drive, so I'm going to be using /dev/hdb for my example. Remember to change it where appropriate.

So, once you are in fdisk, you should see a prompt like this:


[root@localhost /]# /sbin/fdisk /dev/hdb

The number of cylinders for this disk is set to 2491.
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., LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): 

You may or may not get that warning, depending upon your hard drive geometry. Most disks larger than 8GB will get this warning, if not all.

But now what do I do? Well, about the only clue I have here is that "m for help" in the prompt, so let's try that:


Command (m for help): m
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): 

Excellent! Now we have a list of commands whenever we need them. Okay, now lets explore my hard drive for a second and see what fdisk has to say about it. So let's use "p" and print the partition table:


Command (m for help): p

Disk /dev/hdb: 255 heads, 63 sectors, 2491 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hdb1   *         1       195   1566306   a5  BSD/386
/dev/hdb2           196       212    136552+  82  Linux swap
/dev/hdb3           213      2491  18306067+   5  Extended
/dev/hdb5           213       474   2104514+  83  Linux
/dev/hdb6           475       506    257039+  83  Linux
/dev/hdb7           507       532    208844+  83  Linux
/dev/hdb8           795       925   1052257   83  Linux
/dev/hdb9           926      1056   1052257   83  Linux
/dev/hdb10         1057      1088    257008+  83  Linux
/dev/hdb11         1089      1350   2104483+  83  Linux
/dev/hdb12          533       794   2104483+  83  Linux

Command (m for help): 

Let's take a look at each of these columns one by one.

Device - this specifies which device fdisk is looking at as well as which partition. The partition number is the last (and only) number in this section. Partitions 1-4 are "primary partitions", and any partition above 5 is a "logical partition". I'm not going to go into them much more because that would make this NHF much longer than it's already going to be.

Boot - If this column has an asterisk (like my /dev/hdb1 does), that means this partition is flagged as bootable. This means that if this is the primary hard drive (for IDE, /dev/hda is), then this is the partition that the OS or boot-loader is expected to be found on.

Start - This is the starting cylinder of the partition. A cylinder isn't a fixed size for all hard drives, but you can figure out how big each one is on your particular hard drive just by looking at the info at the top. Where it says "Units = cylinders of 16065 * 512 bytes", that tells you how big a cylinder is. So, mine are actually about 8MB per cylinder for this hard drive.

End - This is the ending cylinder of the partition. This can be important when loading up a system because of a (now old) limitation in LILO that won't allow /boot to be beyond the 1024th cylinder. Other than that, it's not too important to us right now.

Blocks - the number of blocks in this partition (duh). A block's size depends upon how you set up the filesystem. For the most part though, they will be 1KB blocks. For example, my first partition has 1566306KB of space, or about 1.5GB - that sounds about right :)

Id - a sort of identification number for partition types. Each type of partition has a different number. You can see all the different types of partitions that fdisk recognizes by simply entering in "l" at the menu prompt (that was option "list known partition types").

System - this is actually just an English version of the ID column. It simply takes the entry from the ID column and compares it to the table of partition types that it knows (as you can see with the "l" option), and prints out that type.

[- next page: Creating Filesystems -]


Would you like to have your article published online? Send them in to newfiles@linuxnewbie.org

The Linux Channel at internet.com
Linux Planet
Linux Today
Linux Central
Linuxnewbie.org
PHPBuilder
Just Linux
Linux Programming
Linux Start
BSD Today
Apache Today
Enterprise Linux Today
BSD Central
All Linux Devices
SITE DESCRIPTIONS
[-What's New-]
Order a Linuxnewbie T-Shirt
Easy Webcam NHF
Directory Navigation NHF
Installing Snort 1.6.3 on SuSE 6.x-7.x
Customizing vim
The SysVinit NHF
Installing ALSA for the VT82C686 integrated sound
USB Creative Video Blaster II for Linux
Configuring the Intellimouse Explorer in XFree86 V4+
The beginnings of a distro NHF
Getting Past Carnivore?
Getting and Installing PGP
Getting your ATI Rage 128 Working
How to create a multiple partition system
Using Fdisk
Introduction to Programming in C/C++ with Vim
Adding a Hard drive in Linux -- In five steps
Installing ALSA for the Yamaha DS-XG Sound Card
Getting your Diamond Rio Mp3 Player to work with Linux
Bash Programming Cheat Sheet
Installing NVIDIA Drivers for Mandrake
Setting up Portsentry
Hard Drive Speed Tweak for Linux
Sensei's Log
Chat room
Join: Linuxnewbie.org SETI Black Belts!
Send in your news
Click the image to add Linuxnewbie.org to your MyNetscape Page
[-LNO Newsletter-]

[-Archive-]
The beginnings of a distro NHF
Connecting to the Internet using KPPP
Getting your SBLive to work
Unreal Tournament NHF
LWE Day 2 Pictures
LWE Day 1 Pictures
The LNO FAQ!
WoW (Words of Wisdom)
Other sites news
What is Linux?
What is Linux? part deux (ups & downs)
Search newsgroups
The List
ALS Report
Feedback Form
jobs.linuxtoday.com.gif
Match: Format: Sort by:
Search:
[-Quick Links-]

Copyright 2000 internet.com Corp. All Rights Reserved. Legal Notices Privacy Policy

internet.com.gif