Linux - fdisk - Partition table manipulator

About

fdisk is a utility that creates and manipulates the partition tables.

fdisk doesn't understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted.

It understands DOS type partition tables and BSD or SUN type disklabels.

There are several fdisk programs around. Each has its problems and strengths. Try them in the order parted, fdisk, sfdisk.

Whenever a partition table is printed out, a consistency check is performed on the partition table entries. This check verifies that the physical and logical start and end points are identical, and that the partition starts and ends on a cylinder boundary (except for the first partition).

If possible, fdisk will obtain the disk geometry automatically. This is not necessarily the physical disk geometry (indeed, modern disks do not really have anything like a physical geometry, certainly not some- thing that can be described in simplistic Cylinders/Heads/Sectors form), but is the disk geometry that MS-DOS uses for the partition table.

Syntax

Changes you make to the partition table do not take effect until you issue the write (w) command.

Harddisk

fdisk is started by typing (as root) at the command prompt:

fdisk device
fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
fdisk -l [-u] [device ...]
fdisk -s partition ...
fdisk -v

Options:

  • -b sectorsize

Specify the sector size of the disk. Valid values are 512, 1024, or 2048. (Recent kernels know the sector size. Use this only on old kernels or to override the kernel's ideas.)

  • -C cyls

Specify the number of cylinders of the disk. I have no idea why anybody would want to do so.

  • -H heads

Specify the number of heads of the disk. (Not the physical number, of course, but the number used for partition tables.) Reasonable values are 255 and 16.

  • -S sects

Specify the number of sectors per track of the disk. (Not the physical number, of course, but the number used for partition tables.) A reasonable value is 63.

  • -u

When listing partition tables, give sizes in sectors instead of cylinders.

  • -s partition

The size of the partition (in blocks) is printed on the standard output.

Version

With the -v otpion, Print version number of fdisk program and exit.

List partition

With the -l option: List the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used.

[root@oel11g ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux

Help

fdisk /dev/sdb
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)

Create partition

Delete partition

  • d delete a partition

Write the partition table

  • w write the new partition table and exit

Quit

  • q quit without saving changes

Flag

Partition Flag





Discover More
Harddisk
Drive - Hard (disk|drive) (HDD) - Mass Storage - Flash

A disk is a storage device that refers to magnetic media, such as: a floppy disk, the disk in your computer's hard drive, an external hard drive. It's also known as mass storage device. Disks...
Windows Disk
File System - Partition table (Sector 0)

A partition table is data that holds partition division information. The partition table is stored within the Master Boot Record of the disk (found in the first sector (0) of the disk) Partition table...
Card Puncher Data Processing
IO - Block (Batch on device)

A block is a unit of storage representing a fix number of bytes called the block size. It's also known as the minimum unit of transfer. It implements the concept of batch where data is organized into...
Linux - Adding storage without LVM

When you add a disk device to your system, you need to add this storage in your Linux environment When you improve the disk capacity of your Virtual Vmware Machine, you just need to configure the device...
Windows Disk
Linux - Disk Partition (logical disk)

Hard disks can be divided into one or more logical disks called partition. This division is described in the partition table found in sector 0 of the disk. The partition is the last part of...
Linux - How to add storage to an OEL 5 update 4 Linux VMWare Machine

When you increase the disk capacity of a VMWare virtual machine, you need to perform some operation to add this capacity to the file system. The basic installation of Oracle Entreprise Linux use Linux...
Linux - resize2fs - ext2/ext3 file system resizer

The resize2fs program will resize ext2 or ext3 file systems. It can be used to enlarge or shrink an unmounted file system located on device. If the filesystem is mounted, it can be used to expand the...



Share this page:
Follow us:
Task Runner