Jump to content

How to view drive partitions with fdisk

+ 2
  carlaschroder's Photo
Posted Sep 22 2009 10:21 AM

You need to see all the partitions on a hard drive or drives, need to see exactly how space is allocated on the disk drives, convert an unused partition to swap space, or find the /dev number for a partition, use

You need to see all the partitions on a hard drive or drives, need to see exactly how space is allocated on the disk drives, convert an unused partition to swap space, or find the /dev number for a partition, use fdisk.

To display all partitions on all hard drives, use:

# /sbin/fdisk -l

Disk /dev/hda: 20.5 GB, 20576747520 bytes

255 heads, 63 sectors/track, 2501 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 Device Boot   Start     End    Blocks   Id  System

/dev/hda1   *   1        893    7172991   7  HPFS/NTFS

/dev/hda2      894      1033   1124550    c  W95 FAT32 (LBA)

/dev/hda4     1034      2501  11791710    f  W95 Ext'd (LBA)

/dev/hda5     2437      2501    522081   82  Linux swap

/dev/hda6     1034      1670   5116639+  83  Linux

/dev/hda7     1671      2436   6152863+  83  Linux

Disk /dev/hdb: 40.0 GB, 40020664320 bytes

16 heads, 63 sectors/track, 77545 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

 Device Boot   Start      End       Blocks   Id  System

/dev/hdb1   *     1       4162     2097616+  82  Linux swap

/dev/hdb2      4163      77545    36985032   83  Linux

Partition table entries are not in disk order

To display the partition table on a selected drive, use:

# /sbin/fdisk -l /dev/hda

Disk /dev/hda: 20.5 GB, 20576747520 bytesDisk /dev/hda: 20.5 GB, 20576747520 bytes

255 heads, 63 sectors/track, 2501 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

...

You can also see what type of filesystem is located on any partition. In this example, you see two different types of Windows filesystems (HPFS/NTFS, FAT32) and a Windows extended partition on which some Linux filesystems and a swap partition have been built.

Linux Cookbook

Learn more about this topic from Linux Cookbook.

Linux information can be found scattered in man pages, texinfo files, and source code comments, but the best source is the experts who have built up a working knowledge of managing Linux systems. The Linux Cookbook's tested techniques distill years of hard-won experience into practical cut-and-paste solutions to everyday Linux dilemmas. Use just one recipe from this collection of real-world solutions, and the hours of tedious trial-and-error saved will more than pay for the cost of the book. It's more than a time-saver; it's a sanity saver.

See what you'll learn


Tags:
0 Subscribe


0 Replies