Recipe 9.16. Creating Linux Disk Partitions with fdisk

 < Day Day Up > 

9.16.1 Problem

You need to partition a new hard drive, or partition free space on an existing hard drive.

9.16.2 Solution

One way is to boot up a Knoppix disk and use QTParted, a great graphical application that creates, deletes, moves, and resizes partitions, without destroying the data. It even resizes NTFS partitions.

You can also use fdisk. This example shows how to create a primary partition:

# fdisk /dev/hda The number of cylinders for this disk is set to 2501. 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): n Command action    l   logical (5 or over)    p   primary partition (1-4) p Partition number (1-4): 3 First cylinder (511-1232, default 511): 511 Last cylinder or +size or+sizeM or +sizeK (511-1232, default1232): +3000M Command (m for help): w The partition table has been altered!     Calling ioctl( ) to re-read the partition table Syncing disks #

That's it. You can change your mind right up to the end, until you hit w to write the new partition table to disk. At any time, you can hit m to see a menu of commands. q always quits.

Before you can put any data on the new partition, you'll need to reboot, then put a filesystem on it (see the next recipe).

9.16.3 Discussion

Use Linux's fdisk only to create Linux volumes. For Windows volumes, use MS-DOS's fdisk.

Here is a list of the more commonly used Linux fdisk options:


m

Display help.


p

Show the current partition table.


d

Delete a partition.


n

Create a new partition.


w

Write the partition table to disk.


l

Display the list of filesystem types.


q

Quit fdisk without changing anything.

9.16.4 See Also

  • fdisk(8)

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net