LinuxBasics.org

The community that helps people to run Linux

rss
Table of Contents

Fix Partition Table

If you try to boot and get a failure, one of the possible problems might be a corrupt partition table. You would have already been directed to run fsck. If fsck told you that your partition table is corrupt, it means that you will need to rewrite it. Your data is still on the disk, but the boundaries of the various partitions are unknown to your system without a valid partition table.

If you have made a hard copy of your table, you will be able to use a partition tool to just write those numbers in and reconstruct your table. It is important to use the same tool to rewrite the table, because the tools produce slightly different numbers.

    fdisk -l > partition-table.txt

The following tools are the same ones used to install the various distributions of Linux. Many of them have a front end such as SuSE’s “Yast” which uses parted.

Partitioning Tools

fdisk - Linux fdisk is the most basic of the partitioning tools and will be found on most systems.

parted - GNU Parted is an industrial-strength package for creating, destroying, resizing, checking and copying partitions, and the file systems on them.

cfdisk- Using cfdisk to partition your harddisk

sfdisk

qtparted - Partition Magic clone written in C++ using the Qt toolkit

gpart - guess the partition table when it is damaged and you don’t have it written down

More about the Partition Table and the MBR

The MBR is a small part of the first harddisk that is reserved for the “Definitions” of the partitions.

The MBR is large enough to hold just 4 (four) definitions. In Linux more than 4 partitions is easy and highly recommended.

In order to fit more than 4 partitions into the MBR we make one of the partitions into an “extended Partition” (Just like Dr Who’s spaceship there is more on the inside that would appear from the outside). So now we can have 3 Primary and 1 Extended partitions. Inside the Extended partition we can put as many “Logical partitions” as we need. There is no difference between the actual Primary and Logical partitions, just where the definition is stored. The Windows scheme of 1 Primary and 1 Extended is wasteful, there is nothing wrong with 3 Primary and 1 Extended.

When building Windows I always use a D: drive, which can never be placed inside a Linux Extended partition.

So my default partition table looks like this, (only the sizes vary).

primary  hda1  Win C:
primary  hda2  Win D:	(10-25% of C:) (downloaded drivers go here)
primary  hda3  Linux  /boot    10-50Mb (normally mounted readonly)
extended hda4  Linux extended
logical  hda5  Linux  /	       1-1.5Gb  (not much writing here)
logical  hda6  Linux  /var     1Gb (Debian loves writing to this)
logical  hda7  Linux  Swap     500Mb
logical  hda8  Linux  /home    (Remainder of drive unless a second
Distro is wanted on this disk)
Experience tells me 500Mb of swap is more than enough.

MBR Section Contributed from an email by Douglas Orchard


Copyright (c) by the authors.
Prior to editing, authors agreed to license their contributions by the terms of the GPL.
See our licensing page for details.


Linux® is a registered trademark of Linus Torvalds.


 
  tutorials/using/fix_partition_table.txt · Last modified: 2008/07/20 21:08

LinuxBasics.org

Start Linux-Course Tutorials Linux Links Security Blog Forum E-mail List Search Online Chat

Site-Info

Help Get in Touch Making of LBo

Wiki-Control

Powered by

Linux Apache DokuWiki Mailman RUTE ht://Dig