Graham's Discoveries


Fixing partition order

One uses the command fdisk to fix the order:


root@graham-laptop:~# fdisk /dev/sda
The number of cylinders for this disk is set to 9729.
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):  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)

Command (m for help): 
We need the "extra functionality .."
Command (m for help): x

Expert command (m for help): m
Command action
   b   move beginning of data in a partition
   c   change number of cylinders
   d   print the raw data in the partition table
   e   list extended partitions
   f   fix partition order
   g   create an IRIX (SGI) partition table
   h   change number of heads
   i   change the disk identifier
   m   print this menu
   p   print the partition table
   q   quit without saving changes
   r   return to main menu
   s   change number of sectors/track
   v   verify the partition table
   w   write table to disk and exit

Expert command (m for help): f
Nothing to do. Ordering is already correct.


Expert command (m for help):
See here my disc partition order doesn't need fixing so I get the "Nothing to do".

If your order is not correct it will fix it and just say "Done."

NOTE: this sometimes busts the partition table for parted et al.
You need to look for the '+' sign in the table layout (next to 104359):
Expert command (m for help): r

Command (m for help): p

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd58d002e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3263    26210016    7  HPFS/NTFS
/dev/sda2            3264        9729    51938145    f  W95 Ext'd (LBA)
/dev/sda5            3264        3276      104359+  83  Linux
/dev/sda6            3277        4582    10490445   83  Linux
/dev/sda7            4583        9729    41343246   83  Linux

Command (m for help): 
In the list of "Blocks" one or more may have a '+' after it.

This means the block count is not exact which parted et al interprets as an overlap.

See http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/201 to see the original ticket I raised which has the details on how to fix that.