Previous Section  < Day Day Up >  Next Section

Recipe 5.5. Viewing Drive Partitions with fdisk

5.5.1 Problem

You need to see all the partitions on a hard drive or drives. You may need to see exactly how space is allocated on the disk drives; you may want to "reclaim" some old Windows partitions, convert an unused partition to swap space, or find the /dev number for a partition. fdisk also tells you the filesystem on the partition, and shows any free space on a drive.

5.5.2 Solution

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

...

5.5.3 Discussion

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.

5.5.4 See Also

  • fdisk(8)

    Previous Section  < Day Day Up >  Next Section