[arch-general] fdisk vs cfdisk... And is my drive borked or what?

Joe(theWordy)Philbrook jtwdyp at ttlc.net
Thu Mar 18 10:10:28 CET 2010


It would appear that on Mar 17, Linas did say:

> Joe(theWordy)Philbrook wrote:
> > fdisk /dev/sda
> >
> > Which complained about a dos compatibility flag and that I should
> > change the display/entry units to sectors. This showed me a small bit of
> > unused space above my last logical partition (/dev/sda12)...

> It shows those two warnings with the default call. AFAIK it is unrelated to
> your actual partition contents.

I'll buy that... The odd thing is the fdisk from my other distros doesn't
bother... So the warnings got my attention.

> > Anyway I decided to look at it with cfdisk (which I haven't used in years
> > but remembered as being easier to work with than fdisk...) But all I got
> > from cfdisk was.
> >
> > =>  FATAL ERROR: Bad primary partition 3: Partition ends after end-of-disk
> > =>                                   Press any key to exit cfdisk
> >
> > When "cfdisk /dev/sda" says "partition 3:" is it counting from 0?
> > That is, does it mean "/dev/sda4" ???
> 
> Could be.
> 
> > I've pasted both the sector and cylinder views of my part table below, Is
> > this anything I should be worried about??? Is there a way to fix this
> > without destroying everything in the extended partition??? (That's a LOT of
> > backing up to dvd, and I don't have room anyplace else...)
> >    
> Caveat emptor: you should have a backup before touching partitions :)
> That said, you only want to "truncate" the partitions, and since your last
> partition is the swap, that should be pretty safe. The process of unmounting
>  swap partition, delete partition with fdisk, create with fdisk, reformat swap
> /shouldn't/ affect your data.

I hadn't intended to touch the partitions. I only gave the malfunctioning 
installer permission to reformat an existing ext2 partition as ext3.
That's an mkfs job that shouldn't have led to ANY table rewrite, never mind
writing to the table of a different drive...

Also, backing up everything isn't always practical. I really don't
have the spare storage space. So backing up 4 Linux installations would
eat a *LOT* of time and several DVD's... I do have enough room on my usb
drive to back up the personal data partitions. But if I bork up the drive
while fixing this I'm going to have to do a *LOT* of reinstalling from
scratch.  Which leads to a *LOT* of painful configuring... But I note
that while the ending sector of the extended partition apparently
exceeds the drive's ending sector... The ending sector of the last
logical partition within it does not... So I don't think I need to redo
the swap. but rather (and for me more problematic) just the extended
partition that contains it. {I'll have more on that in my reply to Mauro below.}

It would appear that on Mar 17, Mauro Santos did say:

> On 03/17/2010 10:45 PM, Linas wrote:
> > Joe(theWordy)Philbrook wrote: {quote tag re-inserted by Joe...}
> >> =>  FATAL ERROR: Bad primary partition 3: Partition ends after
> >> end-of-disk
> >> =>                                   Press any key to exit cfdisk
> 
> cfdisk can complain if _anything_ isn't as it wants it to be. cfdisk is
> easier to use than fdisk but complains a lot if the partition table
> deviates a little from the most compatible "format" possible.

So I noticed... But I think it does have a point.

> >> Because that's my extended partition... And a close look at the ending
> >> cylinder/sector of /dev/sda4 is a slightly higher number than it reports
> >> the total cylinders/sectors to be...
> 
> I take it that the first listing is in sectors, if you look closely you
> will see that your last partition (swap) end before the end of the disk
> so you're safe, the extended partition is just a placeholder for other
> partitions, so if the partitions do not try to use space that doesn't
> exist it should be ok. However I would still try to rectify the ending
> of the extended partition. Backup all your data and try to shrink that
> extended partition until it fits in your disk.

I can backup all my personal data... But I don't have the room to back up
all my Linux installations. Rebuilding them all from scratch, all at once
would be a nightmare. But it's a risk I'll have to take. I'm not so sure
how to shrink the extended partition itself. cfdisk won't touch it. And if
I remember right, to do it with fdisk I basically have to delete and then
recreate the said extended partition using the correct sectors... But that
would, I think mean I'd have to delete the logical partitions first, and
then recreate them with their correct sector information within the
correctly recreated extended partition. 
(And pray I got it "right" before I "write" the rebuilt table.)

I've never used gparted (unless maybe it was used as a backend for the "set
up your partitions manually" section of some Linux installer???
But does it have the ability to resize a NON-empty extended partition?
If not, is there something I can get from pacman that does?

And is it any more risky than the tedious fdisk process I described above?
 
> > I find an oddity on your paritition table, though. You say that
> > /dev/sda4 is an extended partition (and you do have logical partitions)
> > but it is listed by fdisk as having type 0xf (W95 Ext'd (LBA)) instead of
> > 0x5 (Extended). I suspect that after testdisk restoring, some old entries
> > got loaded?  If that's really a wrong entry, you can do the fdisk
> > delete/recreate tip to force its length to be inside the disk limits.
> > However, fdisk won't allow you to set a partition type of 5, which is a
> > pity when you *really* know what you are doing.

Actually while I don't think the ending sector of the extended partition used
to be past the end of the drive before testdisk rebuilt my drive's table
for me. I'm quite sure the (W95 Ext'd (LBA)) part has been there forever.
The first thing I did when I got this laptop that was destined for at least
dual booting was to use the vista cd to repartition the drive into one much
smaller ntfs, two fat, and one extended partition(s) before I reinstalled
vista. Then I used Linux tools to add the logical drives. And eventually
turn the smaller fat into an ext2 /boot partition. 

> Type 0xf is also ok, it all depends on which program created the
> partition table initially, I'm not sure but I think gparted used to set
> extended partitions to 0xf and so do many other programs.
> fdisk should be able to change the type to 5 but if it can't then give
> sfdisk a try but make sure all your data is safe.
> 

0xf, 5, Who cares which it's called? As long as it contains the logical
partitions...  But the ending sector thing will bug me if I don't fix it.
So for my piece of mind I'm gonna have to do something...



More information about the arch-general mailing list